From b4ec9ca7385fa16b1fabe2b6989337408ac77e6b Mon Sep 17 00:00:00 2001 From: Li2CO3 Date: Mon, 23 Dec 2024 10:45:17 +0800 Subject: [PATCH] optimize: update kitex code and remove apache thrift api usage (#163) --- README.md | 4 +- basic/example_shop/go.mod | 23 +- basic/example_shop/go.sum | 43 +- .../kitex_gen/example/shop/base/base.go | 32 +- .../kitex_gen/example/shop/base/k-base.go | 102 +- .../kitex_gen/example/shop/item/item.go | 257 +- .../example/shop/item/itemservice/client.go | 4 +- .../shop/item/itemservice/itemservice.go | 64 +- .../example/shop/item/itemservice/server.go | 7 +- .../kitex_gen/example/shop/item/k-item.go | 435 +- .../kitex_gen/example/shop/stock/k-stock.go | 295 +- .../kitex_gen/example/shop/stock/stock.go | 205 +- .../example/shop/stock/stockservice/client.go | 4 +- .../example/shop/stock/stockservice/server.go | 7 +- .../shop/stock/stockservice/stockservice.go | 64 +- bizdemo/easy_note/go.mod | 23 +- bizdemo/easy_note/go.sum | 42 +- .../easy_note/kitex_gen/notedemo/k-note.go | 1938 ++-- bizdemo/easy_note/kitex_gen/notedemo/note.go | 1097 +- .../kitex_gen/notedemo/noteservice/client.go | 11 +- .../notedemo/noteservice/noteservice.go | 98 +- .../kitex_gen/notedemo/noteservice/server.go | 11 +- bizdemo/kitex_ent/go.mod | 23 +- bizdemo/kitex_ent/go.sum | 41 +- bizdemo/kitex_ent/kitex_gen/user/k-user.go | 1611 +-- bizdemo/kitex_ent/kitex_gen/user/user.go | 808 +- .../kitex_gen/user/userservice/client.go | 4 +- .../kitex_gen/user/userservice/server.go | 7 +- .../kitex_gen/user/userservice/userservice.go | 88 +- bizdemo/kitex_gorm/go.mod | 23 +- bizdemo/kitex_gorm/go.sum | 41 +- bizdemo/kitex_gorm/kitex_gen/user/k-user.go | 1611 +-- bizdemo/kitex_gorm/kitex_gen/user/user.go | 808 +- .../kitex_gen/user/userservice/client.go | 4 +- .../kitex_gen/user/userservice/server.go | 7 +- .../kitex_gen/user/userservice/userservice.go | 88 +- bizdemo/kitex_gorm_gen/go.mod | 23 +- bizdemo/kitex_gorm_gen/go.sum | 41 +- .../kitex_gorm_gen/kitex_gen/user/k-user.go | 1611 +-- bizdemo/kitex_gorm_gen/kitex_gen/user/user.go | 808 +- .../kitex_gen/user/userservice/client.go | 4 +- .../kitex_gen/user/userservice/server.go | 7 +- .../kitex_gen/user/userservice/userservice.go | 88 +- bizdemo/kitex_swagger_gen/go.mod | 23 +- bizdemo/kitex_swagger_gen/go.sum | 48 +- .../kitex_gen/openapi/k-openapi.go | 9364 ++++++----------- .../kitex_gen/openapi/openapi.go | 88 +- .../kitex_gen/user/k-user.go | 1383 +-- .../kitex_swagger_gen/kitex_gen/user/user.go | 22 +- .../kitex_gen/user/userservice/client.go | 3 +- .../kitex_gen/user/userservice/server.go | 2 +- .../kitex_gen/user/userservice/userservice.go | 5 +- bizdemo/kitex_zorm/go.mod | 23 +- bizdemo/kitex_zorm/go.sum | 41 +- bizdemo/kitex_zorm/kitex_gen/user/k-user.go | 1611 +-- bizdemo/kitex_zorm/kitex_gen/user/user.go | 808 +- .../kitex_gen/user/userservice/client.go | 4 +- .../kitex_gen/user/userservice/server.go | 7 +- .../kitex_gen/user/userservice/userservice.go | 88 +- codec/json/meta.go | 4 +- frugal/codec/frugal.go | 12 +- generic/binary/client/main.go | 13 +- .../kitex_gen/http/bizservice/bizservice.go | 81 +- generic/kitex_gen/http/bizservice/client.go | 10 +- generic/kitex_gen/http/bizservice/server.go | 11 +- generic/kitex_gen/http/http.go | 520 +- generic/kitex_gen/http/k-http.go | 676 +- go.mod | 27 +- go.sum | 42 +- hello/kitex_gen/api/hello.go | 217 +- hello/kitex_gen/api/hello/client.go | 10 +- hello/kitex_gen/api/hello/hello.go | 65 +- hello/kitex_gen/api/hello/server.go | 11 +- hello/kitex_gen/api/k-hello.go | 263 +- kitex_gen/api/echo.go | 193 +- kitex_gen/api/echo/client.go | 4 +- kitex_gen/api/echo/echo.go | 64 +- kitex_gen/api/echo/invoker.go | 2 +- kitex_gen/api/echo/server.go | 7 +- kitex_gen/api/k-echo.go | 267 +- kitex_gen/pbapi/echo.pb.go | 6 +- kitex_gen/pbapi/echo/client.go | 2 +- kitex_gen/pbapi/echo/echo.go | 72 +- kitex_gen/pbapi/echo/server.go | 6 +- kitex_gen/slim/api/echo.go | 45 +- kitex_gen/slim/api/echo/client.go | 4 +- kitex_gen/slim/api/echo/echo.go | 64 +- kitex_gen/slim/api/echo/server.go | 7 +- kitex_gen/slim/api/k-echo.go | 10 +- metainfo/backward/client/main.go | 1 + regenerate-idl.sh | 35 +- server_sdk/thrift/main.go | 7 +- thrift_multi_service/kitex_gen/api/demo.go | 294 +- thrift_multi_service/kitex_gen/api/k-demo.go | 391 +- .../kitex_gen/api/servicea/client.go | 2 +- .../kitex_gen/api/servicea/server.go | 2 +- .../kitex_gen/api/servicea/servicea.go | 8 +- .../kitex_gen/api/serviceb/client.go | 2 +- .../kitex_gen/api/serviceb/server.go | 2 +- .../kitex_gen/api/serviceb/serviceb.go | 8 +- thrift_streaming/kitex_gen/echo/api.go | 1681 +-- thrift_streaming/kitex_gen/echo/k-api.go | 767 +- .../kitex_gen/echo/testservice/client.go | 2 +- .../kitex_gen/echo/testservice/server.go | 2 +- .../kitex_gen/echo/testservice/testservice.go | 29 +- 105 files changed, 10179 insertions(+), 21801 deletions(-) diff --git a/README.md b/README.md index b23ab2e4..f2862a77 100644 --- a/README.md +++ b/README.md @@ -78,4 +78,6 @@ You can go into the related examples for information on "how to run" ## Note -All commands to execute the example should be executed under "kitex-examples". \ No newline at end of file +All commands to execute the example should be executed under "kitex-examples". + +Execute 'regenerate-idl.sh' to re-generate all kitex_gen (include sub mods) \ No newline at end of file diff --git a/basic/example_shop/go.mod b/basic/example_shop/go.mod index 91d88baa..44ec1177 100644 --- a/basic/example_shop/go.mod +++ b/basic/example_shop/go.mod @@ -7,35 +7,36 @@ toolchain go1.21.4 replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 require ( - github.com/apache/thrift v0.16.0 + github.com/cloudwego/gopkg v0.1.3 github.com/cloudwego/hertz v0.9.3 - github.com/cloudwego/kitex v0.11.3 + github.com/cloudwego/kitex v0.12.0 + github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 github.com/kitex-contrib/registry-etcd v0.2.5 ) require ( + github.com/apache/thrift v0.16.0 // indirect github.com/bytedance/go-tagexpr/v2 v2.9.2 // indirect github.com/bytedance/gopkg v0.1.1 // indirect - github.com/bytedance/sonic v1.12.2 // indirect + github.com/bytedance/sonic v1.12.5 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/configmanager v0.2.2 // indirect - github.com/cloudwego/dynamicgo v0.4.0 // indirect + github.com/cloudwego/dynamicgo v0.4.6 // indirect github.com/cloudwego/fastpb v0.0.5 // indirect - github.com/cloudwego/frugal v0.2.0 // indirect - github.com/cloudwego/gopkg v0.1.2 // indirect + github.com/cloudwego/frugal v0.2.3 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cloudwego/localsession v0.0.2 // indirect - github.com/cloudwego/netpoll v0.6.4 // indirect + github.com/cloudwego/localsession v0.1.1 // indirect + github.com/cloudwego/netpoll v0.6.5 // indirect github.com/cloudwego/runtimex v0.1.0 // indirect - github.com/cloudwego/thriftgo v0.3.17 // indirect + github.com/cloudwego/thriftgo v0.3.18 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect github.com/henrylee2cn/ameda v1.4.10 // indirect github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 // indirect @@ -67,6 +68,6 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect google.golang.org/grpc v1.59.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/basic/example_shop/go.sum b/basic/example_shop/go.sum index 700b0b52..4c3c3147 100644 --- a/basic/example_shop/go.sum +++ b/basic/example_shop/go.sum @@ -13,8 +13,8 @@ github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP github.com/bytedance/mockey v1.2.12 h1:aeszOmGw8CPX8CRx1DZ/Glzb1yXvhjDh6jdFBNZjsU4= github.com/bytedance/mockey v1.2.12/go.mod h1:3ZA4MQasmqC87Tw0w7Ygdy7eHIc2xgpZ8Pona5rsYIk= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic v1.12.2 h1:oaMFuRTpMHYLpCntGca65YWt5ny+wAceDERTkT2L9lg= -github.com/bytedance/sonic v1.12.2/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= +github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= @@ -28,28 +28,30 @@ 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/configmanager v0.2.2 h1:sVrJB8gWYTlPV2OS3wcgJSO9F2/9Zbkmcm1Z7jempOU= github.com/cloudwego/configmanager v0.2.2/go.mod h1:ppiyU+5TPLonE8qMVi/pFQk2eL3Q4P7d4hbiNJn6jwI= -github.com/cloudwego/dynamicgo v0.4.0 h1:wQqNRNiSQaLkbcn3sfpEJGZsz3xf8Il4P/3DcENsrFI= -github.com/cloudwego/dynamicgo v0.4.0/go.mod h1:zgWk2oz56EyH790LJSxrTz1j01GJBO964jJQ/y7qjJc= +github.com/cloudwego/dynamicgo v0.4.6 h1:raRdvLN1WsGl5WsNd2Ul86s8PFQPu8soF4ALSJ9MdC4= +github.com/cloudwego/dynamicgo v0.4.6/go.mod h1:DknfxjIMuGvXow409bS/AWycXONdc02HECBL0qpNqTY= github.com/cloudwego/fastpb v0.0.5 h1:vYnBPsfbAtU5TVz5+f9UTlmSCixG9F9vRwaqE0mZPZU= github.com/cloudwego/fastpb v0.0.5/go.mod h1:Bho7aAKBUtT9RPD2cNVkTdx4yQumfSv3If7wYnm1izk= -github.com/cloudwego/frugal v0.2.0 h1:0ETSzQYoYqVvdl7EKjqJ9aJnDoG6TzvNKV3PMQiQTS8= -github.com/cloudwego/frugal v0.2.0/go.mod h1:cpnV6kdRMjN3ylxRo63RNbZ9rBK6oxs70Zk6QZ4Enj4= -github.com/cloudwego/gopkg v0.1.2 h1:650t+RiZGht8qX+y0hl49JXJCuO44GhbGZuxDzr2PyI= -github.com/cloudwego/gopkg v0.1.2/go.mod h1:WoNTdXDPdvL97cBmRUWXVGkh2l2UFmpd9BUvbW2r0Aw= +github.com/cloudwego/frugal v0.2.3 h1:t1hhhAi8lXcx7Ncs4PR1pSZ90vlDU1cy5K2btDMFpoA= +github.com/cloudwego/frugal v0.2.3/go.mod h1:nC1U47gswLRiaxv6dybrhZvsDGCfQP9RGiiWC73CnoI= +github.com/cloudwego/gopkg v0.1.3 h1:y9VA5Zn5yqd1+QBV9aB0Zxy56JlAS7x4ZUoED/vJdxA= +github.com/cloudwego/gopkg v0.1.3/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= github.com/cloudwego/hertz v0.9.3 h1:uajvLn6LjEPjUqN/ewUZtWoRQWa2es2XTELdqDlOYMw= github.com/cloudwego/hertz v0.9.3/go.mod h1:gGVUfJU/BOkJv/ZTzrw7FS7uy7171JeYIZvAyV3wS3o= 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.11.3 h1:Qy1GtyuNbygMpwnMw+Aj1iS7fSd0IO7CzxtpZrRJ+Jc= -github.com/cloudwego/kitex v0.11.3/go.mod h1:RHT9ERKFVppJjBfGvwJAPxCIzf4oN1yASW5S4pPZNu4= -github.com/cloudwego/localsession v0.0.2 h1:N9/IDtCPj1fCL9bCTP+DbXx3f40YjVYWcwkJG0YhQkY= -github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= -github.com/cloudwego/netpoll v0.6.4 h1:z/dA4sOTUQof6zZIO4QNnLBXsDFFFEos9OOGloR6kno= -github.com/cloudwego/netpoll v0.6.4/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= +github.com/cloudwego/kitex v0.12.0 h1:TeNlAAkWc3MOIGnBQj+FcSUBan+3TBpzitnrviH0AXM= +github.com/cloudwego/kitex v0.12.0/go.mod h1:k2wQJ+3LPjQJHbBs0xE2k6z8SVRcUpB3/eRO34oM0nQ= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 h1:jU6gpAkJ3HZLZeSpxrL1xaCd/auvAbLs0SN/ylXn9TA= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2/go.mod h1:OP63V8YwwSlPVFqHZblV3mJXLPIjcIdwkT6ZYjEggcI= +github.com/cloudwego/localsession v0.1.1 h1:tbK7laDVrYfFDXoBXo4uCGMAxU4qmz2dDm8d4BGBnDo= +github.com/cloudwego/localsession v0.1.1/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= +github.com/cloudwego/netpoll v0.6.5 h1:6E/BWhSzQoyLg9Kx/4xiMdIIpovzwBtXvuqSqaTUzDQ= +github.com/cloudwego/netpoll v0.6.5/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= 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.17 h1:k0iQe2jEAN1WhPsXWvatwHzoxObUSX2Nw5NqdnywS8k= -github.com/cloudwego/thriftgo v0.3.17/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= +github.com/cloudwego/thriftgo v0.3.18 h1:gnr1vz7G3RbwwCK9AMKHZf63VYGa7ene6WbI9VrBJSw= +github.com/cloudwego/thriftgo v0.3.18/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= @@ -90,8 +92,8 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -358,10 +360,9 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/basic/example_shop/kitex_gen/example/shop/base/base.go b/basic/example_shop/kitex_gen/example/shop/base/base.go index a63551fc..42eac85c 100644 --- a/basic/example_shop/kitex_gen/example/shop/base/base.go +++ b/basic/example_shop/kitex_gen/example/shop/base/base.go @@ -1,10 +1,10 @@ -// Code generated by thriftgo (0.3.2). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package base import ( "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" ) @@ -18,7 +18,6 @@ func NewBaseResp() *BaseResp { } func (p *BaseResp) InitDefault() { - *p = BaseResp{} } func (p *BaseResp) GetCode() (v string) { @@ -64,27 +63,22 @@ func (p *BaseResp) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -110,24 +104,30 @@ ReadStructEndError: } func (p *BaseResp) ReadField1(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Code = v + _field = v } + p.Code = _field return nil } - func (p *BaseResp) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *BaseResp) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("BaseResp"); err != nil { goto WriteStructBeginError @@ -141,7 +141,6 @@ func (p *BaseResp) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -199,6 +198,7 @@ func (p *BaseResp) String() string { return "" } return fmt.Sprintf("BaseResp(%+v)", *p) + } func (p *BaseResp) DeepEqual(ano *BaseResp) bool { diff --git a/basic/example_shop/kitex_gen/example/shop/base/k-base.go b/basic/example_shop/kitex_gen/example/shop/base/k-base.go index c525e710..e6f695cc 100644 --- a/basic/example_shop/kitex_gen/example/shop/base/k-base.go +++ b/basic/example_shop/kitex_gen/example/shop/base/k-base.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package base @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,24 +17,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -53,7 +45,7 @@ func (p *BaseResp) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -67,136 +59,106 @@ func (p *BaseResp) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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 { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Code = v - + _field = v } + p.Code = _field return offset, nil } func (p *BaseResp) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *BaseResp) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *BaseResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BaseResp) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BaseResp") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(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 += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *BaseResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BaseResp) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Code) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Code) return offset } -func (p *BaseResp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BaseResp) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *BaseResp) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Code) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Code) return l } func (p *BaseResp) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } diff --git a/basic/example_shop/kitex_gen/example/shop/item/item.go b/basic/example_shop/kitex_gen/example/shop/item/item.go index df1fae3f..169a93b6 100644 --- a/basic/example_shop/kitex_gen/example/shop/item/item.go +++ b/basic/example_shop/kitex_gen/example/shop/item/item.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.3.2). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package item @@ -6,7 +6,7 @@ import ( "context" "example_shop/kitex_gen/example/shop/base" "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" ) @@ -22,7 +22,6 @@ func NewItem() *Item { } func (p *Item) InitDefault() { - *p = Item{} } func (p *Item) GetId() (v int64) { @@ -84,47 +83,38 @@ func (p *Item) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -150,42 +140,52 @@ ReadStructEndError: } func (p *Item) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Id = v + _field = v } + p.Id = _field return nil } - func (p *Item) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Title = v + _field = v } + p.Title = _field return nil } - func (p *Item) ReadField3(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Description = v + _field = v } + p.Description = _field return nil } - func (p *Item) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Stock = v + _field = v } + p.Stock = _field return nil } func (p *Item) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Item"); err != nil { goto WriteStructBeginError @@ -207,7 +207,6 @@ func (p *Item) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -299,6 +298,7 @@ func (p *Item) String() string { return "" } return fmt.Sprintf("Item(%+v)", *p) + } func (p *Item) DeepEqual(ano *Item) bool { @@ -360,7 +360,6 @@ func NewGetItemReq() *GetItemReq { } func (p *GetItemReq) InitDefault() { - *p = GetItemReq{} } func (p *GetItemReq) GetId() (v int64) { @@ -400,17 +399,14 @@ func (p *GetItemReq) Read(iprot thrift.TProtocol) (err error) { goto ReadFieldError } issetId = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -442,15 +438,19 @@ RequiredFieldNotSetError: } func (p *GetItemReq) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Id = v + _field = v } + p.Id = _field return nil } func (p *GetItemReq) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("GetItemReq"); err != nil { goto WriteStructBeginError @@ -460,7 +460,6 @@ func (p *GetItemReq) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -501,6 +500,7 @@ func (p *GetItemReq) String() string { return "" } return fmt.Sprintf("GetItemReq(%+v)", *p) + } func (p *GetItemReq) DeepEqual(ano *GetItemReq) bool { @@ -533,7 +533,6 @@ func NewGetItemResp() *GetItemResp { } func (p *GetItemResp) InitDefault() { - *p = GetItemResp{} } var GetItemResp_Item_DEFAULT *Item @@ -597,27 +596,22 @@ func (p *GetItemResp) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -643,22 +637,24 @@ ReadStructEndError: } func (p *GetItemResp) ReadField1(iprot thrift.TProtocol) error { - p.Item = NewItem() - if err := p.Item.Read(iprot); err != nil { + _field := NewItem() + if err := _field.Read(iprot); err != nil { return err } + p.Item = _field return nil } - func (p *GetItemResp) ReadField255(iprot thrift.TProtocol) error { - p.BaseResp = base.NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { + _field := base.NewBaseResp() + if err := _field.Read(iprot); err != nil { return err } + p.BaseResp = _field return nil } func (p *GetItemResp) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("GetItemResp"); err != nil { goto WriteStructBeginError @@ -672,7 +668,6 @@ func (p *GetItemResp) Write(oprot thrift.TProtocol) (err error) { fieldId = 255 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -730,6 +725,7 @@ func (p *GetItemResp) String() string { return "" } return fmt.Sprintf("GetItemResp(%+v)", *p) + } func (p *GetItemResp) DeepEqual(ano *GetItemResp) bool { @@ -766,131 +762,6 @@ type ItemService interface { GetItem(ctx context.Context, req *GetItemReq) (r *GetItemResp, err error) } -type ItemServiceClient struct { - c thrift.TClient -} - -func NewItemServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ItemServiceClient { - return &ItemServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewItemServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ItemServiceClient { - return &ItemServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewItemServiceClient(c thrift.TClient) *ItemServiceClient { - return &ItemServiceClient{ - c: c, - } -} - -func (p *ItemServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *ItemServiceClient) GetItem(ctx context.Context, req *GetItemReq) (r *GetItemResp, err error) { - var _args ItemServiceGetItemArgs - _args.Req = req - var _result ItemServiceGetItemResult - if err = p.Client_().Call(ctx, "GetItem", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type ItemServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler ItemService -} - -func (p *ItemServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *ItemServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *ItemServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewItemServiceProcessor(handler ItemService) *ItemServiceProcessor { - self := &ItemServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("GetItem", &itemServiceProcessorGetItem{handler: handler}) - return self -} -func (p *ItemServiceProcessor) 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 itemServiceProcessorGetItem struct { - handler ItemService -} - -func (p *itemServiceProcessorGetItem) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ItemServiceGetItemArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("GetItem", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := ItemServiceGetItemResult{} - var retval *GetItemResp - if retval, err2 = p.handler.GetItem(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing GetItem: "+err2.Error()) - oprot.WriteMessageBegin("GetItem", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("GetItem", 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 ItemServiceGetItemArgs struct { Req *GetItemReq `thrift:"req,1" frugal:"1,default,GetItemReq" json:"req"` } @@ -900,7 +771,6 @@ func NewItemServiceGetItemArgs() *ItemServiceGetItemArgs { } func (p *ItemServiceGetItemArgs) InitDefault() { - *p = ItemServiceGetItemArgs{} } var ItemServiceGetItemArgs_Req_DEFAULT *GetItemReq @@ -947,17 +817,14 @@ func (p *ItemServiceGetItemArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -983,14 +850,16 @@ ReadStructEndError: } func (p *ItemServiceGetItemArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewGetItemReq() - if err := p.Req.Read(iprot); err != nil { + _field := NewGetItemReq() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *ItemServiceGetItemArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("GetItem_args"); err != nil { goto WriteStructBeginError @@ -1000,7 +869,6 @@ func (p *ItemServiceGetItemArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1041,6 +909,7 @@ func (p *ItemServiceGetItemArgs) String() string { return "" } return fmt.Sprintf("ItemServiceGetItemArgs(%+v)", *p) + } func (p *ItemServiceGetItemArgs) DeepEqual(ano *ItemServiceGetItemArgs) bool { @@ -1072,7 +941,6 @@ func NewItemServiceGetItemResult() *ItemServiceGetItemResult { } func (p *ItemServiceGetItemResult) InitDefault() { - *p = ItemServiceGetItemResult{} } var ItemServiceGetItemResult_Success_DEFAULT *GetItemResp @@ -1119,17 +987,14 @@ func (p *ItemServiceGetItemResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1155,14 +1020,16 @@ ReadStructEndError: } func (p *ItemServiceGetItemResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewGetItemResp() - if err := p.Success.Read(iprot); err != nil { + _field := NewGetItemResp() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *ItemServiceGetItemResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("GetItem_result"); err != nil { goto WriteStructBeginError @@ -1172,7 +1039,6 @@ func (p *ItemServiceGetItemResult) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1215,6 +1081,7 @@ func (p *ItemServiceGetItemResult) String() string { return "" } return fmt.Sprintf("ItemServiceGetItemResult(%+v)", *p) + } func (p *ItemServiceGetItemResult) DeepEqual(ano *ItemServiceGetItemResult) bool { diff --git a/basic/example_shop/kitex_gen/example/shop/item/itemservice/client.go b/basic/example_shop/kitex_gen/example/shop/item/itemservice/client.go index 95a9cb29..adefef91 100644 --- a/basic/example_shop/kitex_gen/example/shop/item/itemservice/client.go +++ b/basic/example_shop/kitex_gen/example/shop/item/itemservice/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package itemservice @@ -21,7 +21,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/basic/example_shop/kitex_gen/example/shop/item/itemservice/itemservice.go b/basic/example_shop/kitex_gen/example/shop/item/itemservice/itemservice.go index ea5d7bf6..e79e8992 100644 --- a/basic/example_shop/kitex_gen/example/shop/item/itemservice/itemservice.go +++ b/basic/example_shop/kitex_gen/example/shop/item/itemservice/itemservice.go @@ -1,36 +1,86 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package itemservice import ( "context" + "errors" item "example_shop/kitex_gen/example/shop/item" client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "GetItem": kitex.NewMethodInfo( + getItemHandler, + newItemServiceGetItemArgs, + newItemServiceGetItemResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + itemServiceServiceInfo = NewServiceInfo() + itemServiceServiceInfoForClient = NewServiceInfoForClient() + itemServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return itemServiceServiceInfo } -var itemServiceServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return itemServiceServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return itemServiceServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "ItemService" handlerType := (*item.ItemService)(nil) - methods := map[string]kitex.MethodInfo{ - "GetItem": kitex.NewMethodInfo(getItemHandler, newItemServiceGetItemArgs, newItemServiceGetItemResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ - "PackageName": "item", - "ServiceFilePath": `idl/item.thrift`, + "PackageName": "item", + } + if hasStreaming { + extra["streaming"] = hasStreaming } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/basic/example_shop/kitex_gen/example/shop/item/itemservice/server.go b/basic/example_shop/kitex_gen/example/shop/item/itemservice/server.go index 9d6a4a8b..3516a553 100644 --- a/basic/example_shop/kitex_gen/example/shop/item/itemservice/server.go +++ b/basic/example_shop/kitex_gen/example/shop/item/itemservice/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package itemservice import ( @@ -11,6 +11,7 @@ func NewServer(handler item.ItemService, opts ...server.Option) server.Server { var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler item.ItemService, opts ...server.Option) server.Server { } return svr } + +func RegisterService(svr server.Server, handler item.ItemService, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/basic/example_shop/kitex_gen/example/shop/item/k-item.go b/basic/example_shop/kitex_gen/example/shop/item/k-item.go index 0c83fbf8..882659e4 100644 --- a/basic/example_shop/kitex_gen/example/shop/item/k-item.go +++ b/basic/example_shop/kitex_gen/example/shop/item/k-item.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package item @@ -8,38 +8,33 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" "example_shop/kitex_gen/example/shop/base" ) +var ( + _ = base.KitexUnusedProtection +) + // unused protection var ( _ = fmt.Formatter(nil) _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) - _ = base.KitexUnusedProtection + _ = thrift.STOP ) func (p *Item) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -56,7 +51,7 @@ func (p *Item) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -70,7 +65,7 @@ func (p *Item) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -84,7 +79,7 @@ func (p *Item) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -98,223 +93,180 @@ func (p *Item) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Item[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 *Item) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Id = v - + _field = v } + p.Id = _field return offset, nil } func (p *Item) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Title = v - + _field = v } + p.Title = _field return offset, nil } func (p *Item) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Description = v - + _field = v } + p.Description = _field return offset, nil } func (p *Item) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Stock = v - + _field = v } + p.Stock = _field return offset, nil } -// for compatibility func (p *Item) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Item) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Item) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Item") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Item) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Item") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Item) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Item) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Id) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.Id) return offset } -func (p *Item) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Item) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "title", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Title) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Title) return offset } -func (p *Item) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Item) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Item) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Item) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "stock", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Stock) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Stock) return offset } func (p *Item) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.Id) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *Item) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("title", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Title) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Title) return l } func (p *Item) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Description) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Item) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("stock", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Stock) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *GetItemReq) FastRead(buf []byte) (int, error) { + var err error var offset int var l int var fieldTypeId thrift.TType var fieldId int16 var issetId 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -332,30 +284,19 @@ func (p *GetItemReq) FastRead(buf []byte) (int, error) { } issetId = true } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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 !issetId { @@ -363,95 +304,75 @@ func (p *GetItemReq) FastRead(buf []byte) (int, error) { 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_GetItemReq[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_GetItemReq[fieldId])) + return offset, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_GetItemReq[fieldId])) } func (p *GetItemReq) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Id = v - + _field = v } + p.Id = _field return offset, nil } -// for compatibility func (p *GetItemReq) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *GetItemReq) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *GetItemReq) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetItemReq") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *GetItemReq) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("GetItemReq") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *GetItemReq) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *GetItemReq) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Id) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.Id) return offset } func (p *GetItemReq) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.Id) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *GetItemResp) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -468,7 +389,7 @@ func (p *GetItemResp) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -482,148 +403,115 @@ func (p *GetItemResp) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_GetItemResp[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 *GetItemResp) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewItem() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewItem() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Item = tmp + p.Item = _field return offset, nil } func (p *GetItemResp) FastReadField255(buf []byte) (int, error) { offset := 0 - - tmp := base.NewBaseResp() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := base.NewBaseResp() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.BaseResp = tmp + p.BaseResp = _field return offset, nil } -// for compatibility func (p *GetItemResp) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *GetItemResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *GetItemResp) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetItemResp") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField255(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *GetItemResp) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("GetItemResp") if p != nil { l += p.field1Length() l += p.field255Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *GetItemResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *GetItemResp) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "item", thrift.STRUCT, 1) - offset += p.Item.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Item.FastWriteNocopy(buf[offset:], w) return offset } -func (p *GetItemResp) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *GetItemResp) fastWriteField255(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 255) + offset += p.BaseResp.FastWriteNocopy(buf[offset:], w) return offset } func (p *GetItemResp) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("item", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Item.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *GetItemResp) field255Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("baseResp", thrift.STRUCT, 255) + l += thrift.Binary.FieldBeginLength() l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ItemServiceGetItemArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -640,117 +528,87 @@ func (p *ItemServiceGetItemArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ItemServiceGetItemArgs[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 *ItemServiceGetItemArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewGetItemReq() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewGetItemReq() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *ItemServiceGetItemArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ItemServiceGetItemArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ItemServiceGetItemArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetItem_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ItemServiceGetItemArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("GetItem_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ItemServiceGetItemArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ItemServiceGetItemArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *ItemServiceGetItemArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ItemServiceGetItemResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -767,93 +625,69 @@ func (p *ItemServiceGetItemResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ItemServiceGetItemResult[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 *ItemServiceGetItemResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewGetItemResp() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewGetItemResp() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *ItemServiceGetItemResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ItemServiceGetItemResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ItemServiceGetItemResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetItem_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ItemServiceGetItemResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("GetItem_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ItemServiceGetItemResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ItemServiceGetItemResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -861,9 +695,8 @@ func (p *ItemServiceGetItemResult) fastWriteField0(buf []byte, binaryWriter bthr func (p *ItemServiceGetItemResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/basic/example_shop/kitex_gen/example/shop/stock/k-stock.go b/basic/example_shop/kitex_gen/example/shop/stock/k-stock.go index c58dbeac..c2723c3b 100644 --- a/basic/example_shop/kitex_gen/example/shop/stock/k-stock.go +++ b/basic/example_shop/kitex_gen/example/shop/stock/k-stock.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package stock @@ -8,39 +8,34 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" "example_shop/kitex_gen/example/shop/base" ) +var ( + _ = base.KitexUnusedProtection +) + // unused protection var ( _ = fmt.Formatter(nil) _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) - _ = base.KitexUnusedProtection + _ = thrift.STOP ) func (p *GetItemStockReq) FastRead(buf []byte) (int, error) { + var err error var offset int var l int var fieldTypeId thrift.TType var fieldId int16 var issetItemId 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -58,30 +53,19 @@ func (p *GetItemStockReq) FastRead(buf []byte) (int, error) { } issetItemId = true } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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 !issetItemId { @@ -89,95 +73,75 @@ func (p *GetItemStockReq) FastRead(buf []byte) (int, error) { 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_GetItemStockReq[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_GetItemStockReq[fieldId])) + return offset, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_GetItemStockReq[fieldId])) } func (p *GetItemStockReq) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.ItemId = v - + _field = v } + p.ItemId = _field return offset, nil } -// for compatibility func (p *GetItemStockReq) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *GetItemStockReq) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *GetItemStockReq) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetItemStockReq") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *GetItemStockReq) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("GetItemStockReq") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *GetItemStockReq) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *GetItemStockReq) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "item_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.ItemId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.ItemId) return offset } func (p *GetItemStockReq) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("item_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.ItemId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *GetItemStockResp) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -194,7 +158,7 @@ func (p *GetItemStockResp) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -208,151 +172,117 @@ func (p *GetItemStockResp) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_GetItemStockResp[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 *GetItemStockResp) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Stock = v - + _field = v } + p.Stock = _field return offset, nil } func (p *GetItemStockResp) FastReadField255(buf []byte) (int, error) { offset := 0 - - tmp := base.NewBaseResp() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := base.NewBaseResp() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.BaseResp = tmp + p.BaseResp = _field return offset, nil } -// for compatibility func (p *GetItemStockResp) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *GetItemStockResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *GetItemStockResp) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetItemStockResp") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField255(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *GetItemStockResp) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("GetItemStockResp") if p != nil { l += p.field1Length() l += p.field255Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *GetItemStockResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *GetItemStockResp) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "stock", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Stock) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.Stock) return offset } -func (p *GetItemStockResp) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *GetItemStockResp) fastWriteField255(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 255) + offset += p.BaseResp.FastWriteNocopy(buf[offset:], w) return offset } func (p *GetItemStockResp) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("stock", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.Stock) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *GetItemStockResp) field255Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("BaseResp", thrift.STRUCT, 255) + l += thrift.Binary.FieldBeginLength() l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *StockServiceGetItemStockArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -369,117 +299,87 @@ func (p *StockServiceGetItemStockArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_StockServiceGetItemStockArgs[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 *StockServiceGetItemStockArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewGetItemStockReq() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewGetItemStockReq() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *StockServiceGetItemStockArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *StockServiceGetItemStockArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *StockServiceGetItemStockArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetItemStock_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *StockServiceGetItemStockArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("GetItemStock_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *StockServiceGetItemStockArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *StockServiceGetItemStockArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *StockServiceGetItemStockArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *StockServiceGetItemStockResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -496,93 +396,69 @@ func (p *StockServiceGetItemStockResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_StockServiceGetItemStockResult[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 *StockServiceGetItemStockResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewGetItemStockResp() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewGetItemStockResp() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *StockServiceGetItemStockResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *StockServiceGetItemStockResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *StockServiceGetItemStockResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetItemStock_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *StockServiceGetItemStockResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("GetItemStock_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *StockServiceGetItemStockResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *StockServiceGetItemStockResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -590,9 +466,8 @@ func (p *StockServiceGetItemStockResult) fastWriteField0(buf []byte, binaryWrite func (p *StockServiceGetItemStockResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/basic/example_shop/kitex_gen/example/shop/stock/stock.go b/basic/example_shop/kitex_gen/example/shop/stock/stock.go index 401d9a8f..a82186f5 100644 --- a/basic/example_shop/kitex_gen/example/shop/stock/stock.go +++ b/basic/example_shop/kitex_gen/example/shop/stock/stock.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.3.2). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package stock @@ -6,7 +6,7 @@ import ( "context" "example_shop/kitex_gen/example/shop/base" "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" ) type GetItemStockReq struct { @@ -18,7 +18,6 @@ func NewGetItemStockReq() *GetItemStockReq { } func (p *GetItemStockReq) InitDefault() { - *p = GetItemStockReq{} } func (p *GetItemStockReq) GetItemId() (v int64) { @@ -58,17 +57,14 @@ func (p *GetItemStockReq) Read(iprot thrift.TProtocol) (err error) { goto ReadFieldError } issetItemId = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -100,15 +96,19 @@ RequiredFieldNotSetError: } func (p *GetItemStockReq) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.ItemId = v + _field = v } + p.ItemId = _field return nil } func (p *GetItemStockReq) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("GetItemStockReq"); err != nil { goto WriteStructBeginError @@ -118,7 +118,6 @@ func (p *GetItemStockReq) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -159,6 +158,7 @@ func (p *GetItemStockReq) String() string { return "" } return fmt.Sprintf("GetItemStockReq(%+v)", *p) + } func (p *GetItemStockReq) DeepEqual(ano *GetItemStockReq) bool { @@ -191,7 +191,6 @@ func NewGetItemStockResp() *GetItemStockResp { } func (p *GetItemStockResp) InitDefault() { - *p = GetItemStockResp{} } func (p *GetItemStockResp) GetStock() (v int64) { @@ -246,27 +245,22 @@ func (p *GetItemStockResp) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -292,23 +286,27 @@ ReadStructEndError: } func (p *GetItemStockResp) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Stock = v + _field = v } + p.Stock = _field return nil } - func (p *GetItemStockResp) ReadField255(iprot thrift.TProtocol) error { - p.BaseResp = base.NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { + _field := base.NewBaseResp() + if err := _field.Read(iprot); err != nil { return err } + p.BaseResp = _field return nil } func (p *GetItemStockResp) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("GetItemStockResp"); err != nil { goto WriteStructBeginError @@ -322,7 +320,6 @@ func (p *GetItemStockResp) Write(oprot thrift.TProtocol) (err error) { fieldId = 255 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -380,6 +377,7 @@ func (p *GetItemStockResp) String() string { return "" } return fmt.Sprintf("GetItemStockResp(%+v)", *p) + } func (p *GetItemStockResp) DeepEqual(ano *GetItemStockResp) bool { @@ -416,131 +414,6 @@ type StockService interface { GetItemStock(ctx context.Context, req *GetItemStockReq) (r *GetItemStockResp, err error) } -type StockServiceClient struct { - c thrift.TClient -} - -func NewStockServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StockServiceClient { - return &StockServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewStockServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StockServiceClient { - return &StockServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewStockServiceClient(c thrift.TClient) *StockServiceClient { - return &StockServiceClient{ - c: c, - } -} - -func (p *StockServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *StockServiceClient) GetItemStock(ctx context.Context, req *GetItemStockReq) (r *GetItemStockResp, err error) { - var _args StockServiceGetItemStockArgs - _args.Req = req - var _result StockServiceGetItemStockResult - if err = p.Client_().Call(ctx, "GetItemStock", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type StockServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler StockService -} - -func (p *StockServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *StockServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *StockServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewStockServiceProcessor(handler StockService) *StockServiceProcessor { - self := &StockServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("GetItemStock", &stockServiceProcessorGetItemStock{handler: handler}) - return self -} -func (p *StockServiceProcessor) 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 stockServiceProcessorGetItemStock struct { - handler StockService -} - -func (p *stockServiceProcessorGetItemStock) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := StockServiceGetItemStockArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("GetItemStock", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := StockServiceGetItemStockResult{} - var retval *GetItemStockResp - if retval, err2 = p.handler.GetItemStock(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing GetItemStock: "+err2.Error()) - oprot.WriteMessageBegin("GetItemStock", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("GetItemStock", 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 StockServiceGetItemStockArgs struct { Req *GetItemStockReq `thrift:"req,1" frugal:"1,default,GetItemStockReq" json:"req"` } @@ -550,7 +423,6 @@ func NewStockServiceGetItemStockArgs() *StockServiceGetItemStockArgs { } func (p *StockServiceGetItemStockArgs) InitDefault() { - *p = StockServiceGetItemStockArgs{} } var StockServiceGetItemStockArgs_Req_DEFAULT *GetItemStockReq @@ -597,17 +469,14 @@ func (p *StockServiceGetItemStockArgs) Read(iprot thrift.TProtocol) (err error) if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -633,14 +502,16 @@ ReadStructEndError: } func (p *StockServiceGetItemStockArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewGetItemStockReq() - if err := p.Req.Read(iprot); err != nil { + _field := NewGetItemStockReq() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *StockServiceGetItemStockArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("GetItemStock_args"); err != nil { goto WriteStructBeginError @@ -650,7 +521,6 @@ func (p *StockServiceGetItemStockArgs) Write(oprot thrift.TProtocol) (err error) fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -691,6 +561,7 @@ func (p *StockServiceGetItemStockArgs) String() string { return "" } return fmt.Sprintf("StockServiceGetItemStockArgs(%+v)", *p) + } func (p *StockServiceGetItemStockArgs) DeepEqual(ano *StockServiceGetItemStockArgs) bool { @@ -722,7 +593,6 @@ func NewStockServiceGetItemStockResult() *StockServiceGetItemStockResult { } func (p *StockServiceGetItemStockResult) InitDefault() { - *p = StockServiceGetItemStockResult{} } var StockServiceGetItemStockResult_Success_DEFAULT *GetItemStockResp @@ -769,17 +639,14 @@ func (p *StockServiceGetItemStockResult) Read(iprot thrift.TProtocol) (err error if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -805,14 +672,16 @@ ReadStructEndError: } func (p *StockServiceGetItemStockResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewGetItemStockResp() - if err := p.Success.Read(iprot); err != nil { + _field := NewGetItemStockResp() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *StockServiceGetItemStockResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("GetItemStock_result"); err != nil { goto WriteStructBeginError @@ -822,7 +691,6 @@ func (p *StockServiceGetItemStockResult) Write(oprot thrift.TProtocol) (err erro fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -865,6 +733,7 @@ func (p *StockServiceGetItemStockResult) String() string { return "" } return fmt.Sprintf("StockServiceGetItemStockResult(%+v)", *p) + } func (p *StockServiceGetItemStockResult) DeepEqual(ano *StockServiceGetItemStockResult) bool { diff --git a/basic/example_shop/kitex_gen/example/shop/stock/stockservice/client.go b/basic/example_shop/kitex_gen/example/shop/stock/stockservice/client.go index 383d1475..fff83fda 100644 --- a/basic/example_shop/kitex_gen/example/shop/stock/stockservice/client.go +++ b/basic/example_shop/kitex_gen/example/shop/stock/stockservice/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package stockservice @@ -21,7 +21,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/basic/example_shop/kitex_gen/example/shop/stock/stockservice/server.go b/basic/example_shop/kitex_gen/example/shop/stock/stockservice/server.go index 118916b0..2337a844 100644 --- a/basic/example_shop/kitex_gen/example/shop/stock/stockservice/server.go +++ b/basic/example_shop/kitex_gen/example/shop/stock/stockservice/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package stockservice import ( @@ -11,6 +11,7 @@ func NewServer(handler stock.StockService, opts ...server.Option) server.Server var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler stock.StockService, opts ...server.Option) server.Server } return svr } + +func RegisterService(svr server.Server, handler stock.StockService, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/basic/example_shop/kitex_gen/example/shop/stock/stockservice/stockservice.go b/basic/example_shop/kitex_gen/example/shop/stock/stockservice/stockservice.go index fb4bedc9..e10c3e1c 100644 --- a/basic/example_shop/kitex_gen/example/shop/stock/stockservice/stockservice.go +++ b/basic/example_shop/kitex_gen/example/shop/stock/stockservice/stockservice.go @@ -1,36 +1,86 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package stockservice import ( "context" + "errors" stock "example_shop/kitex_gen/example/shop/stock" client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "GetItemStock": kitex.NewMethodInfo( + getItemStockHandler, + newStockServiceGetItemStockArgs, + newStockServiceGetItemStockResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + stockServiceServiceInfo = NewServiceInfo() + stockServiceServiceInfoForClient = NewServiceInfoForClient() + stockServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return stockServiceServiceInfo } -var stockServiceServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return stockServiceServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return stockServiceServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "StockService" handlerType := (*stock.StockService)(nil) - methods := map[string]kitex.MethodInfo{ - "GetItemStock": kitex.NewMethodInfo(getItemStockHandler, newStockServiceGetItemStockArgs, newStockServiceGetItemStockResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ - "PackageName": "stock", - "ServiceFilePath": `idl/stock.thrift`, + "PackageName": "stock", + } + if hasStreaming { + extra["streaming"] = hasStreaming } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/bizdemo/easy_note/go.mod b/bizdemo/easy_note/go.mod index 5b95c754..1c044d30 100644 --- a/bizdemo/easy_note/go.mod +++ b/bizdemo/easy_note/go.mod @@ -5,16 +5,17 @@ go 1.21 toolchain go1.21.4 require ( - github.com/apache/thrift v0.16.0 + github.com/cloudwego/gopkg v0.1.3 github.com/cloudwego/hertz v0.9.3 - github.com/cloudwego/kitex v0.11.3 + github.com/cloudwego/kitex v0.12.0 + github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 github.com/hertz-contrib/jwt v1.0.2 github.com/kitex-contrib/registry-etcd v0.2.5 github.com/kitex-contrib/tracer-opentracing v0.0.3 github.com/opentracing/opentracing-go v1.2.0 github.com/shirou/gopsutil v3.21.11+incompatible github.com/uber/jaeger-client-go v2.30.0+incompatible - google.golang.org/protobuf v1.31.0 + google.golang.org/protobuf v1.33.0 gorm.io/driver/mysql v1.4.7 gorm.io/gorm v1.25.5 gorm.io/plugin/opentracing v0.0.0-20211220013347-7d2b2af23560 @@ -22,21 +23,21 @@ require ( require ( github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect + github.com/apache/thrift v0.16.0 // indirect github.com/bytedance/go-tagexpr/v2 v2.9.2 // indirect github.com/bytedance/gopkg v0.1.1 // indirect - github.com/bytedance/sonic v1.12.2 // indirect + github.com/bytedance/sonic v1.12.5 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/configmanager v0.2.2 // indirect - github.com/cloudwego/dynamicgo v0.4.0 // indirect + github.com/cloudwego/dynamicgo v0.4.6 // indirect github.com/cloudwego/fastpb v0.0.5 // indirect - github.com/cloudwego/frugal v0.2.0 // indirect - github.com/cloudwego/gopkg v0.1.2 // indirect + github.com/cloudwego/frugal v0.2.3 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cloudwego/localsession v0.0.2 // indirect - github.com/cloudwego/netpoll v0.6.4 // indirect + github.com/cloudwego/localsession v0.1.1 // indirect + github.com/cloudwego/netpoll v0.6.5 // indirect github.com/cloudwego/runtimex v0.1.0 // indirect - github.com/cloudwego/thriftgo v0.3.17 // indirect + github.com/cloudwego/thriftgo v0.3.18 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -46,7 +47,7 @@ require ( github.com/go-sql-driver/mysql v1.7.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect github.com/henrylee2cn/ameda v1.4.10 // indirect github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 // indirect diff --git a/bizdemo/easy_note/go.sum b/bizdemo/easy_note/go.sum index 0c7ef588..a27657ef 100644 --- a/bizdemo/easy_note/go.sum +++ b/bizdemo/easy_note/go.sum @@ -22,8 +22,8 @@ github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP github.com/bytedance/mockey v1.2.12 h1:aeszOmGw8CPX8CRx1DZ/Glzb1yXvhjDh6jdFBNZjsU4= github.com/bytedance/mockey v1.2.12/go.mod h1:3ZA4MQasmqC87Tw0w7Ygdy7eHIc2xgpZ8Pona5rsYIk= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic v1.12.2 h1:oaMFuRTpMHYLpCntGca65YWt5ny+wAceDERTkT2L9lg= -github.com/bytedance/sonic v1.12.2/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= +github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= @@ -39,33 +39,35 @@ 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/configmanager v0.2.2 h1:sVrJB8gWYTlPV2OS3wcgJSO9F2/9Zbkmcm1Z7jempOU= github.com/cloudwego/configmanager v0.2.2/go.mod h1:ppiyU+5TPLonE8qMVi/pFQk2eL3Q4P7d4hbiNJn6jwI= -github.com/cloudwego/dynamicgo v0.4.0 h1:wQqNRNiSQaLkbcn3sfpEJGZsz3xf8Il4P/3DcENsrFI= -github.com/cloudwego/dynamicgo v0.4.0/go.mod h1:zgWk2oz56EyH790LJSxrTz1j01GJBO964jJQ/y7qjJc= +github.com/cloudwego/dynamicgo v0.4.6 h1:raRdvLN1WsGl5WsNd2Ul86s8PFQPu8soF4ALSJ9MdC4= +github.com/cloudwego/dynamicgo v0.4.6/go.mod h1:DknfxjIMuGvXow409bS/AWycXONdc02HECBL0qpNqTY= github.com/cloudwego/fastpb v0.0.5 h1:vYnBPsfbAtU5TVz5+f9UTlmSCixG9F9vRwaqE0mZPZU= github.com/cloudwego/fastpb v0.0.5/go.mod h1:Bho7aAKBUtT9RPD2cNVkTdx4yQumfSv3If7wYnm1izk= -github.com/cloudwego/frugal v0.2.0 h1:0ETSzQYoYqVvdl7EKjqJ9aJnDoG6TzvNKV3PMQiQTS8= -github.com/cloudwego/frugal v0.2.0/go.mod h1:cpnV6kdRMjN3ylxRo63RNbZ9rBK6oxs70Zk6QZ4Enj4= -github.com/cloudwego/gopkg v0.1.2 h1:650t+RiZGht8qX+y0hl49JXJCuO44GhbGZuxDzr2PyI= -github.com/cloudwego/gopkg v0.1.2/go.mod h1:WoNTdXDPdvL97cBmRUWXVGkh2l2UFmpd9BUvbW2r0Aw= +github.com/cloudwego/frugal v0.2.3 h1:t1hhhAi8lXcx7Ncs4PR1pSZ90vlDU1cy5K2btDMFpoA= +github.com/cloudwego/frugal v0.2.3/go.mod h1:nC1U47gswLRiaxv6dybrhZvsDGCfQP9RGiiWC73CnoI= +github.com/cloudwego/gopkg v0.1.3 h1:y9VA5Zn5yqd1+QBV9aB0Zxy56JlAS7x4ZUoED/vJdxA= +github.com/cloudwego/gopkg v0.1.3/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= github.com/cloudwego/hertz v0.9.3 h1:uajvLn6LjEPjUqN/ewUZtWoRQWa2es2XTELdqDlOYMw= github.com/cloudwego/hertz v0.9.3/go.mod h1:gGVUfJU/BOkJv/ZTzrw7FS7uy7171JeYIZvAyV3wS3o= 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.0.4/go.mod h1:EIjPJ4Dom2ornk7xDCdKpUpOnf4Tulevimh4Tn05OGc= -github.com/cloudwego/kitex v0.11.3 h1:Qy1GtyuNbygMpwnMw+Aj1iS7fSd0IO7CzxtpZrRJ+Jc= -github.com/cloudwego/kitex v0.11.3/go.mod h1:RHT9ERKFVppJjBfGvwJAPxCIzf4oN1yASW5S4pPZNu4= -github.com/cloudwego/localsession v0.0.2 h1:N9/IDtCPj1fCL9bCTP+DbXx3f40YjVYWcwkJG0YhQkY= -github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= +github.com/cloudwego/kitex v0.12.0 h1:TeNlAAkWc3MOIGnBQj+FcSUBan+3TBpzitnrviH0AXM= +github.com/cloudwego/kitex v0.12.0/go.mod h1:k2wQJ+3LPjQJHbBs0xE2k6z8SVRcUpB3/eRO34oM0nQ= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 h1:jU6gpAkJ3HZLZeSpxrL1xaCd/auvAbLs0SN/ylXn9TA= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2/go.mod h1:OP63V8YwwSlPVFqHZblV3mJXLPIjcIdwkT6ZYjEggcI= +github.com/cloudwego/localsession v0.1.1 h1:tbK7laDVrYfFDXoBXo4uCGMAxU4qmz2dDm8d4BGBnDo= +github.com/cloudwego/localsession v0.1.1/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= github.com/cloudwego/netpoll v0.0.2/go.mod h1:rZOiNI0FYjuvNybXKKhAPUja03loJi/cdv2F55AE6E8= github.com/cloudwego/netpoll v0.0.3/go.mod h1:rZOiNI0FYjuvNybXKKhAPUja03loJi/cdv2F55AE6E8= -github.com/cloudwego/netpoll v0.6.4 h1:z/dA4sOTUQof6zZIO4QNnLBXsDFFFEos9OOGloR6kno= -github.com/cloudwego/netpoll v0.6.4/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= +github.com/cloudwego/netpoll v0.6.5 h1:6E/BWhSzQoyLg9Kx/4xiMdIIpovzwBtXvuqSqaTUzDQ= +github.com/cloudwego/netpoll v0.6.5/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= github.com/cloudwego/netpoll-http2 v0.0.4/go.mod h1:iFr5SzJCXIYgBg0ubL0fZiCQ6W36s9p0KjXpV04lmoY= 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.1.2/go.mod h1:LzeafuLSiHA9JTiWC8TIMIq64iadeObgRUhmVG1OC/w= -github.com/cloudwego/thriftgo v0.3.17 h1:k0iQe2jEAN1WhPsXWvatwHzoxObUSX2Nw5NqdnywS8k= -github.com/cloudwego/thriftgo v0.3.17/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= +github.com/cloudwego/thriftgo v0.3.18 h1:gnr1vz7G3RbwwCK9AMKHZf63VYGa7ene6WbI9VrBJSw= +github.com/cloudwego/thriftgo v0.3.18/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -118,8 +120,8 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -465,8 +467,8 @@ google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX7 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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= diff --git a/bizdemo/easy_note/kitex_gen/notedemo/k-note.go b/bizdemo/easy_note/kitex_gen/notedemo/k-note.go index 73cd1b60..868530eb 100644 --- a/bizdemo/easy_note/kitex_gen/notedemo/k-note.go +++ b/bizdemo/easy_note/kitex_gen/notedemo/k-note.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package notedemo @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,24 +17,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -53,7 +45,7 @@ func (p *BaseResp) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -67,7 +59,7 @@ func (p *BaseResp) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -81,188 +73,149 @@ func (p *BaseResp) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.StatusCode = v - + _field = v } + p.StatusCode = _field return offset, nil } func (p *BaseResp) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.StatusMessage = v - + _field = v } + p.StatusMessage = _field return offset, nil } func (p *BaseResp) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.ServiceTime = v - + _field = v } + p.ServiceTime = _field return offset, nil } -// for compatibility func (p *BaseResp) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *BaseResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BaseResp) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BaseResp") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(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() + l += thrift.Binary.FieldStopLength() return l } -func (p *BaseResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BaseResp) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "status_code", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.StatusCode) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.StatusCode) return offset } -func (p *BaseResp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BaseResp) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "status_message", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.StatusMessage) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.StatusMessage) return offset } -func (p *BaseResp) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BaseResp) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "service_time", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.ServiceTime) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.ServiceTime) return offset } func (p *BaseResp) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("status_code", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.StatusCode) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *BaseResp) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("status_message", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.StatusMessage) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.StatusMessage) return l } func (p *BaseResp) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("service_time", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.ServiceTime) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *Note) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -279,7 +232,7 @@ func (p *Note) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -293,7 +246,7 @@ func (p *Note) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -307,7 +260,7 @@ func (p *Note) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -321,7 +274,7 @@ func (p *Note) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -335,7 +288,7 @@ func (p *Note) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -349,7 +302,7 @@ func (p *Note) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -363,170 +316,149 @@ func (p *Note) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Note[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 *Note) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.NoteId = v - + _field = v } + p.NoteId = _field return offset, nil } func (p *Note) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *Note) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserName = v - + _field = v } + p.UserName = _field return offset, nil } func (p *Note) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserAvatar = v - + _field = v } + p.UserAvatar = _field return offset, nil } func (p *Note) FastReadField5(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Title = v - + _field = v } + p.Title = _field return offset, nil } func (p *Note) FastReadField6(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Content = v - + _field = v } + p.Content = _field return offset, nil } func (p *Note) FastReadField7(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.CreateTime = v - + _field = v } + p.CreateTime = _field return offset, nil } -// for compatibility func (p *Note) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Note) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Note) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Note") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField7(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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Note) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Note") if p != nil { l += p.field1Length() l += p.field2Length() @@ -536,151 +468,117 @@ func (p *Note) BLength() int { l += p.field6Length() l += p.field7Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Note) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Note) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "note_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.NoteId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.NoteId) return offset } -func (p *Note) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Note) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 2) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *Note) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Note) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_name", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.UserName) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.UserName) return offset } -func (p *Note) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Note) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_avatar", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.UserAvatar) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 4) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.UserAvatar) return offset } -func (p *Note) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Note) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "title", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Title) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Title) return offset } -func (p *Note) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Note) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "content", thrift.STRING, 6) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Content) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 6) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Content) return offset } -func (p *Note) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Note) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "create_time", thrift.I64, 7) - offset += bthrift.Binary.WriteI64(buf[offset:], p.CreateTime) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 7) + offset += thrift.Binary.WriteI64(buf[offset:], p.CreateTime) return offset } func (p *Note) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("note_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.NoteId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *Note) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *Note) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_name", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.UserName) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.UserName) return l } func (p *Note) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_avatar", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.UserAvatar) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.UserAvatar) return l } func (p *Note) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("title", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Title) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Title) return l } func (p *Note) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("content", thrift.STRING, 6) - l += bthrift.Binary.StringLengthNocopy(p.Content) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Content) return l } func (p *Note) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("create_time", thrift.I64, 7) - l += bthrift.Binary.I64Length(p.CreateTime) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *CreateNoteRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -697,7 +595,7 @@ func (p *CreateNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -711,7 +609,7 @@ func (p *CreateNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -725,188 +623,149 @@ func (p *CreateNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateNoteRequest[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 *CreateNoteRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Title = v - + _field = v } + p.Title = _field return offset, nil } func (p *CreateNoteRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Content = v - + _field = v } + p.Content = _field return offset, nil } func (p *CreateNoteRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } -// for compatibility func (p *CreateNoteRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateNoteRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateNoteRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateNoteRequest") if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateNoteRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateNoteRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateNoteRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateNoteRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "title", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Title) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Title) return offset } -func (p *CreateNoteRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateNoteRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "content", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Content) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Content) return offset } -func (p *CreateNoteRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateNoteRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } func (p *CreateNoteRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("title", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Title) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Title) return l } func (p *CreateNoteRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("content", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Content) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Content) return l } func (p *CreateNoteRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *CreateNoteResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -923,115 +782,87 @@ func (p *CreateNoteResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateNoteResponse[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 *CreateNoteResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - p.BaseResp = NewBaseResp() - if l, err := p.BaseResp.FastRead(buf[offset:]); err != nil { + _field := NewBaseResp() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.BaseResp = _field return offset, nil } -// for compatibility func (p *CreateNoteResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateNoteResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateNoteResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateNoteResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateNoteResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateNoteResponse") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateNoteResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateNoteResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "base_resp", thrift.STRUCT, 1) - offset += p.BaseResp.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.BaseResp.FastWriteNocopy(buf[offset:], w) return offset } func (p *CreateNoteResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("base_resp", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *DeleteNoteRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1048,7 +879,7 @@ func (p *DeleteNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1062,154 +893,119 @@ func (p *DeleteNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteNoteRequest[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 *DeleteNoteRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.NoteId = v - + _field = v } + p.NoteId = _field return offset, nil } func (p *DeleteNoteRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } -// for compatibility func (p *DeleteNoteRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteNoteRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteNoteRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteNoteRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteNoteRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteNoteRequest") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteNoteRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteNoteRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "note_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.NoteId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.NoteId) return offset } -func (p *DeleteNoteRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteNoteRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 2) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } func (p *DeleteNoteRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("note_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.NoteId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteNoteRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteNoteResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1226,115 +1022,87 @@ func (p *DeleteNoteResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteNoteResponse[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 *DeleteNoteResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - p.BaseResp = NewBaseResp() - if l, err := p.BaseResp.FastRead(buf[offset:]); err != nil { + _field := NewBaseResp() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.BaseResp = _field return offset, nil } -// for compatibility func (p *DeleteNoteResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteNoteResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteNoteResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteNoteResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteNoteResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteNoteResponse") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteNoteResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteNoteResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "base_resp", thrift.STRUCT, 1) - offset += p.BaseResp.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.BaseResp.FastWriteNocopy(buf[offset:], w) return offset } func (p *DeleteNoteResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("base_resp", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UpdateNoteRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1351,7 +1119,7 @@ func (p *UpdateNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1365,7 +1133,7 @@ func (p *UpdateNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1379,7 +1147,7 @@ func (p *UpdateNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1393,199 +1161,165 @@ func (p *UpdateNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateNoteRequest[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 *UpdateNoteRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.NoteId = v - + _field = v } + p.NoteId = _field return offset, nil } func (p *UpdateNoteRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *UpdateNoteRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field *string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Title = &v - + _field = &v } + p.Title = _field return offset, nil } func (p *UpdateNoteRequest) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field *string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Content = &v - + _field = &v } + p.Content = _field return offset, nil } -// for compatibility func (p *UpdateNoteRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateNoteRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateNoteRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateNoteRequest") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateNoteRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateNoteRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateNoteRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateNoteRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "note_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.NoteId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.NoteId) return offset } -func (p *UpdateNoteRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateNoteRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 2) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *UpdateNoteRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateNoteRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 if p.IsSetTitle() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "title", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Title) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, *p.Title) } return offset } -func (p *UpdateNoteRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateNoteRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 if p.IsSetContent() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "content", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Content) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 4) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, *p.Content) } return offset } func (p *UpdateNoteRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("note_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.NoteId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateNoteRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateNoteRequest) field3Length() int { l := 0 if p.IsSetTitle() { - l += bthrift.Binary.FieldBeginLength("title", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(*p.Title) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(*p.Title) } return l } @@ -1593,28 +1327,21 @@ func (p *UpdateNoteRequest) field3Length() int { func (p *UpdateNoteRequest) field4Length() int { l := 0 if p.IsSetContent() { - l += bthrift.Binary.FieldBeginLength("content", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(*p.Content) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(*p.Content) } return l } func (p *UpdateNoteResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1631,115 +1358,87 @@ func (p *UpdateNoteResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateNoteResponse[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 *UpdateNoteResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - p.BaseResp = NewBaseResp() - if l, err := p.BaseResp.FastRead(buf[offset:]); err != nil { + _field := NewBaseResp() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.BaseResp = _field return offset, nil } -// for compatibility func (p *UpdateNoteResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateNoteResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateNoteResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateNoteResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateNoteResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateNoteResponse") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateNoteResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateNoteResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "base_resp", thrift.STRUCT, 1) - offset += p.BaseResp.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.BaseResp.FastWriteNocopy(buf[offset:], w) return offset } func (p *UpdateNoteResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("base_resp", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *MGetNoteRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1756,146 +1455,108 @@ func (p *MGetNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_MGetNoteRequest[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 *MGetNoteRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err } - p.NoteIds = make([]int64, 0, size) + _field := make([]int64, 0, size) for i := 0; i < size; i++ { var _elem int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _elem = v - } - p.NoteIds = append(p.NoteIds, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + _field = append(_field, _elem) } + p.NoteIds = _field return offset, nil } -// for compatibility func (p *MGetNoteRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *MGetNoteRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MGetNoteRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "MGetNoteRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *MGetNoteRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("MGetNoteRequest") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *MGetNoteRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MGetNoteRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "note_ids", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.I64, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.NoteIds { length++ - offset += bthrift.Binary.WriteI64(buf[offset:], v) - + offset += thrift.Binary.WriteI64(buf[offset:], v) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.I64, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.I64, length) return offset } func (p *MGetNoteRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("note_ids", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.I64, len(p.NoteIds)) - var tmpV int64 - l += bthrift.Binary.I64Length(int64(tmpV)) * len(p.NoteIds) - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() + l += + thrift.Binary.I64Length() * len(p.NoteIds) return l } func (p *MGetNoteResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1912,7 +1573,7 @@ func (p *MGetNoteResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1926,172 +1587,139 @@ func (p *MGetNoteResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_MGetNoteResponse[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 *MGetNoteResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err } - p.Notes = make([]*Note, 0, size) + _field := make([]*Note, 0, size) + values := make([]Note, size) for i := 0; i < size; i++ { - _elem := NewNote() + _elem := &values[i] + _elem.InitDefault() if l, err := _elem.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Notes = append(p.Notes, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + _field = append(_field, _elem) } + p.Notes = _field return offset, nil } func (p *MGetNoteResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - p.BaseResp = NewBaseResp() - if l, err := p.BaseResp.FastRead(buf[offset:]); err != nil { + _field := NewBaseResp() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.BaseResp = _field return offset, nil } -// for compatibility func (p *MGetNoteResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *MGetNoteResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MGetNoteResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "MGetNoteResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *MGetNoteResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("MGetNoteResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *MGetNoteResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MGetNoteResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "notes", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Notes { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *MGetNoteResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MGetNoteResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "base_resp", thrift.STRUCT, 2) - offset += p.BaseResp.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.BaseResp.FastWriteNocopy(buf[offset:], w) return offset } func (p *MGetNoteResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("notes", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Notes)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Notes { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *MGetNoteResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("base_resp", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *QueryNoteRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2108,7 +1736,7 @@ func (p *QueryNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2122,7 +1750,7 @@ func (p *QueryNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2136,7 +1764,7 @@ func (p *QueryNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2150,225 +1778,183 @@ func (p *QueryNoteRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryNoteRequest[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 *QueryNoteRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *QueryNoteRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field *string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - p.SearchKey = &v - + _field = &v } + p.SearchKey = _field return offset, nil } func (p *QueryNoteRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Offset = v - + _field = v } + p.Offset = _field return offset, nil } func (p *QueryNoteRequest) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Limit = v - + _field = v } + p.Limit = _field return offset, nil } -// for compatibility func (p *QueryNoteRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryNoteRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryNoteRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryNoteRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryNoteRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryNoteRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryNoteRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryNoteRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *QueryNoteRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryNoteRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 if p.IsSetSearchKey() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "search_key", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.SearchKey) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, *p.SearchKey) } return offset } -func (p *QueryNoteRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryNoteRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "offset", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Offset) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.Offset) return offset } -func (p *QueryNoteRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryNoteRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "limit", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Limit) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Limit) return offset } func (p *QueryNoteRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryNoteRequest) field2Length() int { l := 0 if p.IsSetSearchKey() { - l += bthrift.Binary.FieldBeginLength("search_key", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(*p.SearchKey) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(*p.SearchKey) } return l } func (p *QueryNoteRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("offset", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.Offset) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryNoteRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("limit", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Limit) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryNoteResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2385,7 +1971,7 @@ func (p *QueryNoteResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2399,7 +1985,7 @@ func (p *QueryNoteResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2413,206 +1999,169 @@ func (p *QueryNoteResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryNoteResponse[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 *QueryNoteResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err } - p.Notes = make([]*Note, 0, size) + _field := make([]*Note, 0, size) + values := make([]Note, size) for i := 0; i < size; i++ { - _elem := NewNote() + _elem := &values[i] + _elem.InitDefault() if l, err := _elem.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Notes = append(p.Notes, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + _field = append(_field, _elem) } + p.Notes = _field return offset, nil } func (p *QueryNoteResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Total = v - + _field = v } + p.Total = _field return offset, nil } func (p *QueryNoteResponse) FastReadField3(buf []byte) (int, error) { offset := 0 - p.BaseResp = NewBaseResp() - if l, err := p.BaseResp.FastRead(buf[offset:]); err != nil { + _field := NewBaseResp() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.BaseResp = _field return offset, nil } -// for compatibility func (p *QueryNoteResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryNoteResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryNoteResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryNoteResponse") if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryNoteResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryNoteResponse") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryNoteResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryNoteResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "notes", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Notes { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *QueryNoteResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryNoteResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "total", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Total) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 2) + offset += thrift.Binary.WriteI64(buf[offset:], p.Total) return offset } -func (p *QueryNoteResponse) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryNoteResponse) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "base_resp", thrift.STRUCT, 3) - offset += p.BaseResp.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 3) + offset += p.BaseResp.FastWriteNocopy(buf[offset:], w) return offset } func (p *QueryNoteResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("notes", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Notes)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Notes { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *QueryNoteResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("total", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.Total) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryNoteResponse) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("base_resp", thrift.STRUCT, 3) + l += thrift.Binary.FieldBeginLength() l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NoteServiceCreateNoteArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2629,115 +2178,87 @@ func (p *NoteServiceCreateNoteArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NoteServiceCreateNoteArgs[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 *NoteServiceCreateNoteArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - p.Req = NewCreateNoteRequest() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { + _field := NewCreateNoteRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Req = _field return offset, nil } -// for compatibility func (p *NoteServiceCreateNoteArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NoteServiceCreateNoteArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceCreateNoteArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateNote_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NoteServiceCreateNoteArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateNote_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NoteServiceCreateNoteArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceCreateNoteArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *NoteServiceCreateNoteArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NoteServiceCreateNoteResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2754,91 +2275,69 @@ func (p *NoteServiceCreateNoteResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NoteServiceCreateNoteResult[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 *NoteServiceCreateNoteResult) FastReadField0(buf []byte) (int, error) { offset := 0 - p.Success = NewCreateNoteResponse() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { + _field := NewCreateNoteResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Success = _field return offset, nil } -// for compatibility func (p *NoteServiceCreateNoteResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NoteServiceCreateNoteResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceCreateNoteResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateNote_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NoteServiceCreateNoteResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateNote_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NoteServiceCreateNoteResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceCreateNoteResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2846,27 +2345,21 @@ func (p *NoteServiceCreateNoteResult) fastWriteField0(buf []byte, binaryWriter b func (p *NoteServiceCreateNoteResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *NoteServiceMGetNoteArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2883,115 +2376,87 @@ func (p *NoteServiceMGetNoteArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NoteServiceMGetNoteArgs[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 *NoteServiceMGetNoteArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - p.Req = NewMGetNoteRequest() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { + _field := NewMGetNoteRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Req = _field return offset, nil } -// for compatibility func (p *NoteServiceMGetNoteArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NoteServiceMGetNoteArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceMGetNoteArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "MGetNote_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NoteServiceMGetNoteArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("MGetNote_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NoteServiceMGetNoteArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceMGetNoteArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *NoteServiceMGetNoteArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NoteServiceMGetNoteResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3008,91 +2473,69 @@ func (p *NoteServiceMGetNoteResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NoteServiceMGetNoteResult[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 *NoteServiceMGetNoteResult) FastReadField0(buf []byte) (int, error) { offset := 0 - p.Success = NewMGetNoteResponse() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { + _field := NewMGetNoteResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Success = _field return offset, nil } -// for compatibility func (p *NoteServiceMGetNoteResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NoteServiceMGetNoteResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceMGetNoteResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "MGetNote_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NoteServiceMGetNoteResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("MGetNote_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NoteServiceMGetNoteResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceMGetNoteResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -3100,27 +2543,21 @@ func (p *NoteServiceMGetNoteResult) fastWriteField0(buf []byte, binaryWriter bth func (p *NoteServiceMGetNoteResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *NoteServiceDeleteNoteArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3137,115 +2574,87 @@ func (p *NoteServiceDeleteNoteArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NoteServiceDeleteNoteArgs[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 *NoteServiceDeleteNoteArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - p.Req = NewDeleteNoteRequest() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { + _field := NewDeleteNoteRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Req = _field return offset, nil } -// for compatibility func (p *NoteServiceDeleteNoteArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NoteServiceDeleteNoteArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceDeleteNoteArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteNote_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NoteServiceDeleteNoteArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteNote_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NoteServiceDeleteNoteArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceDeleteNoteArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *NoteServiceDeleteNoteArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NoteServiceDeleteNoteResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3262,91 +2671,69 @@ func (p *NoteServiceDeleteNoteResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NoteServiceDeleteNoteResult[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 *NoteServiceDeleteNoteResult) FastReadField0(buf []byte) (int, error) { offset := 0 - p.Success = NewDeleteNoteResponse() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { + _field := NewDeleteNoteResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Success = _field return offset, nil } -// for compatibility func (p *NoteServiceDeleteNoteResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NoteServiceDeleteNoteResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceDeleteNoteResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteNote_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NoteServiceDeleteNoteResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteNote_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NoteServiceDeleteNoteResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceDeleteNoteResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -3354,27 +2741,21 @@ func (p *NoteServiceDeleteNoteResult) fastWriteField0(buf []byte, binaryWriter b func (p *NoteServiceDeleteNoteResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *NoteServiceQueryNoteArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3391,115 +2772,87 @@ func (p *NoteServiceQueryNoteArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NoteServiceQueryNoteArgs[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 *NoteServiceQueryNoteArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - p.Req = NewQueryNoteRequest() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { + _field := NewQueryNoteRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Req = _field return offset, nil } -// for compatibility func (p *NoteServiceQueryNoteArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NoteServiceQueryNoteArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceQueryNoteArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryNote_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NoteServiceQueryNoteArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryNote_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NoteServiceQueryNoteArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceQueryNoteArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *NoteServiceQueryNoteArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NoteServiceQueryNoteResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3516,91 +2869,69 @@ func (p *NoteServiceQueryNoteResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NoteServiceQueryNoteResult[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 *NoteServiceQueryNoteResult) FastReadField0(buf []byte) (int, error) { offset := 0 - p.Success = NewQueryNoteResponse() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { + _field := NewQueryNoteResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Success = _field return offset, nil } -// for compatibility func (p *NoteServiceQueryNoteResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NoteServiceQueryNoteResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceQueryNoteResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryNote_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NoteServiceQueryNoteResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryNote_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NoteServiceQueryNoteResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceQueryNoteResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -3608,27 +2939,21 @@ func (p *NoteServiceQueryNoteResult) fastWriteField0(buf []byte, binaryWriter bt func (p *NoteServiceQueryNoteResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *NoteServiceUpdateNoteArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3645,115 +2970,87 @@ func (p *NoteServiceUpdateNoteArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NoteServiceUpdateNoteArgs[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 *NoteServiceUpdateNoteArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - p.Req = NewUpdateNoteRequest() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { + _field := NewUpdateNoteRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Req = _field return offset, nil } -// for compatibility func (p *NoteServiceUpdateNoteArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NoteServiceUpdateNoteArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceUpdateNoteArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateNote_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NoteServiceUpdateNoteArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateNote_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NoteServiceUpdateNoteArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceUpdateNoteArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *NoteServiceUpdateNoteArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NoteServiceUpdateNoteResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3770,91 +3067,69 @@ func (p *NoteServiceUpdateNoteResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NoteServiceUpdateNoteResult[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 *NoteServiceUpdateNoteResult) FastReadField0(buf []byte) (int, error) { offset := 0 - p.Success = NewUpdateNoteResponse() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { + _field := NewUpdateNoteResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Success = _field return offset, nil } -// for compatibility func (p *NoteServiceUpdateNoteResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NoteServiceUpdateNoteResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceUpdateNoteResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateNote_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NoteServiceUpdateNoteResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateNote_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NoteServiceUpdateNoteResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NoteServiceUpdateNoteResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -3862,9 +3137,8 @@ func (p *NoteServiceUpdateNoteResult) fastWriteField0(buf []byte, binaryWriter b func (p *NoteServiceUpdateNoteResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/bizdemo/easy_note/kitex_gen/notedemo/note.go b/bizdemo/easy_note/kitex_gen/notedemo/note.go index e1479bb0..52450901 100644 --- a/bizdemo/easy_note/kitex_gen/notedemo/note.go +++ b/bizdemo/easy_note/kitex_gen/notedemo/note.go @@ -1,25 +1,27 @@ -// Code generated by thriftgo (0.1.3). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package notedemo import ( "context" "fmt" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" - - "github.com/apache/thrift/lib/go/thrift" ) type BaseResp struct { - StatusCode int64 `thrift:"status_code,1" json:"status_code"` - StatusMessage string `thrift:"status_message,2" json:"status_message"` - ServiceTime int64 `thrift:"service_time,3" json:"service_time"` + StatusCode int64 `thrift:"status_code,1" frugal:"1,default,i64" json:"status_code"` + StatusMessage string `thrift:"status_message,2" frugal:"2,default,string" json:"status_message"` + ServiceTime int64 `thrift:"service_time,3" frugal:"3,default,i64" json:"service_time"` } func NewBaseResp() *BaseResp { return &BaseResp{} } +func (p *BaseResp) InitDefault() { +} + func (p *BaseResp) GetStatusCode() (v int64) { return p.StatusCode } @@ -71,37 +73,30 @@ func (p *BaseResp) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -127,33 +122,41 @@ ReadStructEndError: } func (p *BaseResp) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.StatusCode = v + _field = v } + p.StatusCode = _field return nil } - func (p *BaseResp) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.StatusMessage = v + _field = v } + p.StatusMessage = _field return nil } - func (p *BaseResp) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.ServiceTime = v + _field = v } + p.ServiceTime = _field return nil } func (p *BaseResp) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("BaseResp"); err != nil { goto WriteStructBeginError @@ -171,7 +174,6 @@ func (p *BaseResp) Write(oprot thrift.TProtocol) (err error) { fieldId = 3 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -246,6 +248,7 @@ func (p *BaseResp) String() string { return "" } return fmt.Sprintf("BaseResp(%+v)", *p) + } func (p *BaseResp) DeepEqual(ano *BaseResp) bool { @@ -289,19 +292,22 @@ func (p *BaseResp) Field3DeepEqual(src int64) bool { } type Note struct { - NoteId int64 `thrift:"note_id,1" json:"note_id"` - UserId int64 `thrift:"user_id,2" json:"user_id"` - UserName string `thrift:"user_name,3" json:"user_name"` - UserAvatar string `thrift:"user_avatar,4" json:"user_avatar"` - Title string `thrift:"title,5" json:"title"` - Content string `thrift:"content,6" json:"content"` - CreateTime int64 `thrift:"create_time,7" json:"create_time"` + NoteId int64 `thrift:"note_id,1" frugal:"1,default,i64" json:"note_id"` + UserId int64 `thrift:"user_id,2" frugal:"2,default,i64" json:"user_id"` + UserName string `thrift:"user_name,3" frugal:"3,default,string" json:"user_name"` + UserAvatar string `thrift:"user_avatar,4" frugal:"4,default,string" json:"user_avatar"` + Title string `thrift:"title,5" frugal:"5,default,string" json:"title"` + Content string `thrift:"content,6" frugal:"6,default,string" json:"content"` + CreateTime int64 `thrift:"create_time,7" frugal:"7,default,i64" json:"create_time"` } func NewNote() *Note { return &Note{} } +func (p *Note) InitDefault() { +} + func (p *Note) GetNoteId() (v int64) { return p.NoteId } @@ -385,77 +391,62 @@ func (p *Note) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 - } + } 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 - } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError } case 7: if fieldTypeId == thrift.I64 { if err = p.ReadField7(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -481,69 +472,85 @@ ReadStructEndError: } func (p *Note) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.NoteId = v + _field = v } + p.NoteId = _field return nil } - func (p *Note) ReadField2(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *Note) ReadField3(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.UserName = v + _field = v } + p.UserName = _field return nil } - func (p *Note) ReadField4(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.UserAvatar = v + _field = v } + p.UserAvatar = _field return nil } - func (p *Note) ReadField5(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Title = v + _field = v } + p.Title = _field return nil } - func (p *Note) ReadField6(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Content = v + _field = v } + p.Content = _field return nil } - func (p *Note) ReadField7(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.CreateTime = v + _field = v } + p.CreateTime = _field return nil } func (p *Note) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Note"); err != nil { goto WriteStructBeginError @@ -577,7 +584,6 @@ func (p *Note) Write(oprot thrift.TProtocol) (err error) { fieldId = 7 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -720,6 +726,7 @@ func (p *Note) String() string { return "" } return fmt.Sprintf("Note(%+v)", *p) + } func (p *Note) DeepEqual(ano *Note) bool { @@ -803,15 +810,18 @@ func (p *Note) Field7DeepEqual(src int64) bool { } type CreateNoteRequest struct { - Title string `thrift:"title,1" json:"title"` - Content string `thrift:"content,2" json:"content"` - UserId int64 `thrift:"user_id,3" json:"user_id"` + Title string `thrift:"title,1" frugal:"1,default,string" json:"title"` + Content string `thrift:"content,2" frugal:"2,default,string" json:"content"` + UserId int64 `thrift:"user_id,3" frugal:"3,default,i64" json:"user_id"` } func NewCreateNoteRequest() *CreateNoteRequest { return &CreateNoteRequest{} } +func (p *CreateNoteRequest) InitDefault() { +} + func (p *CreateNoteRequest) GetTitle() (v string) { return p.Title } @@ -863,37 +873,30 @@ func (p *CreateNoteRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -919,33 +922,41 @@ ReadStructEndError: } func (p *CreateNoteRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Title = v + _field = v } + p.Title = _field return nil } - func (p *CreateNoteRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Content = v + _field = v } + p.Content = _field return nil } - func (p *CreateNoteRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } func (p *CreateNoteRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateNoteRequest"); err != nil { goto WriteStructBeginError @@ -963,7 +974,6 @@ func (p *CreateNoteRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 3 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1038,6 +1048,7 @@ func (p *CreateNoteRequest) String() string { return "" } return fmt.Sprintf("CreateNoteRequest(%+v)", *p) + } func (p *CreateNoteRequest) DeepEqual(ano *CreateNoteRequest) bool { @@ -1081,13 +1092,16 @@ func (p *CreateNoteRequest) Field3DeepEqual(src int64) bool { } type CreateNoteResponse struct { - BaseResp *BaseResp `thrift:"base_resp,1" json:"base_resp"` + BaseResp *BaseResp `thrift:"base_resp,1" frugal:"1,default,BaseResp" json:"base_resp"` } func NewCreateNoteResponse() *CreateNoteResponse { return &CreateNoteResponse{} } +func (p *CreateNoteResponse) InitDefault() { +} + var CreateNoteResponse_BaseResp_DEFAULT *BaseResp func (p *CreateNoteResponse) GetBaseResp() (v *BaseResp) { @@ -1132,17 +1146,14 @@ func (p *CreateNoteResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1168,14 +1179,16 @@ ReadStructEndError: } func (p *CreateNoteResponse) ReadField1(iprot thrift.TProtocol) error { - p.BaseResp = NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { + _field := NewBaseResp() + if err := _field.Read(iprot); err != nil { return err } + p.BaseResp = _field return nil } func (p *CreateNoteResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateNoteResponse"); err != nil { goto WriteStructBeginError @@ -1185,7 +1198,6 @@ func (p *CreateNoteResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1226,6 +1238,7 @@ func (p *CreateNoteResponse) String() string { return "" } return fmt.Sprintf("CreateNoteResponse(%+v)", *p) + } func (p *CreateNoteResponse) DeepEqual(ano *CreateNoteResponse) bool { @@ -1249,14 +1262,17 @@ func (p *CreateNoteResponse) Field1DeepEqual(src *BaseResp) bool { } type DeleteNoteRequest struct { - NoteId int64 `thrift:"note_id,1" json:"note_id"` - UserId int64 `thrift:"user_id,2" json:"user_id"` + NoteId int64 `thrift:"note_id,1" frugal:"1,default,i64" json:"note_id"` + UserId int64 `thrift:"user_id,2" frugal:"2,default,i64" json:"user_id"` } func NewDeleteNoteRequest() *DeleteNoteRequest { return &DeleteNoteRequest{} } +func (p *DeleteNoteRequest) InitDefault() { +} + func (p *DeleteNoteRequest) GetNoteId() (v int64) { return p.NoteId } @@ -1300,27 +1316,22 @@ func (p *DeleteNoteRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -1346,24 +1357,30 @@ ReadStructEndError: } func (p *DeleteNoteRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.NoteId = v + _field = v } + p.NoteId = _field return nil } - func (p *DeleteNoteRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } func (p *DeleteNoteRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteNoteRequest"); err != nil { goto WriteStructBeginError @@ -1377,7 +1394,6 @@ func (p *DeleteNoteRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1435,6 +1451,7 @@ func (p *DeleteNoteRequest) String() string { return "" } return fmt.Sprintf("DeleteNoteRequest(%+v)", *p) + } func (p *DeleteNoteRequest) DeepEqual(ano *DeleteNoteRequest) bool { @@ -1468,13 +1485,16 @@ func (p *DeleteNoteRequest) Field2DeepEqual(src int64) bool { } type DeleteNoteResponse struct { - BaseResp *BaseResp `thrift:"base_resp,1" json:"base_resp"` + BaseResp *BaseResp `thrift:"base_resp,1" frugal:"1,default,BaseResp" json:"base_resp"` } func NewDeleteNoteResponse() *DeleteNoteResponse { return &DeleteNoteResponse{} } +func (p *DeleteNoteResponse) InitDefault() { +} + var DeleteNoteResponse_BaseResp_DEFAULT *BaseResp func (p *DeleteNoteResponse) GetBaseResp() (v *BaseResp) { @@ -1519,17 +1539,14 @@ func (p *DeleteNoteResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1555,14 +1572,16 @@ ReadStructEndError: } func (p *DeleteNoteResponse) ReadField1(iprot thrift.TProtocol) error { - p.BaseResp = NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { + _field := NewBaseResp() + if err := _field.Read(iprot); err != nil { return err } + p.BaseResp = _field return nil } func (p *DeleteNoteResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteNoteResponse"); err != nil { goto WriteStructBeginError @@ -1572,7 +1591,6 @@ func (p *DeleteNoteResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1613,6 +1631,7 @@ func (p *DeleteNoteResponse) String() string { return "" } return fmt.Sprintf("DeleteNoteResponse(%+v)", *p) + } func (p *DeleteNoteResponse) DeepEqual(ano *DeleteNoteResponse) bool { @@ -1636,16 +1655,19 @@ func (p *DeleteNoteResponse) Field1DeepEqual(src *BaseResp) bool { } type UpdateNoteRequest struct { - NoteId int64 `thrift:"note_id,1" json:"note_id"` - UserId int64 `thrift:"user_id,2" json:"user_id"` - Title *string `thrift:"title,3" json:"title,omitempty"` - Content *string `thrift:"content,4" json:"content,omitempty"` + NoteId int64 `thrift:"note_id,1" frugal:"1,default,i64" json:"note_id"` + UserId int64 `thrift:"user_id,2" frugal:"2,default,i64" json:"user_id"` + Title *string `thrift:"title,3,optional" frugal:"3,optional,string" json:"title,omitempty"` + Content *string `thrift:"content,4,optional" frugal:"4,optional,string" json:"content,omitempty"` } func NewUpdateNoteRequest() *UpdateNoteRequest { return &UpdateNoteRequest{} } +func (p *UpdateNoteRequest) InitDefault() { +} + func (p *UpdateNoteRequest) GetNoteId() (v int64) { return p.NoteId } @@ -1723,47 +1745,38 @@ func (p *UpdateNoteRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -1789,42 +1802,52 @@ ReadStructEndError: } func (p *UpdateNoteRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.NoteId = v + _field = v } + p.NoteId = _field return nil } - func (p *UpdateNoteRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *UpdateNoteRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field *string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Title = &v + _field = &v } + p.Title = _field return nil } - func (p *UpdateNoteRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field *string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Content = &v + _field = &v } + p.Content = _field return nil } func (p *UpdateNoteRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateNoteRequest"); err != nil { goto WriteStructBeginError @@ -1846,7 +1869,6 @@ func (p *UpdateNoteRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1942,6 +1964,7 @@ func (p *UpdateNoteRequest) String() string { return "" } return fmt.Sprintf("UpdateNoteRequest(%+v)", *p) + } func (p *UpdateNoteRequest) DeepEqual(ano *UpdateNoteRequest) bool { @@ -2005,13 +2028,16 @@ func (p *UpdateNoteRequest) Field4DeepEqual(src *string) bool { } type UpdateNoteResponse struct { - BaseResp *BaseResp `thrift:"base_resp,1" json:"base_resp"` + BaseResp *BaseResp `thrift:"base_resp,1" frugal:"1,default,BaseResp" json:"base_resp"` } func NewUpdateNoteResponse() *UpdateNoteResponse { return &UpdateNoteResponse{} } +func (p *UpdateNoteResponse) InitDefault() { +} + var UpdateNoteResponse_BaseResp_DEFAULT *BaseResp func (p *UpdateNoteResponse) GetBaseResp() (v *BaseResp) { @@ -2056,17 +2082,14 @@ func (p *UpdateNoteResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -2092,14 +2115,16 @@ ReadStructEndError: } func (p *UpdateNoteResponse) ReadField1(iprot thrift.TProtocol) error { - p.BaseResp = NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { + _field := NewBaseResp() + if err := _field.Read(iprot); err != nil { return err } + p.BaseResp = _field return nil } func (p *UpdateNoteResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateNoteResponse"); err != nil { goto WriteStructBeginError @@ -2109,7 +2134,6 @@ func (p *UpdateNoteResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2150,6 +2174,7 @@ func (p *UpdateNoteResponse) String() string { return "" } return fmt.Sprintf("UpdateNoteResponse(%+v)", *p) + } func (p *UpdateNoteResponse) DeepEqual(ano *UpdateNoteResponse) bool { @@ -2173,13 +2198,16 @@ func (p *UpdateNoteResponse) Field1DeepEqual(src *BaseResp) bool { } type MGetNoteRequest struct { - NoteIds []int64 `thrift:"note_ids,1" json:"note_ids"` + NoteIds []int64 `thrift:"note_ids,1" frugal:"1,default,list" json:"note_ids"` } func NewMGetNoteRequest() *MGetNoteRequest { return &MGetNoteRequest{} } +func (p *MGetNoteRequest) InitDefault() { +} + func (p *MGetNoteRequest) GetNoteIds() (v []int64) { return p.NoteIds } @@ -2215,17 +2243,14 @@ func (p *MGetNoteRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -2255,8 +2280,9 @@ func (p *MGetNoteRequest) ReadField1(iprot thrift.TProtocol) error { if err != nil { return err } - p.NoteIds = make([]int64, 0, size) + _field := make([]int64, 0, size) for i := 0; i < size; i++ { + var _elem int64 if v, err := iprot.ReadI64(); err != nil { return err @@ -2264,15 +2290,17 @@ func (p *MGetNoteRequest) ReadField1(iprot thrift.TProtocol) error { _elem = v } - p.NoteIds = append(p.NoteIds, _elem) + _field = append(_field, _elem) } if err := iprot.ReadListEnd(); err != nil { return err } + p.NoteIds = _field return nil } func (p *MGetNoteRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("MGetNoteRequest"); err != nil { goto WriteStructBeginError @@ -2282,7 +2310,6 @@ func (p *MGetNoteRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2331,6 +2358,7 @@ func (p *MGetNoteRequest) String() string { return "" } return fmt.Sprintf("MGetNoteRequest(%+v)", *p) + } func (p *MGetNoteRequest) DeepEqual(ano *MGetNoteRequest) bool { @@ -2360,14 +2388,17 @@ func (p *MGetNoteRequest) Field1DeepEqual(src []int64) bool { } type MGetNoteResponse struct { - Notes []*Note `thrift:"notes,1" json:"notes"` - BaseResp *BaseResp `thrift:"base_resp,2" json:"base_resp"` + Notes []*Note `thrift:"notes,1" frugal:"1,default,list" json:"notes"` + BaseResp *BaseResp `thrift:"base_resp,2" frugal:"2,default,BaseResp" json:"base_resp"` } func NewMGetNoteResponse() *MGetNoteResponse { return &MGetNoteResponse{} } +func (p *MGetNoteResponse) InitDefault() { +} + func (p *MGetNoteResponse) GetNotes() (v []*Note) { return p.Notes } @@ -2420,27 +2451,22 @@ func (p *MGetNoteResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -2470,30 +2496,35 @@ func (p *MGetNoteResponse) ReadField1(iprot thrift.TProtocol) error { if err != nil { return err } - p.Notes = make([]*Note, 0, size) + _field := make([]*Note, 0, size) + values := make([]Note, size) for i := 0; i < size; i++ { - _elem := NewNote() + _elem := &values[i] + _elem.InitDefault() + if err := _elem.Read(iprot); err != nil { return err } - p.Notes = append(p.Notes, _elem) + _field = append(_field, _elem) } if err := iprot.ReadListEnd(); err != nil { return err } + p.Notes = _field return nil } - func (p *MGetNoteResponse) ReadField2(iprot thrift.TProtocol) error { - p.BaseResp = NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { + _field := NewBaseResp() + if err := _field.Read(iprot); err != nil { return err } + p.BaseResp = _field return nil } func (p *MGetNoteResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("MGetNoteResponse"); err != nil { goto WriteStructBeginError @@ -2507,7 +2538,6 @@ func (p *MGetNoteResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2573,6 +2603,7 @@ func (p *MGetNoteResponse) String() string { return "" } return fmt.Sprintf("MGetNoteResponse(%+v)", *p) + } func (p *MGetNoteResponse) DeepEqual(ano *MGetNoteResponse) bool { @@ -2612,16 +2643,19 @@ func (p *MGetNoteResponse) Field2DeepEqual(src *BaseResp) bool { } type QueryNoteRequest struct { - UserId int64 `thrift:"user_id,1" json:"user_id"` - SearchKey *string `thrift:"search_key,2" json:"search_key,omitempty"` - Offset int64 `thrift:"offset,3" json:"offset"` - Limit int64 `thrift:"limit,4" json:"limit"` + UserId int64 `thrift:"user_id,1" frugal:"1,default,i64" json:"user_id"` + SearchKey *string `thrift:"search_key,2,optional" frugal:"2,optional,string" json:"search_key,omitempty"` + Offset int64 `thrift:"offset,3" frugal:"3,default,i64" json:"offset"` + Limit int64 `thrift:"limit,4" frugal:"4,default,i64" json:"limit"` } func NewQueryNoteRequest() *QueryNoteRequest { return &QueryNoteRequest{} } +func (p *QueryNoteRequest) InitDefault() { +} + func (p *QueryNoteRequest) GetUserId() (v int64) { return p.UserId } @@ -2690,47 +2724,38 @@ func (p *QueryNoteRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -2756,42 +2781,52 @@ ReadStructEndError: } func (p *QueryNoteRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *QueryNoteRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field *string if v, err := iprot.ReadString(); err != nil { return err } else { - p.SearchKey = &v + _field = &v } + p.SearchKey = _field return nil } - func (p *QueryNoteRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Offset = v + _field = v } + p.Offset = _field return nil } - func (p *QueryNoteRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Limit = v + _field = v } + p.Limit = _field return nil } func (p *QueryNoteRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryNoteRequest"); err != nil { goto WriteStructBeginError @@ -2813,7 +2848,6 @@ func (p *QueryNoteRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2907,6 +2941,7 @@ func (p *QueryNoteRequest) String() string { return "" } return fmt.Sprintf("QueryNoteRequest(%+v)", *p) + } func (p *QueryNoteRequest) DeepEqual(ano *QueryNoteRequest) bool { @@ -2965,15 +3000,18 @@ func (p *QueryNoteRequest) Field4DeepEqual(src int64) bool { } type QueryNoteResponse struct { - Notes []*Note `thrift:"notes,1" json:"notes"` - Total int64 `thrift:"total,2" json:"total"` - BaseResp *BaseResp `thrift:"base_resp,3" json:"base_resp"` + Notes []*Note `thrift:"notes,1" frugal:"1,default,list" json:"notes"` + Total int64 `thrift:"total,2" frugal:"2,default,i64" json:"total"` + BaseResp *BaseResp `thrift:"base_resp,3" frugal:"3,default,BaseResp" json:"base_resp"` } func NewQueryNoteResponse() *QueryNoteResponse { return &QueryNoteResponse{} } +func (p *QueryNoteResponse) InitDefault() { +} + func (p *QueryNoteResponse) GetNotes() (v []*Note) { return p.Notes } @@ -3034,37 +3072,30 @@ func (p *QueryNoteResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 } @@ -3094,39 +3125,46 @@ func (p *QueryNoteResponse) ReadField1(iprot thrift.TProtocol) error { if err != nil { return err } - p.Notes = make([]*Note, 0, size) + _field := make([]*Note, 0, size) + values := make([]Note, size) for i := 0; i < size; i++ { - _elem := NewNote() + _elem := &values[i] + _elem.InitDefault() + if err := _elem.Read(iprot); err != nil { return err } - p.Notes = append(p.Notes, _elem) + _field = append(_field, _elem) } if err := iprot.ReadListEnd(); err != nil { return err } + p.Notes = _field return nil } - func (p *QueryNoteResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Total = v + _field = v } + p.Total = _field return nil } - func (p *QueryNoteResponse) ReadField3(iprot thrift.TProtocol) error { - p.BaseResp = NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { + _field := NewBaseResp() + if err := _field.Read(iprot); err != nil { return err } + p.BaseResp = _field return nil } func (p *QueryNoteResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryNoteResponse"); err != nil { goto WriteStructBeginError @@ -3144,7 +3182,6 @@ func (p *QueryNoteResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 3 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3227,6 +3264,7 @@ func (p *QueryNoteResponse) String() string { return "" } return fmt.Sprintf("QueryNoteResponse(%+v)", *p) + } func (p *QueryNoteResponse) DeepEqual(ano *QueryNoteResponse) bool { @@ -3287,375 +3325,17 @@ type NoteService interface { UpdateNote(ctx context.Context, req *UpdateNoteRequest) (r *UpdateNoteResponse, err error) } -type NoteServiceClient struct { - c thrift.TClient -} - -func NewNoteServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *NoteServiceClient { - return &NoteServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewNoteServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *NoteServiceClient { - return &NoteServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewNoteServiceClient(c thrift.TClient) *NoteServiceClient { - return &NoteServiceClient{ - c: c, - } -} - -func (p *NoteServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *NoteServiceClient) CreateNote(ctx context.Context, req *CreateNoteRequest) (r *CreateNoteResponse, err error) { - var _args NoteServiceCreateNoteArgs - _args.Req = req - var _result NoteServiceCreateNoteResult - if err = p.Client_().Call(ctx, "CreateNote", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *NoteServiceClient) MGetNote(ctx context.Context, req *MGetNoteRequest) (r *MGetNoteResponse, err error) { - var _args NoteServiceMGetNoteArgs - _args.Req = req - var _result NoteServiceMGetNoteResult - if err = p.Client_().Call(ctx, "MGetNote", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *NoteServiceClient) DeleteNote(ctx context.Context, req *DeleteNoteRequest) (r *DeleteNoteResponse, err error) { - var _args NoteServiceDeleteNoteArgs - _args.Req = req - var _result NoteServiceDeleteNoteResult - if err = p.Client_().Call(ctx, "DeleteNote", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *NoteServiceClient) QueryNote(ctx context.Context, req *QueryNoteRequest) (r *QueryNoteResponse, err error) { - var _args NoteServiceQueryNoteArgs - _args.Req = req - var _result NoteServiceQueryNoteResult - if err = p.Client_().Call(ctx, "QueryNote", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *NoteServiceClient) UpdateNote(ctx context.Context, req *UpdateNoteRequest) (r *UpdateNoteResponse, err error) { - var _args NoteServiceUpdateNoteArgs - _args.Req = req - var _result NoteServiceUpdateNoteResult - if err = p.Client_().Call(ctx, "UpdateNote", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type NoteServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler NoteService -} - -func (p *NoteServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *NoteServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *NoteServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewNoteServiceProcessor(handler NoteService) *NoteServiceProcessor { - self := &NoteServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("CreateNote", ¬eServiceProcessorCreateNote{handler: handler}) - self.AddToProcessorMap("MGetNote", ¬eServiceProcessorMGetNote{handler: handler}) - self.AddToProcessorMap("DeleteNote", ¬eServiceProcessorDeleteNote{handler: handler}) - self.AddToProcessorMap("QueryNote", ¬eServiceProcessorQueryNote{handler: handler}) - self.AddToProcessorMap("UpdateNote", ¬eServiceProcessorUpdateNote{handler: handler}) - return self -} -func (p *NoteServiceProcessor) 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 noteServiceProcessorCreateNote struct { - handler NoteService -} - -func (p *noteServiceProcessorCreateNote) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := NoteServiceCreateNoteArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("CreateNote", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := NoteServiceCreateNoteResult{} - var retval *CreateNoteResponse - if retval, err2 = p.handler.CreateNote(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing CreateNote: "+err2.Error()) - oprot.WriteMessageBegin("CreateNote", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("CreateNote", 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 noteServiceProcessorMGetNote struct { - handler NoteService -} - -func (p *noteServiceProcessorMGetNote) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := NoteServiceMGetNoteArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("MGetNote", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := NoteServiceMGetNoteResult{} - var retval *MGetNoteResponse - if retval, err2 = p.handler.MGetNote(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing MGetNote: "+err2.Error()) - oprot.WriteMessageBegin("MGetNote", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("MGetNote", 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 noteServiceProcessorDeleteNote struct { - handler NoteService -} - -func (p *noteServiceProcessorDeleteNote) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := NoteServiceDeleteNoteArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("DeleteNote", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := NoteServiceDeleteNoteResult{} - var retval *DeleteNoteResponse - if retval, err2 = p.handler.DeleteNote(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing DeleteNote: "+err2.Error()) - oprot.WriteMessageBegin("DeleteNote", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("DeleteNote", 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 noteServiceProcessorQueryNote struct { - handler NoteService -} - -func (p *noteServiceProcessorQueryNote) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := NoteServiceQueryNoteArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("QueryNote", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := NoteServiceQueryNoteResult{} - var retval *QueryNoteResponse - if retval, err2 = p.handler.QueryNote(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing QueryNote: "+err2.Error()) - oprot.WriteMessageBegin("QueryNote", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("QueryNote", 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 noteServiceProcessorUpdateNote struct { - handler NoteService -} - -func (p *noteServiceProcessorUpdateNote) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := NoteServiceUpdateNoteArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("UpdateNote", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := NoteServiceUpdateNoteResult{} - var retval *UpdateNoteResponse - if retval, err2 = p.handler.UpdateNote(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing UpdateNote: "+err2.Error()) - oprot.WriteMessageBegin("UpdateNote", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("UpdateNote", 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 NoteServiceCreateNoteArgs struct { - Req *CreateNoteRequest `thrift:"req,1" json:"req"` + Req *CreateNoteRequest `thrift:"req,1" frugal:"1,default,CreateNoteRequest" json:"req"` } func NewNoteServiceCreateNoteArgs() *NoteServiceCreateNoteArgs { return &NoteServiceCreateNoteArgs{} } +func (p *NoteServiceCreateNoteArgs) InitDefault() { +} + var NoteServiceCreateNoteArgs_Req_DEFAULT *CreateNoteRequest func (p *NoteServiceCreateNoteArgs) GetReq() (v *CreateNoteRequest) { @@ -3700,17 +3380,14 @@ func (p *NoteServiceCreateNoteArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3736,14 +3413,16 @@ ReadStructEndError: } func (p *NoteServiceCreateNoteArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewCreateNoteRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewCreateNoteRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *NoteServiceCreateNoteArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateNote_args"); err != nil { goto WriteStructBeginError @@ -3753,7 +3432,6 @@ func (p *NoteServiceCreateNoteArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3794,6 +3472,7 @@ func (p *NoteServiceCreateNoteArgs) String() string { return "" } return fmt.Sprintf("NoteServiceCreateNoteArgs(%+v)", *p) + } func (p *NoteServiceCreateNoteArgs) DeepEqual(ano *NoteServiceCreateNoteArgs) bool { @@ -3817,13 +3496,16 @@ func (p *NoteServiceCreateNoteArgs) Field1DeepEqual(src *CreateNoteRequest) bool } type NoteServiceCreateNoteResult struct { - Success *CreateNoteResponse `thrift:"success,0" json:"success,omitempty"` + Success *CreateNoteResponse `thrift:"success,0,optional" frugal:"0,optional,CreateNoteResponse" json:"success,omitempty"` } func NewNoteServiceCreateNoteResult() *NoteServiceCreateNoteResult { return &NoteServiceCreateNoteResult{} } +func (p *NoteServiceCreateNoteResult) InitDefault() { +} + var NoteServiceCreateNoteResult_Success_DEFAULT *CreateNoteResponse func (p *NoteServiceCreateNoteResult) GetSuccess() (v *CreateNoteResponse) { @@ -3868,17 +3550,14 @@ func (p *NoteServiceCreateNoteResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3904,14 +3583,16 @@ ReadStructEndError: } func (p *NoteServiceCreateNoteResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewCreateNoteResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewCreateNoteResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *NoteServiceCreateNoteResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateNote_result"); err != nil { goto WriteStructBeginError @@ -3921,7 +3602,6 @@ func (p *NoteServiceCreateNoteResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3964,6 +3644,7 @@ func (p *NoteServiceCreateNoteResult) String() string { return "" } return fmt.Sprintf("NoteServiceCreateNoteResult(%+v)", *p) + } func (p *NoteServiceCreateNoteResult) DeepEqual(ano *NoteServiceCreateNoteResult) bool { @@ -3987,13 +3668,16 @@ func (p *NoteServiceCreateNoteResult) Field0DeepEqual(src *CreateNoteResponse) b } type NoteServiceMGetNoteArgs struct { - Req *MGetNoteRequest `thrift:"req,1" json:"req"` + Req *MGetNoteRequest `thrift:"req,1" frugal:"1,default,MGetNoteRequest" json:"req"` } func NewNoteServiceMGetNoteArgs() *NoteServiceMGetNoteArgs { return &NoteServiceMGetNoteArgs{} } +func (p *NoteServiceMGetNoteArgs) InitDefault() { +} + var NoteServiceMGetNoteArgs_Req_DEFAULT *MGetNoteRequest func (p *NoteServiceMGetNoteArgs) GetReq() (v *MGetNoteRequest) { @@ -4038,17 +3722,14 @@ func (p *NoteServiceMGetNoteArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4074,14 +3755,16 @@ ReadStructEndError: } func (p *NoteServiceMGetNoteArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewMGetNoteRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewMGetNoteRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *NoteServiceMGetNoteArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("MGetNote_args"); err != nil { goto WriteStructBeginError @@ -4091,7 +3774,6 @@ func (p *NoteServiceMGetNoteArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4132,6 +3814,7 @@ func (p *NoteServiceMGetNoteArgs) String() string { return "" } return fmt.Sprintf("NoteServiceMGetNoteArgs(%+v)", *p) + } func (p *NoteServiceMGetNoteArgs) DeepEqual(ano *NoteServiceMGetNoteArgs) bool { @@ -4155,13 +3838,16 @@ func (p *NoteServiceMGetNoteArgs) Field1DeepEqual(src *MGetNoteRequest) bool { } type NoteServiceMGetNoteResult struct { - Success *MGetNoteResponse `thrift:"success,0" json:"success,omitempty"` + Success *MGetNoteResponse `thrift:"success,0,optional" frugal:"0,optional,MGetNoteResponse" json:"success,omitempty"` } func NewNoteServiceMGetNoteResult() *NoteServiceMGetNoteResult { return &NoteServiceMGetNoteResult{} } +func (p *NoteServiceMGetNoteResult) InitDefault() { +} + var NoteServiceMGetNoteResult_Success_DEFAULT *MGetNoteResponse func (p *NoteServiceMGetNoteResult) GetSuccess() (v *MGetNoteResponse) { @@ -4206,17 +3892,14 @@ func (p *NoteServiceMGetNoteResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4242,14 +3925,16 @@ ReadStructEndError: } func (p *NoteServiceMGetNoteResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewMGetNoteResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewMGetNoteResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *NoteServiceMGetNoteResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("MGetNote_result"); err != nil { goto WriteStructBeginError @@ -4259,7 +3944,6 @@ func (p *NoteServiceMGetNoteResult) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4302,6 +3986,7 @@ func (p *NoteServiceMGetNoteResult) String() string { return "" } return fmt.Sprintf("NoteServiceMGetNoteResult(%+v)", *p) + } func (p *NoteServiceMGetNoteResult) DeepEqual(ano *NoteServiceMGetNoteResult) bool { @@ -4325,13 +4010,16 @@ func (p *NoteServiceMGetNoteResult) Field0DeepEqual(src *MGetNoteResponse) bool } type NoteServiceDeleteNoteArgs struct { - Req *DeleteNoteRequest `thrift:"req,1" json:"req"` + Req *DeleteNoteRequest `thrift:"req,1" frugal:"1,default,DeleteNoteRequest" json:"req"` } func NewNoteServiceDeleteNoteArgs() *NoteServiceDeleteNoteArgs { return &NoteServiceDeleteNoteArgs{} } +func (p *NoteServiceDeleteNoteArgs) InitDefault() { +} + var NoteServiceDeleteNoteArgs_Req_DEFAULT *DeleteNoteRequest func (p *NoteServiceDeleteNoteArgs) GetReq() (v *DeleteNoteRequest) { @@ -4376,17 +4064,14 @@ func (p *NoteServiceDeleteNoteArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4412,14 +4097,16 @@ ReadStructEndError: } func (p *NoteServiceDeleteNoteArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewDeleteNoteRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewDeleteNoteRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *NoteServiceDeleteNoteArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteNote_args"); err != nil { goto WriteStructBeginError @@ -4429,7 +4116,6 @@ func (p *NoteServiceDeleteNoteArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4470,6 +4156,7 @@ func (p *NoteServiceDeleteNoteArgs) String() string { return "" } return fmt.Sprintf("NoteServiceDeleteNoteArgs(%+v)", *p) + } func (p *NoteServiceDeleteNoteArgs) DeepEqual(ano *NoteServiceDeleteNoteArgs) bool { @@ -4493,13 +4180,16 @@ func (p *NoteServiceDeleteNoteArgs) Field1DeepEqual(src *DeleteNoteRequest) bool } type NoteServiceDeleteNoteResult struct { - Success *DeleteNoteResponse `thrift:"success,0" json:"success,omitempty"` + Success *DeleteNoteResponse `thrift:"success,0,optional" frugal:"0,optional,DeleteNoteResponse" json:"success,omitempty"` } func NewNoteServiceDeleteNoteResult() *NoteServiceDeleteNoteResult { return &NoteServiceDeleteNoteResult{} } +func (p *NoteServiceDeleteNoteResult) InitDefault() { +} + var NoteServiceDeleteNoteResult_Success_DEFAULT *DeleteNoteResponse func (p *NoteServiceDeleteNoteResult) GetSuccess() (v *DeleteNoteResponse) { @@ -4544,17 +4234,14 @@ func (p *NoteServiceDeleteNoteResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4580,14 +4267,16 @@ ReadStructEndError: } func (p *NoteServiceDeleteNoteResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewDeleteNoteResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewDeleteNoteResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *NoteServiceDeleteNoteResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteNote_result"); err != nil { goto WriteStructBeginError @@ -4597,7 +4286,6 @@ func (p *NoteServiceDeleteNoteResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4640,6 +4328,7 @@ func (p *NoteServiceDeleteNoteResult) String() string { return "" } return fmt.Sprintf("NoteServiceDeleteNoteResult(%+v)", *p) + } func (p *NoteServiceDeleteNoteResult) DeepEqual(ano *NoteServiceDeleteNoteResult) bool { @@ -4663,13 +4352,16 @@ func (p *NoteServiceDeleteNoteResult) Field0DeepEqual(src *DeleteNoteResponse) b } type NoteServiceQueryNoteArgs struct { - Req *QueryNoteRequest `thrift:"req,1" json:"req"` + Req *QueryNoteRequest `thrift:"req,1" frugal:"1,default,QueryNoteRequest" json:"req"` } func NewNoteServiceQueryNoteArgs() *NoteServiceQueryNoteArgs { return &NoteServiceQueryNoteArgs{} } +func (p *NoteServiceQueryNoteArgs) InitDefault() { +} + var NoteServiceQueryNoteArgs_Req_DEFAULT *QueryNoteRequest func (p *NoteServiceQueryNoteArgs) GetReq() (v *QueryNoteRequest) { @@ -4714,17 +4406,14 @@ func (p *NoteServiceQueryNoteArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4750,14 +4439,16 @@ ReadStructEndError: } func (p *NoteServiceQueryNoteArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewQueryNoteRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewQueryNoteRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *NoteServiceQueryNoteArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryNote_args"); err != nil { goto WriteStructBeginError @@ -4767,7 +4458,6 @@ func (p *NoteServiceQueryNoteArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4808,6 +4498,7 @@ func (p *NoteServiceQueryNoteArgs) String() string { return "" } return fmt.Sprintf("NoteServiceQueryNoteArgs(%+v)", *p) + } func (p *NoteServiceQueryNoteArgs) DeepEqual(ano *NoteServiceQueryNoteArgs) bool { @@ -4831,13 +4522,16 @@ func (p *NoteServiceQueryNoteArgs) Field1DeepEqual(src *QueryNoteRequest) bool { } type NoteServiceQueryNoteResult struct { - Success *QueryNoteResponse `thrift:"success,0" json:"success,omitempty"` + Success *QueryNoteResponse `thrift:"success,0,optional" frugal:"0,optional,QueryNoteResponse" json:"success,omitempty"` } func NewNoteServiceQueryNoteResult() *NoteServiceQueryNoteResult { return &NoteServiceQueryNoteResult{} } +func (p *NoteServiceQueryNoteResult) InitDefault() { +} + var NoteServiceQueryNoteResult_Success_DEFAULT *QueryNoteResponse func (p *NoteServiceQueryNoteResult) GetSuccess() (v *QueryNoteResponse) { @@ -4882,17 +4576,14 @@ func (p *NoteServiceQueryNoteResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4918,14 +4609,16 @@ ReadStructEndError: } func (p *NoteServiceQueryNoteResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewQueryNoteResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewQueryNoteResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *NoteServiceQueryNoteResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryNote_result"); err != nil { goto WriteStructBeginError @@ -4935,7 +4628,6 @@ func (p *NoteServiceQueryNoteResult) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4978,6 +4670,7 @@ func (p *NoteServiceQueryNoteResult) String() string { return "" } return fmt.Sprintf("NoteServiceQueryNoteResult(%+v)", *p) + } func (p *NoteServiceQueryNoteResult) DeepEqual(ano *NoteServiceQueryNoteResult) bool { @@ -5001,13 +4694,16 @@ func (p *NoteServiceQueryNoteResult) Field0DeepEqual(src *QueryNoteResponse) boo } type NoteServiceUpdateNoteArgs struct { - Req *UpdateNoteRequest `thrift:"req,1" json:"req"` + Req *UpdateNoteRequest `thrift:"req,1" frugal:"1,default,UpdateNoteRequest" json:"req"` } func NewNoteServiceUpdateNoteArgs() *NoteServiceUpdateNoteArgs { return &NoteServiceUpdateNoteArgs{} } +func (p *NoteServiceUpdateNoteArgs) InitDefault() { +} + var NoteServiceUpdateNoteArgs_Req_DEFAULT *UpdateNoteRequest func (p *NoteServiceUpdateNoteArgs) GetReq() (v *UpdateNoteRequest) { @@ -5052,17 +4748,14 @@ func (p *NoteServiceUpdateNoteArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -5088,14 +4781,16 @@ ReadStructEndError: } func (p *NoteServiceUpdateNoteArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewUpdateNoteRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewUpdateNoteRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *NoteServiceUpdateNoteArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateNote_args"); err != nil { goto WriteStructBeginError @@ -5105,7 +4800,6 @@ func (p *NoteServiceUpdateNoteArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -5146,6 +4840,7 @@ func (p *NoteServiceUpdateNoteArgs) String() string { return "" } return fmt.Sprintf("NoteServiceUpdateNoteArgs(%+v)", *p) + } func (p *NoteServiceUpdateNoteArgs) DeepEqual(ano *NoteServiceUpdateNoteArgs) bool { @@ -5169,13 +4864,16 @@ func (p *NoteServiceUpdateNoteArgs) Field1DeepEqual(src *UpdateNoteRequest) bool } type NoteServiceUpdateNoteResult struct { - Success *UpdateNoteResponse `thrift:"success,0" json:"success,omitempty"` + Success *UpdateNoteResponse `thrift:"success,0,optional" frugal:"0,optional,UpdateNoteResponse" json:"success,omitempty"` } func NewNoteServiceUpdateNoteResult() *NoteServiceUpdateNoteResult { return &NoteServiceUpdateNoteResult{} } +func (p *NoteServiceUpdateNoteResult) InitDefault() { +} + var NoteServiceUpdateNoteResult_Success_DEFAULT *UpdateNoteResponse func (p *NoteServiceUpdateNoteResult) GetSuccess() (v *UpdateNoteResponse) { @@ -5220,17 +4918,14 @@ func (p *NoteServiceUpdateNoteResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -5256,14 +4951,16 @@ ReadStructEndError: } func (p *NoteServiceUpdateNoteResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewUpdateNoteResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewUpdateNoteResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *NoteServiceUpdateNoteResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateNote_result"); err != nil { goto WriteStructBeginError @@ -5273,7 +4970,6 @@ func (p *NoteServiceUpdateNoteResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -5316,6 +5012,7 @@ func (p *NoteServiceUpdateNoteResult) String() string { return "" } return fmt.Sprintf("NoteServiceUpdateNoteResult(%+v)", *p) + } func (p *NoteServiceUpdateNoteResult) DeepEqual(ano *NoteServiceUpdateNoteResult) bool { diff --git a/bizdemo/easy_note/kitex_gen/notedemo/noteservice/client.go b/bizdemo/easy_note/kitex_gen/notedemo/noteservice/client.go index a2a29c7d..7f8ac050 100644 --- a/bizdemo/easy_note/kitex_gen/notedemo/noteservice/client.go +++ b/bizdemo/easy_note/kitex_gen/notedemo/noteservice/client.go @@ -1,13 +1,12 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package noteservice import ( "context" - - "github.com/cloudwego/kitex-examples/bizdemo/easy_note/kitex_gen/notedemo" - "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt" + notedemo "github.com/cloudwego/kitex-examples/bizdemo/easy_note/kitex_gen/notedemo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. @@ -26,7 +25,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/bizdemo/easy_note/kitex_gen/notedemo/noteservice/noteservice.go b/bizdemo/easy_note/kitex_gen/notedemo/noteservice/noteservice.go index 4ad7d98c..e3b7efc0 100644 --- a/bizdemo/easy_note/kitex_gen/notedemo/noteservice/noteservice.go +++ b/bizdemo/easy_note/kitex_gen/notedemo/noteservice/noteservice.go @@ -1,40 +1,114 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package noteservice import ( "context" - - "github.com/cloudwego/kitex-examples/bizdemo/easy_note/kitex_gen/notedemo" - "github.com/cloudwego/kitex/client" + "errors" + notedemo "github.com/cloudwego/kitex-examples/bizdemo/easy_note/kitex_gen/notedemo" + client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "CreateNote": kitex.NewMethodInfo( + createNoteHandler, + newNoteServiceCreateNoteArgs, + newNoteServiceCreateNoteResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "MGetNote": kitex.NewMethodInfo( + mGetNoteHandler, + newNoteServiceMGetNoteArgs, + newNoteServiceMGetNoteResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "DeleteNote": kitex.NewMethodInfo( + deleteNoteHandler, + newNoteServiceDeleteNoteArgs, + newNoteServiceDeleteNoteResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "QueryNote": kitex.NewMethodInfo( + queryNoteHandler, + newNoteServiceQueryNoteArgs, + newNoteServiceQueryNoteResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "UpdateNote": kitex.NewMethodInfo( + updateNoteHandler, + newNoteServiceUpdateNoteArgs, + newNoteServiceUpdateNoteResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + noteServiceServiceInfo = NewServiceInfo() + noteServiceServiceInfoForClient = NewServiceInfoForClient() + noteServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return noteServiceServiceInfo } -var noteServiceServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return noteServiceServiceInfoForStreamClient +} +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return noteServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "NoteService" handlerType := (*notedemo.NoteService)(nil) - methods := map[string]kitex.MethodInfo{ - "CreateNote": kitex.NewMethodInfo(createNoteHandler, newNoteServiceCreateNoteArgs, newNoteServiceCreateNoteResult, false), - "MGetNote": kitex.NewMethodInfo(mGetNoteHandler, newNoteServiceMGetNoteArgs, newNoteServiceMGetNoteResult, false), - "DeleteNote": kitex.NewMethodInfo(deleteNoteHandler, newNoteServiceDeleteNoteArgs, newNoteServiceDeleteNoteResult, false), - "QueryNote": kitex.NewMethodInfo(queryNoteHandler, newNoteServiceQueryNoteArgs, newNoteServiceQueryNoteResult, false), - "UpdateNote": kitex.NewMethodInfo(updateNoteHandler, newNoteServiceUpdateNoteArgs, newNoteServiceUpdateNoteResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ "PackageName": "notedemo", } + if hasStreaming { + extra["streaming"] = hasStreaming + } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.1.4", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/bizdemo/easy_note/kitex_gen/notedemo/noteservice/server.go b/bizdemo/easy_note/kitex_gen/notedemo/noteservice/server.go index 6f3712d7..d59494dc 100644 --- a/bizdemo/easy_note/kitex_gen/notedemo/noteservice/server.go +++ b/bizdemo/easy_note/kitex_gen/notedemo/noteservice/server.go @@ -1,9 +1,9 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package noteservice import ( - "github.com/cloudwego/kitex-examples/bizdemo/easy_note/kitex_gen/notedemo" - "github.com/cloudwego/kitex/server" + notedemo "github.com/cloudwego/kitex-examples/bizdemo/easy_note/kitex_gen/notedemo" + server "github.com/cloudwego/kitex/server" ) // NewServer creates a server.Server with the given handler and options. @@ -11,6 +11,7 @@ func NewServer(handler notedemo.NoteService, opts ...server.Option) server.Serve var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler notedemo.NoteService, opts ...server.Option) server.Serve } return svr } + +func RegisterService(svr server.Server, handler notedemo.NoteService, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/bizdemo/kitex_ent/go.mod b/bizdemo/kitex_ent/go.mod index 51f891bb..82e26031 100644 --- a/bizdemo/kitex_ent/go.mod +++ b/bizdemo/kitex_ent/go.mod @@ -4,32 +4,33 @@ go 1.21 require ( entgo.io/ent v0.12.5 - github.com/apache/thrift v0.13.0 - github.com/cloudwego/kitex v0.11.3 + github.com/cloudwego/gopkg v0.1.3 + github.com/cloudwego/kitex v0.12.0 + github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 ) require ( ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935 // indirect github.com/agext/levenshtein v1.2.1 // indirect + github.com/apache/thrift v0.13.0 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/bytedance/gopkg v0.1.1 // indirect - github.com/bytedance/sonic v1.12.2 // indirect + github.com/bytedance/sonic v1.12.5 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/configmanager v0.2.2 // indirect - github.com/cloudwego/dynamicgo v0.4.0 // indirect + github.com/cloudwego/dynamicgo v0.4.6 // indirect github.com/cloudwego/fastpb v0.0.5 // indirect - github.com/cloudwego/frugal v0.2.0 // indirect - github.com/cloudwego/gopkg v0.1.2 // indirect + github.com/cloudwego/frugal v0.2.3 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cloudwego/localsession v0.0.2 // indirect - github.com/cloudwego/netpoll v0.6.4 // indirect + github.com/cloudwego/localsession v0.1.1 // indirect + github.com/cloudwego/netpoll v0.6.5 // indirect github.com/cloudwego/runtimex v0.1.0 // indirect - github.com/cloudwego/thriftgo v0.3.17 // indirect + github.com/cloudwego/thriftgo v0.3.18 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/go-openapi/inflect v0.19.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/go-cmp v0.5.7 // indirect github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect github.com/google/uuid v1.3.0 // indirect @@ -56,7 +57,7 @@ require ( golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/bizdemo/kitex_ent/go.sum b/bizdemo/kitex_ent/go.sum index 840e97b4..c1482f1a 100644 --- a/bizdemo/kitex_ent/go.sum +++ b/bizdemo/kitex_ent/go.sum @@ -17,8 +17,8 @@ github.com/bytedance/gopkg v0.1.0/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvD github.com/bytedance/gopkg v0.1.1 h1:3azzgSkiaw79u24a+w9arfH8OfnQQ4MHUt9lJFREEaE= github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic v1.12.2 h1:oaMFuRTpMHYLpCntGca65YWt5ny+wAceDERTkT2L9lg= -github.com/bytedance/sonic v1.12.2/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= +github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= @@ -28,26 +28,28 @@ 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/configmanager v0.2.2 h1:sVrJB8gWYTlPV2OS3wcgJSO9F2/9Zbkmcm1Z7jempOU= github.com/cloudwego/configmanager v0.2.2/go.mod h1:ppiyU+5TPLonE8qMVi/pFQk2eL3Q4P7d4hbiNJn6jwI= -github.com/cloudwego/dynamicgo v0.4.0 h1:wQqNRNiSQaLkbcn3sfpEJGZsz3xf8Il4P/3DcENsrFI= -github.com/cloudwego/dynamicgo v0.4.0/go.mod h1:zgWk2oz56EyH790LJSxrTz1j01GJBO964jJQ/y7qjJc= +github.com/cloudwego/dynamicgo v0.4.6 h1:raRdvLN1WsGl5WsNd2Ul86s8PFQPu8soF4ALSJ9MdC4= +github.com/cloudwego/dynamicgo v0.4.6/go.mod h1:DknfxjIMuGvXow409bS/AWycXONdc02HECBL0qpNqTY= github.com/cloudwego/fastpb v0.0.5 h1:vYnBPsfbAtU5TVz5+f9UTlmSCixG9F9vRwaqE0mZPZU= github.com/cloudwego/fastpb v0.0.5/go.mod h1:Bho7aAKBUtT9RPD2cNVkTdx4yQumfSv3If7wYnm1izk= -github.com/cloudwego/frugal v0.2.0 h1:0ETSzQYoYqVvdl7EKjqJ9aJnDoG6TzvNKV3PMQiQTS8= -github.com/cloudwego/frugal v0.2.0/go.mod h1:cpnV6kdRMjN3ylxRo63RNbZ9rBK6oxs70Zk6QZ4Enj4= -github.com/cloudwego/gopkg v0.1.2 h1:650t+RiZGht8qX+y0hl49JXJCuO44GhbGZuxDzr2PyI= -github.com/cloudwego/gopkg v0.1.2/go.mod h1:WoNTdXDPdvL97cBmRUWXVGkh2l2UFmpd9BUvbW2r0Aw= +github.com/cloudwego/frugal v0.2.3 h1:t1hhhAi8lXcx7Ncs4PR1pSZ90vlDU1cy5K2btDMFpoA= +github.com/cloudwego/frugal v0.2.3/go.mod h1:nC1U47gswLRiaxv6dybrhZvsDGCfQP9RGiiWC73CnoI= +github.com/cloudwego/gopkg v0.1.3 h1:y9VA5Zn5yqd1+QBV9aB0Zxy56JlAS7x4ZUoED/vJdxA= +github.com/cloudwego/gopkg v0.1.3/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= 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.11.3 h1:Qy1GtyuNbygMpwnMw+Aj1iS7fSd0IO7CzxtpZrRJ+Jc= -github.com/cloudwego/kitex v0.11.3/go.mod h1:RHT9ERKFVppJjBfGvwJAPxCIzf4oN1yASW5S4pPZNu4= -github.com/cloudwego/localsession v0.0.2 h1:N9/IDtCPj1fCL9bCTP+DbXx3f40YjVYWcwkJG0YhQkY= -github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= -github.com/cloudwego/netpoll v0.6.4 h1:z/dA4sOTUQof6zZIO4QNnLBXsDFFFEos9OOGloR6kno= -github.com/cloudwego/netpoll v0.6.4/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= +github.com/cloudwego/kitex v0.12.0 h1:TeNlAAkWc3MOIGnBQj+FcSUBan+3TBpzitnrviH0AXM= +github.com/cloudwego/kitex v0.12.0/go.mod h1:k2wQJ+3LPjQJHbBs0xE2k6z8SVRcUpB3/eRO34oM0nQ= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 h1:jU6gpAkJ3HZLZeSpxrL1xaCd/auvAbLs0SN/ylXn9TA= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2/go.mod h1:OP63V8YwwSlPVFqHZblV3mJXLPIjcIdwkT6ZYjEggcI= +github.com/cloudwego/localsession v0.1.1 h1:tbK7laDVrYfFDXoBXo4uCGMAxU4qmz2dDm8d4BGBnDo= +github.com/cloudwego/localsession v0.1.1/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= +github.com/cloudwego/netpoll v0.6.5 h1:6E/BWhSzQoyLg9Kx/4xiMdIIpovzwBtXvuqSqaTUzDQ= +github.com/cloudwego/netpoll v0.6.5/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= 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.17 h1:k0iQe2jEAN1WhPsXWvatwHzoxObUSX2Nw5NqdnywS8k= -github.com/cloudwego/thriftgo v0.3.17/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= +github.com/cloudwego/thriftgo v0.3.18 h1:gnr1vz7G3RbwwCK9AMKHZf63VYGa7ene6WbI9VrBJSw= +github.com/cloudwego/thriftgo v0.3.18/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= 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= @@ -80,8 +82,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -281,8 +284,8 @@ 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.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/bizdemo/kitex_ent/kitex_gen/user/k-user.go b/bizdemo/kitex_ent/kitex_gen/user/k-user.go index 8901cc14..c3ad759a 100644 --- a/bizdemo/kitex_ent/kitex_gen/user/k-user.go +++ b/bizdemo/kitex_ent/kitex_gen/user/k-user.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package user @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,24 +17,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *User) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -53,7 +45,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -67,7 +59,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -81,7 +73,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -95,7 +87,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -109,140 +101,120 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_User[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 *User) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *User) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *User) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *User) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *User) FastReadField5(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *User) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *User) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "User") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *User) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("User") if p != nil { l += p.field1Length() l += p.field2Length() @@ -250,115 +222,89 @@ func (p *User) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *User) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *User) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *User) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *User) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *User) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *User) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *User) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *User) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 3) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *User) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *User) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *CreateUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -375,7 +321,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -389,7 +335,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -403,7 +349,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -417,222 +363,180 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateUserRequest[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 *CreateUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *CreateUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *CreateUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *CreateUserRequest) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *CreateUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUserRequest") if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *CreateUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 2) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *CreateUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *CreateUserRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 4) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *CreateUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *CreateUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 2) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *CreateUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *CreateUserRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *CreateUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -649,7 +553,7 @@ func (p *CreateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -663,154 +567,120 @@ func (p *CreateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateUserResponse[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 *CreateUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *CreateUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *CreateUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *CreateUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *CreateUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *CreateUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *QueryUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -827,7 +697,7 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -841,7 +711,7 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -855,191 +725,153 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryUserRequest[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 *QueryUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field *string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Keyword = &v - + _field = &v } + p.Keyword = _field return offset, nil } func (p *QueryUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Page = v - + _field = v } + p.Page = _field return offset, nil } func (p *QueryUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.PageSize = v - + _field = v } + p.PageSize = _field return offset, nil } -// for compatibility func (p *QueryUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUserRequest") if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 if p.IsSetKeyword() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Keyword", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Keyword) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, *p.Keyword) } return offset } -func (p *QueryUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "page", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Page) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 2) + offset += thrift.Binary.WriteI64(buf[offset:], p.Page) return offset } -func (p *QueryUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "page_size", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.PageSize) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.PageSize) return offset } func (p *QueryUserRequest) field1Length() int { l := 0 if p.IsSetKeyword() { - l += bthrift.Binary.FieldBeginLength("Keyword", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(*p.Keyword) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(*p.Keyword) } return l } func (p *QueryUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("page", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.Page) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("page_size", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.PageSize) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1056,7 +888,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1070,7 +902,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1084,7 +916,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1098,245 +930,202 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryUserResponse[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 *QueryUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *QueryUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } func (p *QueryUserResponse) FastReadField3(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err } - p.Users = make([]*User, 0, size) + _field := make([]*User, 0, size) + values := make([]User, size) for i := 0; i < size; i++ { - _elem := NewUser() + _elem := &values[i] + _elem.InitDefault() if l, err := _elem.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Users = append(p.Users, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + _field = append(_field, _elem) } + p.Users = _field return offset, nil } func (p *QueryUserResponse) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Totoal = v - + _field = v } + p.Totoal = _field return offset, nil } -// for compatibility func (p *QueryUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUserResponse") if p != nil { - offset += p.fastWriteField4(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:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *QueryUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } -func (p *QueryUserResponse) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "users", thrift.LIST, 3) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 3) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Users { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *QueryUserResponse) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "totoal", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Totoal) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Totoal) return offset } func (p *QueryUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *QueryUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *QueryUserResponse) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("users", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Users)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Users { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *QueryUserResponse) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("totoal", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Totoal) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1353,120 +1142,89 @@ func (p *DeleteUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteUserRequest[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 *DeleteUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } -// for compatibility func (p *DeleteUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUserRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUserRequest") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } func (p *DeleteUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1483,7 +1241,7 @@ func (p *DeleteUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1497,154 +1255,120 @@ func (p *DeleteUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteUserResponse[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 *DeleteUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *DeleteUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *DeleteUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *DeleteUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *DeleteUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *DeleteUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *UpdateUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1661,7 +1385,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1675,7 +1399,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1689,7 +1413,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1703,7 +1427,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1717,140 +1441,120 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateUserRequest[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 *UpdateUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *UpdateUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *UpdateUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *UpdateUserRequest) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *UpdateUserRequest) FastReadField5(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *UpdateUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUserRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() @@ -1858,115 +1562,89 @@ func (p *UpdateUserRequest) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *UpdateUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *UpdateUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *UpdateUserRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *UpdateUserRequest) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *UpdateUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *UpdateUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 3) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *UpdateUserRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateUserRequest) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *UpdateUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1983,7 +1661,7 @@ func (p *UpdateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1997,154 +1675,120 @@ func (p *UpdateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateUserResponse[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 *UpdateUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *UpdateUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *UpdateUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *UpdateUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *UpdateUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *UpdateUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *UserServiceUpdateUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2161,117 +1805,87 @@ func (p *UserServiceUpdateUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceUpdateUserArgs[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 *UserServiceUpdateUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewUpdateUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewUpdateUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceUpdateUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceUpdateUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceUpdateUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceUpdateUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceUpdateUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceUpdateUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2288,93 +1902,69 @@ func (p *UserServiceUpdateUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceUpdateUserResult[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 *UserServiceUpdateUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewUpdateUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewUpdateUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceUpdateUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceUpdateUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceUpdateUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2382,27 +1972,21 @@ func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceUpdateUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceDeleteUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2419,117 +2003,87 @@ func (p *UserServiceDeleteUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceDeleteUserArgs[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 *UserServiceDeleteUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewDeleteUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewDeleteUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceDeleteUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceDeleteUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceDeleteUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceDeleteUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceDeleteUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceDeleteUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2546,93 +2100,69 @@ func (p *UserServiceDeleteUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceDeleteUserResult[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 *UserServiceDeleteUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewDeleteUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewDeleteUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceDeleteUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceDeleteUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceDeleteUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2640,27 +2170,21 @@ func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceDeleteUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceQueryUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2677,117 +2201,87 @@ func (p *UserServiceQueryUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceQueryUserArgs[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 *UserServiceQueryUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewQueryUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewQueryUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceQueryUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceQueryUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceQueryUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceQueryUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceQueryUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceQueryUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2804,93 +2298,69 @@ func (p *UserServiceQueryUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceQueryUserResult[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 *UserServiceQueryUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewQueryUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewQueryUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceQueryUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceQueryUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceQueryUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2898,27 +2368,21 @@ func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, binaryWriter bt func (p *UserServiceQueryUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceCreateUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2935,117 +2399,87 @@ func (p *UserServiceCreateUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceCreateUserArgs[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 *UserServiceCreateUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewCreateUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewCreateUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceCreateUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceCreateUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceCreateUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceCreateUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceCreateUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceCreateUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3062,93 +2496,69 @@ func (p *UserServiceCreateUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceCreateUserResult[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 *UserServiceCreateUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewCreateUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewCreateUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceCreateUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceCreateUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceCreateUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -3156,9 +2566,8 @@ func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceCreateUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/bizdemo/kitex_ent/kitex_gen/user/user.go b/bizdemo/kitex_ent/kitex_gen/user/user.go index b18a5d72..ef643911 100644 --- a/bizdemo/kitex_ent/kitex_gen/user/user.go +++ b/bizdemo/kitex_ent/kitex_gen/user/user.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.2.12). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package user @@ -7,7 +7,7 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" ) @@ -118,7 +118,6 @@ func NewUser() *User { } func (p *User) InitDefault() { - *p = User{} } func (p *User) GetUserId() (v int64) { @@ -188,57 +187,46 @@ func (p *User) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -264,51 +252,63 @@ ReadStructEndError: } func (p *User) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *User) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *User) ReadField3(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *User) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *User) ReadField5(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *User) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("User"); err != nil { goto WriteStructBeginError @@ -334,7 +334,6 @@ func (p *User) Write(oprot thrift.TProtocol) (err error) { fieldId = 5 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -443,6 +442,7 @@ func (p *User) String() string { return "" } return fmt.Sprintf("User(%+v)", *p) + } func (p *User) DeepEqual(ano *User) bool { @@ -517,7 +517,6 @@ func NewCreateUserRequest() *CreateUserRequest { } func (p *CreateUserRequest) InitDefault() { - *p = CreateUserRequest{} } func (p *CreateUserRequest) GetName() (v string) { @@ -579,47 +578,38 @@ func (p *CreateUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -645,42 +635,52 @@ ReadStructEndError: } func (p *CreateUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *CreateUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *CreateUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *CreateUserRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUserRequest"); err != nil { goto WriteStructBeginError @@ -702,7 +702,6 @@ func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -794,6 +793,7 @@ func (p *CreateUserRequest) String() string { return "" } return fmt.Sprintf("CreateUserRequest(%+v)", *p) + } func (p *CreateUserRequest) DeepEqual(ano *CreateUserRequest) bool { @@ -856,7 +856,6 @@ func NewCreateUserResponse() *CreateUserResponse { } func (p *CreateUserResponse) InitDefault() { - *p = CreateUserResponse{} } func (p *CreateUserResponse) GetCode() (v Code) { @@ -902,27 +901,22 @@ func (p *CreateUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -948,24 +942,30 @@ ReadStructEndError: } func (p *CreateUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *CreateUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *CreateUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUserResponse"); err != nil { goto WriteStructBeginError @@ -979,7 +979,6 @@ func (p *CreateUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1037,6 +1036,7 @@ func (p *CreateUserResponse) String() string { return "" } return fmt.Sprintf("CreateUserResponse(%+v)", *p) + } func (p *CreateUserResponse) DeepEqual(ano *CreateUserResponse) bool { @@ -1080,7 +1080,6 @@ func NewQueryUserRequest() *QueryUserRequest { } func (p *QueryUserRequest) InitDefault() { - *p = QueryUserRequest{} } var QueryUserRequest_Keyword_DEFAULT string @@ -1143,37 +1142,30 @@ func (p *QueryUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1199,33 +1191,41 @@ ReadStructEndError: } func (p *QueryUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field *string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Keyword = &v + _field = &v } + p.Keyword = _field return nil } - func (p *QueryUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Page = v + _field = v } + p.Page = _field return nil } - func (p *QueryUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.PageSize = v + _field = v } + p.PageSize = _field return nil } func (p *QueryUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUserRequest"); err != nil { goto WriteStructBeginError @@ -1243,7 +1243,6 @@ func (p *QueryUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 3 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1320,6 +1319,7 @@ func (p *QueryUserRequest) String() string { return "" } return fmt.Sprintf("QueryUserRequest(%+v)", *p) + } func (p *QueryUserRequest) DeepEqual(ano *QueryUserRequest) bool { @@ -1379,7 +1379,6 @@ func NewQueryUserResponse() *QueryUserResponse { } func (p *QueryUserResponse) InitDefault() { - *p = QueryUserResponse{} } func (p *QueryUserResponse) GetCode() (v Code) { @@ -1441,47 +1440,38 @@ func (p *QueryUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -1507,53 +1497,64 @@ ReadStructEndError: } func (p *QueryUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *QueryUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } - func (p *QueryUserResponse) ReadField3(iprot thrift.TProtocol) error { _, size, err := iprot.ReadListBegin() if err != nil { return err } - p.Users = make([]*User, 0, size) + _field := make([]*User, 0, size) + values := make([]User, size) for i := 0; i < size; i++ { - _elem := NewUser() + _elem := &values[i] + _elem.InitDefault() + if err := _elem.Read(iprot); err != nil { return err } - p.Users = append(p.Users, _elem) + _field = append(_field, _elem) } if err := iprot.ReadListEnd(); err != nil { return err } + p.Users = _field return nil } - func (p *QueryUserResponse) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Totoal = v + _field = v } + p.Totoal = _field return nil } func (p *QueryUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUserResponse"); err != nil { goto WriteStructBeginError @@ -1575,7 +1576,6 @@ func (p *QueryUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1675,6 +1675,7 @@ func (p *QueryUserResponse) String() string { return "" } return fmt.Sprintf("QueryUserResponse(%+v)", *p) + } func (p *QueryUserResponse) DeepEqual(ano *QueryUserResponse) bool { @@ -1742,7 +1743,6 @@ func NewDeleteUserRequest() *DeleteUserRequest { } func (p *DeleteUserRequest) InitDefault() { - *p = DeleteUserRequest{} } func (p *DeleteUserRequest) GetUserId() (v int64) { @@ -1780,17 +1780,14 @@ func (p *DeleteUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1816,15 +1813,19 @@ ReadStructEndError: } func (p *DeleteUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } func (p *DeleteUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUserRequest"); err != nil { goto WriteStructBeginError @@ -1834,7 +1835,6 @@ func (p *DeleteUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1875,6 +1875,7 @@ func (p *DeleteUserRequest) String() string { return "" } return fmt.Sprintf("DeleteUserRequest(%+v)", *p) + } func (p *DeleteUserRequest) DeepEqual(ano *DeleteUserRequest) bool { @@ -1907,7 +1908,6 @@ func NewDeleteUserResponse() *DeleteUserResponse { } func (p *DeleteUserResponse) InitDefault() { - *p = DeleteUserResponse{} } func (p *DeleteUserResponse) GetCode() (v Code) { @@ -1953,27 +1953,22 @@ func (p *DeleteUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -1999,24 +1994,30 @@ ReadStructEndError: } func (p *DeleteUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *DeleteUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *DeleteUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUserResponse"); err != nil { goto WriteStructBeginError @@ -2030,7 +2031,6 @@ func (p *DeleteUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2088,6 +2088,7 @@ func (p *DeleteUserResponse) String() string { return "" } return fmt.Sprintf("DeleteUserResponse(%+v)", *p) + } func (p *DeleteUserResponse) DeepEqual(ano *DeleteUserResponse) bool { @@ -2133,7 +2134,6 @@ func NewUpdateUserRequest() *UpdateUserRequest { } func (p *UpdateUserRequest) InitDefault() { - *p = UpdateUserRequest{} } func (p *UpdateUserRequest) GetUserId() (v int64) { @@ -2203,57 +2203,46 @@ func (p *UpdateUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -2279,51 +2268,63 @@ ReadStructEndError: } func (p *UpdateUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *UpdateUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *UpdateUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *UpdateUserRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *UpdateUserRequest) ReadField5(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *UpdateUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUserRequest"); err != nil { goto WriteStructBeginError @@ -2349,7 +2350,6 @@ func (p *UpdateUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 5 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2458,6 +2458,7 @@ func (p *UpdateUserRequest) String() string { return "" } return fmt.Sprintf("UpdateUserRequest(%+v)", *p) + } func (p *UpdateUserRequest) DeepEqual(ano *UpdateUserRequest) bool { @@ -2530,7 +2531,6 @@ func NewUpdateUserResponse() *UpdateUserResponse { } func (p *UpdateUserResponse) InitDefault() { - *p = UpdateUserResponse{} } func (p *UpdateUserResponse) GetCode() (v Code) { @@ -2576,27 +2576,22 @@ func (p *UpdateUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -2622,24 +2617,30 @@ ReadStructEndError: } func (p *UpdateUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *UpdateUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *UpdateUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUserResponse"); err != nil { goto WriteStructBeginError @@ -2653,7 +2654,6 @@ func (p *UpdateUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2711,6 +2711,7 @@ func (p *UpdateUserResponse) String() string { return "" } return fmt.Sprintf("UpdateUserResponse(%+v)", *p) + } func (p *UpdateUserResponse) DeepEqual(ano *UpdateUserResponse) bool { @@ -2753,305 +2754,6 @@ type UserService interface { CreateUser(ctx context.Context, req *CreateUserRequest) (r *CreateUserResponse, err error) } -type UserServiceClient struct { - c thrift.TClient -} - -func NewUserServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *UserServiceClient { - return &UserServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewUserServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *UserServiceClient { - return &UserServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewUserServiceClient(c thrift.TClient) *UserServiceClient { - return &UserServiceClient{ - c: c, - } -} - -func (p *UserServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *UserServiceClient) UpdateUser(ctx context.Context, req *UpdateUserRequest) (r *UpdateUserResponse, err error) { - var _args UserServiceUpdateUserArgs - _args.Req = req - var _result UserServiceUpdateUserResult - if err = p.Client_().Call(ctx, "UpdateUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) DeleteUser(ctx context.Context, req *DeleteUserRequest) (r *DeleteUserResponse, err error) { - var _args UserServiceDeleteUserArgs - _args.Req = req - var _result UserServiceDeleteUserResult - if err = p.Client_().Call(ctx, "DeleteUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) QueryUser(ctx context.Context, req *QueryUserRequest) (r *QueryUserResponse, err error) { - var _args UserServiceQueryUserArgs - _args.Req = req - var _result UserServiceQueryUserResult - if err = p.Client_().Call(ctx, "QueryUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) CreateUser(ctx context.Context, req *CreateUserRequest) (r *CreateUserResponse, err error) { - var _args UserServiceCreateUserArgs - _args.Req = req - var _result UserServiceCreateUserResult - if err = p.Client_().Call(ctx, "CreateUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type UserServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler UserService -} - -func (p *UserServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *UserServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *UserServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewUserServiceProcessor(handler UserService) *UserServiceProcessor { - self := &UserServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("UpdateUser", &userServiceProcessorUpdateUser{handler: handler}) - self.AddToProcessorMap("DeleteUser", &userServiceProcessorDeleteUser{handler: handler}) - self.AddToProcessorMap("QueryUser", &userServiceProcessorQueryUser{handler: handler}) - self.AddToProcessorMap("CreateUser", &userServiceProcessorCreateUser{handler: handler}) - return self -} -func (p *UserServiceProcessor) 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 userServiceProcessorUpdateUser struct { - handler UserService -} - -func (p *userServiceProcessorUpdateUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceUpdateUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("UpdateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceUpdateUserResult{} - var retval *UpdateUserResponse - if retval, err2 = p.handler.UpdateUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing UpdateUser: "+err2.Error()) - oprot.WriteMessageBegin("UpdateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("UpdateUser", 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 userServiceProcessorDeleteUser struct { - handler UserService -} - -func (p *userServiceProcessorDeleteUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceDeleteUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("DeleteUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceDeleteUserResult{} - var retval *DeleteUserResponse - if retval, err2 = p.handler.DeleteUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing DeleteUser: "+err2.Error()) - oprot.WriteMessageBegin("DeleteUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("DeleteUser", 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 userServiceProcessorQueryUser struct { - handler UserService -} - -func (p *userServiceProcessorQueryUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceQueryUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("QueryUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceQueryUserResult{} - var retval *QueryUserResponse - if retval, err2 = p.handler.QueryUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing QueryUser: "+err2.Error()) - oprot.WriteMessageBegin("QueryUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("QueryUser", 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 userServiceProcessorCreateUser struct { - handler UserService -} - -func (p *userServiceProcessorCreateUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceCreateUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("CreateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceCreateUserResult{} - var retval *CreateUserResponse - if retval, err2 = p.handler.CreateUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing CreateUser: "+err2.Error()) - oprot.WriteMessageBegin("CreateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("CreateUser", 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 UserServiceUpdateUserArgs struct { Req *UpdateUserRequest `thrift:"req,1" frugal:"1,default,UpdateUserRequest" json:"req"` } @@ -3061,7 +2763,6 @@ func NewUserServiceUpdateUserArgs() *UserServiceUpdateUserArgs { } func (p *UserServiceUpdateUserArgs) InitDefault() { - *p = UserServiceUpdateUserArgs{} } var UserServiceUpdateUserArgs_Req_DEFAULT *UpdateUserRequest @@ -3108,17 +2809,14 @@ func (p *UserServiceUpdateUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3144,14 +2842,16 @@ ReadStructEndError: } func (p *UserServiceUpdateUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewUpdateUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewUpdateUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceUpdateUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUser_args"); err != nil { goto WriteStructBeginError @@ -3161,7 +2861,6 @@ func (p *UserServiceUpdateUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3202,6 +2901,7 @@ func (p *UserServiceUpdateUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceUpdateUserArgs(%+v)", *p) + } func (p *UserServiceUpdateUserArgs) DeepEqual(ano *UserServiceUpdateUserArgs) bool { @@ -3233,7 +2933,6 @@ func NewUserServiceUpdateUserResult() *UserServiceUpdateUserResult { } func (p *UserServiceUpdateUserResult) InitDefault() { - *p = UserServiceUpdateUserResult{} } var UserServiceUpdateUserResult_Success_DEFAULT *UpdateUserResponse @@ -3280,17 +2979,14 @@ func (p *UserServiceUpdateUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3316,14 +3012,16 @@ ReadStructEndError: } func (p *UserServiceUpdateUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewUpdateUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewUpdateUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceUpdateUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUser_result"); err != nil { goto WriteStructBeginError @@ -3333,7 +3031,6 @@ func (p *UserServiceUpdateUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3376,6 +3073,7 @@ func (p *UserServiceUpdateUserResult) String() string { return "" } return fmt.Sprintf("UserServiceUpdateUserResult(%+v)", *p) + } func (p *UserServiceUpdateUserResult) DeepEqual(ano *UserServiceUpdateUserResult) bool { @@ -3407,7 +3105,6 @@ func NewUserServiceDeleteUserArgs() *UserServiceDeleteUserArgs { } func (p *UserServiceDeleteUserArgs) InitDefault() { - *p = UserServiceDeleteUserArgs{} } var UserServiceDeleteUserArgs_Req_DEFAULT *DeleteUserRequest @@ -3454,17 +3151,14 @@ func (p *UserServiceDeleteUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3490,14 +3184,16 @@ ReadStructEndError: } func (p *UserServiceDeleteUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewDeleteUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewDeleteUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceDeleteUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUser_args"); err != nil { goto WriteStructBeginError @@ -3507,7 +3203,6 @@ func (p *UserServiceDeleteUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3548,6 +3243,7 @@ func (p *UserServiceDeleteUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceDeleteUserArgs(%+v)", *p) + } func (p *UserServiceDeleteUserArgs) DeepEqual(ano *UserServiceDeleteUserArgs) bool { @@ -3579,7 +3275,6 @@ func NewUserServiceDeleteUserResult() *UserServiceDeleteUserResult { } func (p *UserServiceDeleteUserResult) InitDefault() { - *p = UserServiceDeleteUserResult{} } var UserServiceDeleteUserResult_Success_DEFAULT *DeleteUserResponse @@ -3626,17 +3321,14 @@ func (p *UserServiceDeleteUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3662,14 +3354,16 @@ ReadStructEndError: } func (p *UserServiceDeleteUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewDeleteUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewDeleteUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceDeleteUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUser_result"); err != nil { goto WriteStructBeginError @@ -3679,7 +3373,6 @@ func (p *UserServiceDeleteUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3722,6 +3415,7 @@ func (p *UserServiceDeleteUserResult) String() string { return "" } return fmt.Sprintf("UserServiceDeleteUserResult(%+v)", *p) + } func (p *UserServiceDeleteUserResult) DeepEqual(ano *UserServiceDeleteUserResult) bool { @@ -3753,7 +3447,6 @@ func NewUserServiceQueryUserArgs() *UserServiceQueryUserArgs { } func (p *UserServiceQueryUserArgs) InitDefault() { - *p = UserServiceQueryUserArgs{} } var UserServiceQueryUserArgs_Req_DEFAULT *QueryUserRequest @@ -3800,17 +3493,14 @@ func (p *UserServiceQueryUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3836,14 +3526,16 @@ ReadStructEndError: } func (p *UserServiceQueryUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewQueryUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewQueryUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceQueryUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUser_args"); err != nil { goto WriteStructBeginError @@ -3853,7 +3545,6 @@ func (p *UserServiceQueryUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3894,6 +3585,7 @@ func (p *UserServiceQueryUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceQueryUserArgs(%+v)", *p) + } func (p *UserServiceQueryUserArgs) DeepEqual(ano *UserServiceQueryUserArgs) bool { @@ -3925,7 +3617,6 @@ func NewUserServiceQueryUserResult() *UserServiceQueryUserResult { } func (p *UserServiceQueryUserResult) InitDefault() { - *p = UserServiceQueryUserResult{} } var UserServiceQueryUserResult_Success_DEFAULT *QueryUserResponse @@ -3972,17 +3663,14 @@ func (p *UserServiceQueryUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4008,14 +3696,16 @@ ReadStructEndError: } func (p *UserServiceQueryUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewQueryUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewQueryUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceQueryUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUser_result"); err != nil { goto WriteStructBeginError @@ -4025,7 +3715,6 @@ func (p *UserServiceQueryUserResult) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4068,6 +3757,7 @@ func (p *UserServiceQueryUserResult) String() string { return "" } return fmt.Sprintf("UserServiceQueryUserResult(%+v)", *p) + } func (p *UserServiceQueryUserResult) DeepEqual(ano *UserServiceQueryUserResult) bool { @@ -4099,7 +3789,6 @@ func NewUserServiceCreateUserArgs() *UserServiceCreateUserArgs { } func (p *UserServiceCreateUserArgs) InitDefault() { - *p = UserServiceCreateUserArgs{} } var UserServiceCreateUserArgs_Req_DEFAULT *CreateUserRequest @@ -4146,17 +3835,14 @@ func (p *UserServiceCreateUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4182,14 +3868,16 @@ ReadStructEndError: } func (p *UserServiceCreateUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewCreateUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewCreateUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceCreateUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUser_args"); err != nil { goto WriteStructBeginError @@ -4199,7 +3887,6 @@ func (p *UserServiceCreateUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4240,6 +3927,7 @@ func (p *UserServiceCreateUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceCreateUserArgs(%+v)", *p) + } func (p *UserServiceCreateUserArgs) DeepEqual(ano *UserServiceCreateUserArgs) bool { @@ -4271,7 +3959,6 @@ func NewUserServiceCreateUserResult() *UserServiceCreateUserResult { } func (p *UserServiceCreateUserResult) InitDefault() { - *p = UserServiceCreateUserResult{} } var UserServiceCreateUserResult_Success_DEFAULT *CreateUserResponse @@ -4318,17 +4005,14 @@ func (p *UserServiceCreateUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4354,14 +4038,16 @@ ReadStructEndError: } func (p *UserServiceCreateUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewCreateUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewCreateUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceCreateUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUser_result"); err != nil { goto WriteStructBeginError @@ -4371,7 +4057,6 @@ func (p *UserServiceCreateUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4414,6 +4099,7 @@ func (p *UserServiceCreateUserResult) String() string { return "" } return fmt.Sprintf("UserServiceCreateUserResult(%+v)", *p) + } func (p *UserServiceCreateUserResult) DeepEqual(ano *UserServiceCreateUserResult) bool { diff --git a/bizdemo/kitex_ent/kitex_gen/user/userservice/client.go b/bizdemo/kitex_ent/kitex_gen/user/userservice/client.go index 8ad0adb0..1c6688fb 100644 --- a/bizdemo/kitex_ent/kitex_gen/user/userservice/client.go +++ b/bizdemo/kitex_ent/kitex_gen/user/userservice/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice @@ -24,7 +24,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/bizdemo/kitex_ent/kitex_gen/user/userservice/server.go b/bizdemo/kitex_ent/kitex_gen/user/userservice/server.go index 31d7b129..01f3fcc6 100644 --- a/bizdemo/kitex_ent/kitex_gen/user/userservice/server.go +++ b/bizdemo/kitex_ent/kitex_gen/user/userservice/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( @@ -11,6 +11,7 @@ func NewServer(handler user.UserService, opts ...server.Option) server.Server { var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler user.UserService, opts ...server.Option) server.Server { } return svr } + +func RegisterService(svr server.Server, handler user.UserService, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/bizdemo/kitex_ent/kitex_gen/user/userservice/userservice.go b/bizdemo/kitex_ent/kitex_gen/user/userservice/userservice.go index 3644a4d7..93a34aa5 100644 --- a/bizdemo/kitex_ent/kitex_gen/user/userservice/userservice.go +++ b/bizdemo/kitex_ent/kitex_gen/user/userservice/userservice.go @@ -1,39 +1,107 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( "context" + "errors" user "github.com/cloudwego/kitex-examples/bizdemo/kitex_ent/kitex_gen/user" client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "UpdateUser": kitex.NewMethodInfo( + updateUserHandler, + newUserServiceUpdateUserArgs, + newUserServiceUpdateUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "DeleteUser": kitex.NewMethodInfo( + deleteUserHandler, + newUserServiceDeleteUserArgs, + newUserServiceDeleteUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "QueryUser": kitex.NewMethodInfo( + queryUserHandler, + newUserServiceQueryUserArgs, + newUserServiceQueryUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "CreateUser": kitex.NewMethodInfo( + createUserHandler, + newUserServiceCreateUserArgs, + newUserServiceCreateUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + userServiceServiceInfo = NewServiceInfo() + userServiceServiceInfoForClient = NewServiceInfoForClient() + userServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return userServiceServiceInfo } -var userServiceServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return userServiceServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return userServiceServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "UserService" handlerType := (*user.UserService)(nil) - methods := map[string]kitex.MethodInfo{ - "UpdateUser": kitex.NewMethodInfo(updateUserHandler, newUserServiceUpdateUserArgs, newUserServiceUpdateUserResult, false), - "DeleteUser": kitex.NewMethodInfo(deleteUserHandler, newUserServiceDeleteUserArgs, newUserServiceDeleteUserResult, false), - "QueryUser": kitex.NewMethodInfo(queryUserHandler, newUserServiceQueryUserArgs, newUserServiceQueryUserResult, false), - "CreateUser": kitex.NewMethodInfo(createUserHandler, newUserServiceCreateUserArgs, newUserServiceCreateUserResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ - "PackageName": "user", - "ServiceFilePath": `idl/user.thrift`, + "PackageName": "user", + } + if hasStreaming { + extra["streaming"] = hasStreaming } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/bizdemo/kitex_gorm/go.mod b/bizdemo/kitex_gorm/go.mod index 96791125..1382a28c 100644 --- a/bizdemo/kitex_gorm/go.mod +++ b/bizdemo/kitex_gorm/go.mod @@ -5,31 +5,32 @@ go 1.21 replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 require ( - github.com/apache/thrift v0.13.0 - github.com/cloudwego/kitex v0.11.3 + github.com/cloudwego/gopkg v0.1.3 + github.com/cloudwego/kitex v0.12.0 + github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 gorm.io/driver/mysql v1.5.2 gorm.io/gorm v1.25.7 ) require ( + github.com/apache/thrift v0.13.0 // indirect github.com/bytedance/gopkg v0.1.1 // indirect - github.com/bytedance/sonic v1.12.2 // indirect + github.com/bytedance/sonic v1.12.5 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/configmanager v0.2.2 // indirect - github.com/cloudwego/dynamicgo v0.4.0 // indirect + github.com/cloudwego/dynamicgo v0.4.6 // indirect github.com/cloudwego/fastpb v0.0.5 // indirect - github.com/cloudwego/frugal v0.2.0 // indirect - github.com/cloudwego/gopkg v0.1.2 // indirect + github.com/cloudwego/frugal v0.2.3 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cloudwego/localsession v0.0.2 // indirect - github.com/cloudwego/netpoll v0.6.4 // indirect + github.com/cloudwego/localsession v0.1.1 // indirect + github.com/cloudwego/netpoll v0.6.5 // indirect github.com/cloudwego/runtimex v0.1.0 // indirect - github.com/cloudwego/thriftgo v0.3.17 // indirect + github.com/cloudwego/thriftgo v0.3.18 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/go-sql-driver/mysql v1.7.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect github.com/iancoleman/strcase v0.2.0 // indirect github.com/jhump/protoreflect v1.8.2 // indirect @@ -52,6 +53,6 @@ require ( golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/bizdemo/kitex_gorm/go.sum b/bizdemo/kitex_gorm/go.sum index fe1a8fea..82218d9a 100644 --- a/bizdemo/kitex_gorm/go.sum +++ b/bizdemo/kitex_gorm/go.sum @@ -7,8 +7,8 @@ github.com/bytedance/gopkg v0.1.0/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvD github.com/bytedance/gopkg v0.1.1 h1:3azzgSkiaw79u24a+w9arfH8OfnQQ4MHUt9lJFREEaE= github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic v1.12.2 h1:oaMFuRTpMHYLpCntGca65YWt5ny+wAceDERTkT2L9lg= -github.com/bytedance/sonic v1.12.2/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= +github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= @@ -18,26 +18,28 @@ 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/configmanager v0.2.2 h1:sVrJB8gWYTlPV2OS3wcgJSO9F2/9Zbkmcm1Z7jempOU= github.com/cloudwego/configmanager v0.2.2/go.mod h1:ppiyU+5TPLonE8qMVi/pFQk2eL3Q4P7d4hbiNJn6jwI= -github.com/cloudwego/dynamicgo v0.4.0 h1:wQqNRNiSQaLkbcn3sfpEJGZsz3xf8Il4P/3DcENsrFI= -github.com/cloudwego/dynamicgo v0.4.0/go.mod h1:zgWk2oz56EyH790LJSxrTz1j01GJBO964jJQ/y7qjJc= +github.com/cloudwego/dynamicgo v0.4.6 h1:raRdvLN1WsGl5WsNd2Ul86s8PFQPu8soF4ALSJ9MdC4= +github.com/cloudwego/dynamicgo v0.4.6/go.mod h1:DknfxjIMuGvXow409bS/AWycXONdc02HECBL0qpNqTY= github.com/cloudwego/fastpb v0.0.5 h1:vYnBPsfbAtU5TVz5+f9UTlmSCixG9F9vRwaqE0mZPZU= github.com/cloudwego/fastpb v0.0.5/go.mod h1:Bho7aAKBUtT9RPD2cNVkTdx4yQumfSv3If7wYnm1izk= -github.com/cloudwego/frugal v0.2.0 h1:0ETSzQYoYqVvdl7EKjqJ9aJnDoG6TzvNKV3PMQiQTS8= -github.com/cloudwego/frugal v0.2.0/go.mod h1:cpnV6kdRMjN3ylxRo63RNbZ9rBK6oxs70Zk6QZ4Enj4= -github.com/cloudwego/gopkg v0.1.2 h1:650t+RiZGht8qX+y0hl49JXJCuO44GhbGZuxDzr2PyI= -github.com/cloudwego/gopkg v0.1.2/go.mod h1:WoNTdXDPdvL97cBmRUWXVGkh2l2UFmpd9BUvbW2r0Aw= +github.com/cloudwego/frugal v0.2.3 h1:t1hhhAi8lXcx7Ncs4PR1pSZ90vlDU1cy5K2btDMFpoA= +github.com/cloudwego/frugal v0.2.3/go.mod h1:nC1U47gswLRiaxv6dybrhZvsDGCfQP9RGiiWC73CnoI= +github.com/cloudwego/gopkg v0.1.3 h1:y9VA5Zn5yqd1+QBV9aB0Zxy56JlAS7x4ZUoED/vJdxA= +github.com/cloudwego/gopkg v0.1.3/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= 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.11.3 h1:Qy1GtyuNbygMpwnMw+Aj1iS7fSd0IO7CzxtpZrRJ+Jc= -github.com/cloudwego/kitex v0.11.3/go.mod h1:RHT9ERKFVppJjBfGvwJAPxCIzf4oN1yASW5S4pPZNu4= -github.com/cloudwego/localsession v0.0.2 h1:N9/IDtCPj1fCL9bCTP+DbXx3f40YjVYWcwkJG0YhQkY= -github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= -github.com/cloudwego/netpoll v0.6.4 h1:z/dA4sOTUQof6zZIO4QNnLBXsDFFFEos9OOGloR6kno= -github.com/cloudwego/netpoll v0.6.4/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= +github.com/cloudwego/kitex v0.12.0 h1:TeNlAAkWc3MOIGnBQj+FcSUBan+3TBpzitnrviH0AXM= +github.com/cloudwego/kitex v0.12.0/go.mod h1:k2wQJ+3LPjQJHbBs0xE2k6z8SVRcUpB3/eRO34oM0nQ= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 h1:jU6gpAkJ3HZLZeSpxrL1xaCd/auvAbLs0SN/ylXn9TA= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2/go.mod h1:OP63V8YwwSlPVFqHZblV3mJXLPIjcIdwkT6ZYjEggcI= +github.com/cloudwego/localsession v0.1.1 h1:tbK7laDVrYfFDXoBXo4uCGMAxU4qmz2dDm8d4BGBnDo= +github.com/cloudwego/localsession v0.1.1/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= +github.com/cloudwego/netpoll v0.6.5 h1:6E/BWhSzQoyLg9Kx/4xiMdIIpovzwBtXvuqSqaTUzDQ= +github.com/cloudwego/netpoll v0.6.5/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= 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.17 h1:k0iQe2jEAN1WhPsXWvatwHzoxObUSX2Nw5NqdnywS8k= -github.com/cloudwego/thriftgo v0.3.17/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= +github.com/cloudwego/thriftgo v0.3.18 h1:gnr1vz7G3RbwwCK9AMKHZf63VYGa7ene6WbI9VrBJSw= +github.com/cloudwego/thriftgo v0.3.18/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= 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= @@ -66,8 +68,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -247,8 +250,8 @@ 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.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/bizdemo/kitex_gorm/kitex_gen/user/k-user.go b/bizdemo/kitex_gorm/kitex_gen/user/k-user.go index 8901cc14..c3ad759a 100644 --- a/bizdemo/kitex_gorm/kitex_gen/user/k-user.go +++ b/bizdemo/kitex_gorm/kitex_gen/user/k-user.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package user @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,24 +17,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *User) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -53,7 +45,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -67,7 +59,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -81,7 +73,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -95,7 +87,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -109,140 +101,120 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_User[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 *User) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *User) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *User) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *User) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *User) FastReadField5(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *User) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *User) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "User") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *User) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("User") if p != nil { l += p.field1Length() l += p.field2Length() @@ -250,115 +222,89 @@ func (p *User) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *User) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *User) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *User) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *User) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *User) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *User) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *User) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *User) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 3) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *User) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *User) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *CreateUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -375,7 +321,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -389,7 +335,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -403,7 +349,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -417,222 +363,180 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateUserRequest[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 *CreateUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *CreateUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *CreateUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *CreateUserRequest) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *CreateUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUserRequest") if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *CreateUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 2) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *CreateUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *CreateUserRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 4) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *CreateUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *CreateUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 2) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *CreateUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *CreateUserRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *CreateUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -649,7 +553,7 @@ func (p *CreateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -663,154 +567,120 @@ func (p *CreateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateUserResponse[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 *CreateUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *CreateUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *CreateUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *CreateUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *CreateUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *CreateUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *QueryUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -827,7 +697,7 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -841,7 +711,7 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -855,191 +725,153 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryUserRequest[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 *QueryUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field *string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Keyword = &v - + _field = &v } + p.Keyword = _field return offset, nil } func (p *QueryUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Page = v - + _field = v } + p.Page = _field return offset, nil } func (p *QueryUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.PageSize = v - + _field = v } + p.PageSize = _field return offset, nil } -// for compatibility func (p *QueryUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUserRequest") if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 if p.IsSetKeyword() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Keyword", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Keyword) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, *p.Keyword) } return offset } -func (p *QueryUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "page", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Page) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 2) + offset += thrift.Binary.WriteI64(buf[offset:], p.Page) return offset } -func (p *QueryUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "page_size", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.PageSize) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.PageSize) return offset } func (p *QueryUserRequest) field1Length() int { l := 0 if p.IsSetKeyword() { - l += bthrift.Binary.FieldBeginLength("Keyword", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(*p.Keyword) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(*p.Keyword) } return l } func (p *QueryUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("page", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.Page) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("page_size", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.PageSize) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1056,7 +888,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1070,7 +902,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1084,7 +916,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1098,245 +930,202 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryUserResponse[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 *QueryUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *QueryUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } func (p *QueryUserResponse) FastReadField3(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err } - p.Users = make([]*User, 0, size) + _field := make([]*User, 0, size) + values := make([]User, size) for i := 0; i < size; i++ { - _elem := NewUser() + _elem := &values[i] + _elem.InitDefault() if l, err := _elem.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Users = append(p.Users, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + _field = append(_field, _elem) } + p.Users = _field return offset, nil } func (p *QueryUserResponse) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Totoal = v - + _field = v } + p.Totoal = _field return offset, nil } -// for compatibility func (p *QueryUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUserResponse") if p != nil { - offset += p.fastWriteField4(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:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *QueryUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } -func (p *QueryUserResponse) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "users", thrift.LIST, 3) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 3) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Users { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *QueryUserResponse) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "totoal", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Totoal) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Totoal) return offset } func (p *QueryUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *QueryUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *QueryUserResponse) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("users", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Users)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Users { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *QueryUserResponse) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("totoal", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Totoal) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1353,120 +1142,89 @@ func (p *DeleteUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteUserRequest[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 *DeleteUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } -// for compatibility func (p *DeleteUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUserRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUserRequest") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } func (p *DeleteUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1483,7 +1241,7 @@ func (p *DeleteUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1497,154 +1255,120 @@ func (p *DeleteUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteUserResponse[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 *DeleteUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *DeleteUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *DeleteUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *DeleteUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *DeleteUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *DeleteUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *UpdateUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1661,7 +1385,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1675,7 +1399,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1689,7 +1413,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1703,7 +1427,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1717,140 +1441,120 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateUserRequest[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 *UpdateUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *UpdateUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *UpdateUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *UpdateUserRequest) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *UpdateUserRequest) FastReadField5(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *UpdateUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUserRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() @@ -1858,115 +1562,89 @@ func (p *UpdateUserRequest) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *UpdateUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *UpdateUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *UpdateUserRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *UpdateUserRequest) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *UpdateUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *UpdateUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 3) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *UpdateUserRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateUserRequest) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *UpdateUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1983,7 +1661,7 @@ func (p *UpdateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1997,154 +1675,120 @@ func (p *UpdateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateUserResponse[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 *UpdateUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *UpdateUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *UpdateUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *UpdateUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *UpdateUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *UpdateUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *UserServiceUpdateUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2161,117 +1805,87 @@ func (p *UserServiceUpdateUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceUpdateUserArgs[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 *UserServiceUpdateUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewUpdateUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewUpdateUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceUpdateUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceUpdateUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceUpdateUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceUpdateUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceUpdateUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceUpdateUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2288,93 +1902,69 @@ func (p *UserServiceUpdateUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceUpdateUserResult[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 *UserServiceUpdateUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewUpdateUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewUpdateUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceUpdateUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceUpdateUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceUpdateUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2382,27 +1972,21 @@ func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceUpdateUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceDeleteUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2419,117 +2003,87 @@ func (p *UserServiceDeleteUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceDeleteUserArgs[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 *UserServiceDeleteUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewDeleteUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewDeleteUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceDeleteUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceDeleteUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceDeleteUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceDeleteUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceDeleteUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceDeleteUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2546,93 +2100,69 @@ func (p *UserServiceDeleteUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceDeleteUserResult[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 *UserServiceDeleteUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewDeleteUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewDeleteUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceDeleteUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceDeleteUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceDeleteUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2640,27 +2170,21 @@ func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceDeleteUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceQueryUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2677,117 +2201,87 @@ func (p *UserServiceQueryUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceQueryUserArgs[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 *UserServiceQueryUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewQueryUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewQueryUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceQueryUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceQueryUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceQueryUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceQueryUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceQueryUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceQueryUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2804,93 +2298,69 @@ func (p *UserServiceQueryUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceQueryUserResult[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 *UserServiceQueryUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewQueryUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewQueryUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceQueryUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceQueryUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceQueryUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2898,27 +2368,21 @@ func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, binaryWriter bt func (p *UserServiceQueryUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceCreateUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2935,117 +2399,87 @@ func (p *UserServiceCreateUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceCreateUserArgs[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 *UserServiceCreateUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewCreateUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewCreateUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceCreateUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceCreateUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceCreateUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceCreateUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceCreateUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceCreateUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3062,93 +2496,69 @@ func (p *UserServiceCreateUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceCreateUserResult[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 *UserServiceCreateUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewCreateUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewCreateUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceCreateUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceCreateUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceCreateUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -3156,9 +2566,8 @@ func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceCreateUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/bizdemo/kitex_gorm/kitex_gen/user/user.go b/bizdemo/kitex_gorm/kitex_gen/user/user.go index b18a5d72..ef643911 100644 --- a/bizdemo/kitex_gorm/kitex_gen/user/user.go +++ b/bizdemo/kitex_gorm/kitex_gen/user/user.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.2.12). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package user @@ -7,7 +7,7 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" ) @@ -118,7 +118,6 @@ func NewUser() *User { } func (p *User) InitDefault() { - *p = User{} } func (p *User) GetUserId() (v int64) { @@ -188,57 +187,46 @@ func (p *User) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -264,51 +252,63 @@ ReadStructEndError: } func (p *User) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *User) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *User) ReadField3(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *User) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *User) ReadField5(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *User) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("User"); err != nil { goto WriteStructBeginError @@ -334,7 +334,6 @@ func (p *User) Write(oprot thrift.TProtocol) (err error) { fieldId = 5 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -443,6 +442,7 @@ func (p *User) String() string { return "" } return fmt.Sprintf("User(%+v)", *p) + } func (p *User) DeepEqual(ano *User) bool { @@ -517,7 +517,6 @@ func NewCreateUserRequest() *CreateUserRequest { } func (p *CreateUserRequest) InitDefault() { - *p = CreateUserRequest{} } func (p *CreateUserRequest) GetName() (v string) { @@ -579,47 +578,38 @@ func (p *CreateUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -645,42 +635,52 @@ ReadStructEndError: } func (p *CreateUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *CreateUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *CreateUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *CreateUserRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUserRequest"); err != nil { goto WriteStructBeginError @@ -702,7 +702,6 @@ func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -794,6 +793,7 @@ func (p *CreateUserRequest) String() string { return "" } return fmt.Sprintf("CreateUserRequest(%+v)", *p) + } func (p *CreateUserRequest) DeepEqual(ano *CreateUserRequest) bool { @@ -856,7 +856,6 @@ func NewCreateUserResponse() *CreateUserResponse { } func (p *CreateUserResponse) InitDefault() { - *p = CreateUserResponse{} } func (p *CreateUserResponse) GetCode() (v Code) { @@ -902,27 +901,22 @@ func (p *CreateUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -948,24 +942,30 @@ ReadStructEndError: } func (p *CreateUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *CreateUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *CreateUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUserResponse"); err != nil { goto WriteStructBeginError @@ -979,7 +979,6 @@ func (p *CreateUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1037,6 +1036,7 @@ func (p *CreateUserResponse) String() string { return "" } return fmt.Sprintf("CreateUserResponse(%+v)", *p) + } func (p *CreateUserResponse) DeepEqual(ano *CreateUserResponse) bool { @@ -1080,7 +1080,6 @@ func NewQueryUserRequest() *QueryUserRequest { } func (p *QueryUserRequest) InitDefault() { - *p = QueryUserRequest{} } var QueryUserRequest_Keyword_DEFAULT string @@ -1143,37 +1142,30 @@ func (p *QueryUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1199,33 +1191,41 @@ ReadStructEndError: } func (p *QueryUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field *string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Keyword = &v + _field = &v } + p.Keyword = _field return nil } - func (p *QueryUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Page = v + _field = v } + p.Page = _field return nil } - func (p *QueryUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.PageSize = v + _field = v } + p.PageSize = _field return nil } func (p *QueryUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUserRequest"); err != nil { goto WriteStructBeginError @@ -1243,7 +1243,6 @@ func (p *QueryUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 3 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1320,6 +1319,7 @@ func (p *QueryUserRequest) String() string { return "" } return fmt.Sprintf("QueryUserRequest(%+v)", *p) + } func (p *QueryUserRequest) DeepEqual(ano *QueryUserRequest) bool { @@ -1379,7 +1379,6 @@ func NewQueryUserResponse() *QueryUserResponse { } func (p *QueryUserResponse) InitDefault() { - *p = QueryUserResponse{} } func (p *QueryUserResponse) GetCode() (v Code) { @@ -1441,47 +1440,38 @@ func (p *QueryUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -1507,53 +1497,64 @@ ReadStructEndError: } func (p *QueryUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *QueryUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } - func (p *QueryUserResponse) ReadField3(iprot thrift.TProtocol) error { _, size, err := iprot.ReadListBegin() if err != nil { return err } - p.Users = make([]*User, 0, size) + _field := make([]*User, 0, size) + values := make([]User, size) for i := 0; i < size; i++ { - _elem := NewUser() + _elem := &values[i] + _elem.InitDefault() + if err := _elem.Read(iprot); err != nil { return err } - p.Users = append(p.Users, _elem) + _field = append(_field, _elem) } if err := iprot.ReadListEnd(); err != nil { return err } + p.Users = _field return nil } - func (p *QueryUserResponse) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Totoal = v + _field = v } + p.Totoal = _field return nil } func (p *QueryUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUserResponse"); err != nil { goto WriteStructBeginError @@ -1575,7 +1576,6 @@ func (p *QueryUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1675,6 +1675,7 @@ func (p *QueryUserResponse) String() string { return "" } return fmt.Sprintf("QueryUserResponse(%+v)", *p) + } func (p *QueryUserResponse) DeepEqual(ano *QueryUserResponse) bool { @@ -1742,7 +1743,6 @@ func NewDeleteUserRequest() *DeleteUserRequest { } func (p *DeleteUserRequest) InitDefault() { - *p = DeleteUserRequest{} } func (p *DeleteUserRequest) GetUserId() (v int64) { @@ -1780,17 +1780,14 @@ func (p *DeleteUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1816,15 +1813,19 @@ ReadStructEndError: } func (p *DeleteUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } func (p *DeleteUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUserRequest"); err != nil { goto WriteStructBeginError @@ -1834,7 +1835,6 @@ func (p *DeleteUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1875,6 +1875,7 @@ func (p *DeleteUserRequest) String() string { return "" } return fmt.Sprintf("DeleteUserRequest(%+v)", *p) + } func (p *DeleteUserRequest) DeepEqual(ano *DeleteUserRequest) bool { @@ -1907,7 +1908,6 @@ func NewDeleteUserResponse() *DeleteUserResponse { } func (p *DeleteUserResponse) InitDefault() { - *p = DeleteUserResponse{} } func (p *DeleteUserResponse) GetCode() (v Code) { @@ -1953,27 +1953,22 @@ func (p *DeleteUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -1999,24 +1994,30 @@ ReadStructEndError: } func (p *DeleteUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *DeleteUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *DeleteUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUserResponse"); err != nil { goto WriteStructBeginError @@ -2030,7 +2031,6 @@ func (p *DeleteUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2088,6 +2088,7 @@ func (p *DeleteUserResponse) String() string { return "" } return fmt.Sprintf("DeleteUserResponse(%+v)", *p) + } func (p *DeleteUserResponse) DeepEqual(ano *DeleteUserResponse) bool { @@ -2133,7 +2134,6 @@ func NewUpdateUserRequest() *UpdateUserRequest { } func (p *UpdateUserRequest) InitDefault() { - *p = UpdateUserRequest{} } func (p *UpdateUserRequest) GetUserId() (v int64) { @@ -2203,57 +2203,46 @@ func (p *UpdateUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -2279,51 +2268,63 @@ ReadStructEndError: } func (p *UpdateUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *UpdateUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *UpdateUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *UpdateUserRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *UpdateUserRequest) ReadField5(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *UpdateUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUserRequest"); err != nil { goto WriteStructBeginError @@ -2349,7 +2350,6 @@ func (p *UpdateUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 5 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2458,6 +2458,7 @@ func (p *UpdateUserRequest) String() string { return "" } return fmt.Sprintf("UpdateUserRequest(%+v)", *p) + } func (p *UpdateUserRequest) DeepEqual(ano *UpdateUserRequest) bool { @@ -2530,7 +2531,6 @@ func NewUpdateUserResponse() *UpdateUserResponse { } func (p *UpdateUserResponse) InitDefault() { - *p = UpdateUserResponse{} } func (p *UpdateUserResponse) GetCode() (v Code) { @@ -2576,27 +2576,22 @@ func (p *UpdateUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -2622,24 +2617,30 @@ ReadStructEndError: } func (p *UpdateUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *UpdateUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *UpdateUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUserResponse"); err != nil { goto WriteStructBeginError @@ -2653,7 +2654,6 @@ func (p *UpdateUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2711,6 +2711,7 @@ func (p *UpdateUserResponse) String() string { return "" } return fmt.Sprintf("UpdateUserResponse(%+v)", *p) + } func (p *UpdateUserResponse) DeepEqual(ano *UpdateUserResponse) bool { @@ -2753,305 +2754,6 @@ type UserService interface { CreateUser(ctx context.Context, req *CreateUserRequest) (r *CreateUserResponse, err error) } -type UserServiceClient struct { - c thrift.TClient -} - -func NewUserServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *UserServiceClient { - return &UserServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewUserServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *UserServiceClient { - return &UserServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewUserServiceClient(c thrift.TClient) *UserServiceClient { - return &UserServiceClient{ - c: c, - } -} - -func (p *UserServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *UserServiceClient) UpdateUser(ctx context.Context, req *UpdateUserRequest) (r *UpdateUserResponse, err error) { - var _args UserServiceUpdateUserArgs - _args.Req = req - var _result UserServiceUpdateUserResult - if err = p.Client_().Call(ctx, "UpdateUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) DeleteUser(ctx context.Context, req *DeleteUserRequest) (r *DeleteUserResponse, err error) { - var _args UserServiceDeleteUserArgs - _args.Req = req - var _result UserServiceDeleteUserResult - if err = p.Client_().Call(ctx, "DeleteUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) QueryUser(ctx context.Context, req *QueryUserRequest) (r *QueryUserResponse, err error) { - var _args UserServiceQueryUserArgs - _args.Req = req - var _result UserServiceQueryUserResult - if err = p.Client_().Call(ctx, "QueryUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) CreateUser(ctx context.Context, req *CreateUserRequest) (r *CreateUserResponse, err error) { - var _args UserServiceCreateUserArgs - _args.Req = req - var _result UserServiceCreateUserResult - if err = p.Client_().Call(ctx, "CreateUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type UserServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler UserService -} - -func (p *UserServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *UserServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *UserServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewUserServiceProcessor(handler UserService) *UserServiceProcessor { - self := &UserServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("UpdateUser", &userServiceProcessorUpdateUser{handler: handler}) - self.AddToProcessorMap("DeleteUser", &userServiceProcessorDeleteUser{handler: handler}) - self.AddToProcessorMap("QueryUser", &userServiceProcessorQueryUser{handler: handler}) - self.AddToProcessorMap("CreateUser", &userServiceProcessorCreateUser{handler: handler}) - return self -} -func (p *UserServiceProcessor) 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 userServiceProcessorUpdateUser struct { - handler UserService -} - -func (p *userServiceProcessorUpdateUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceUpdateUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("UpdateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceUpdateUserResult{} - var retval *UpdateUserResponse - if retval, err2 = p.handler.UpdateUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing UpdateUser: "+err2.Error()) - oprot.WriteMessageBegin("UpdateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("UpdateUser", 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 userServiceProcessorDeleteUser struct { - handler UserService -} - -func (p *userServiceProcessorDeleteUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceDeleteUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("DeleteUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceDeleteUserResult{} - var retval *DeleteUserResponse - if retval, err2 = p.handler.DeleteUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing DeleteUser: "+err2.Error()) - oprot.WriteMessageBegin("DeleteUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("DeleteUser", 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 userServiceProcessorQueryUser struct { - handler UserService -} - -func (p *userServiceProcessorQueryUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceQueryUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("QueryUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceQueryUserResult{} - var retval *QueryUserResponse - if retval, err2 = p.handler.QueryUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing QueryUser: "+err2.Error()) - oprot.WriteMessageBegin("QueryUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("QueryUser", 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 userServiceProcessorCreateUser struct { - handler UserService -} - -func (p *userServiceProcessorCreateUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceCreateUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("CreateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceCreateUserResult{} - var retval *CreateUserResponse - if retval, err2 = p.handler.CreateUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing CreateUser: "+err2.Error()) - oprot.WriteMessageBegin("CreateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("CreateUser", 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 UserServiceUpdateUserArgs struct { Req *UpdateUserRequest `thrift:"req,1" frugal:"1,default,UpdateUserRequest" json:"req"` } @@ -3061,7 +2763,6 @@ func NewUserServiceUpdateUserArgs() *UserServiceUpdateUserArgs { } func (p *UserServiceUpdateUserArgs) InitDefault() { - *p = UserServiceUpdateUserArgs{} } var UserServiceUpdateUserArgs_Req_DEFAULT *UpdateUserRequest @@ -3108,17 +2809,14 @@ func (p *UserServiceUpdateUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3144,14 +2842,16 @@ ReadStructEndError: } func (p *UserServiceUpdateUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewUpdateUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewUpdateUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceUpdateUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUser_args"); err != nil { goto WriteStructBeginError @@ -3161,7 +2861,6 @@ func (p *UserServiceUpdateUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3202,6 +2901,7 @@ func (p *UserServiceUpdateUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceUpdateUserArgs(%+v)", *p) + } func (p *UserServiceUpdateUserArgs) DeepEqual(ano *UserServiceUpdateUserArgs) bool { @@ -3233,7 +2933,6 @@ func NewUserServiceUpdateUserResult() *UserServiceUpdateUserResult { } func (p *UserServiceUpdateUserResult) InitDefault() { - *p = UserServiceUpdateUserResult{} } var UserServiceUpdateUserResult_Success_DEFAULT *UpdateUserResponse @@ -3280,17 +2979,14 @@ func (p *UserServiceUpdateUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3316,14 +3012,16 @@ ReadStructEndError: } func (p *UserServiceUpdateUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewUpdateUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewUpdateUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceUpdateUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUser_result"); err != nil { goto WriteStructBeginError @@ -3333,7 +3031,6 @@ func (p *UserServiceUpdateUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3376,6 +3073,7 @@ func (p *UserServiceUpdateUserResult) String() string { return "" } return fmt.Sprintf("UserServiceUpdateUserResult(%+v)", *p) + } func (p *UserServiceUpdateUserResult) DeepEqual(ano *UserServiceUpdateUserResult) bool { @@ -3407,7 +3105,6 @@ func NewUserServiceDeleteUserArgs() *UserServiceDeleteUserArgs { } func (p *UserServiceDeleteUserArgs) InitDefault() { - *p = UserServiceDeleteUserArgs{} } var UserServiceDeleteUserArgs_Req_DEFAULT *DeleteUserRequest @@ -3454,17 +3151,14 @@ func (p *UserServiceDeleteUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3490,14 +3184,16 @@ ReadStructEndError: } func (p *UserServiceDeleteUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewDeleteUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewDeleteUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceDeleteUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUser_args"); err != nil { goto WriteStructBeginError @@ -3507,7 +3203,6 @@ func (p *UserServiceDeleteUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3548,6 +3243,7 @@ func (p *UserServiceDeleteUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceDeleteUserArgs(%+v)", *p) + } func (p *UserServiceDeleteUserArgs) DeepEqual(ano *UserServiceDeleteUserArgs) bool { @@ -3579,7 +3275,6 @@ func NewUserServiceDeleteUserResult() *UserServiceDeleteUserResult { } func (p *UserServiceDeleteUserResult) InitDefault() { - *p = UserServiceDeleteUserResult{} } var UserServiceDeleteUserResult_Success_DEFAULT *DeleteUserResponse @@ -3626,17 +3321,14 @@ func (p *UserServiceDeleteUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3662,14 +3354,16 @@ ReadStructEndError: } func (p *UserServiceDeleteUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewDeleteUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewDeleteUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceDeleteUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUser_result"); err != nil { goto WriteStructBeginError @@ -3679,7 +3373,6 @@ func (p *UserServiceDeleteUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3722,6 +3415,7 @@ func (p *UserServiceDeleteUserResult) String() string { return "" } return fmt.Sprintf("UserServiceDeleteUserResult(%+v)", *p) + } func (p *UserServiceDeleteUserResult) DeepEqual(ano *UserServiceDeleteUserResult) bool { @@ -3753,7 +3447,6 @@ func NewUserServiceQueryUserArgs() *UserServiceQueryUserArgs { } func (p *UserServiceQueryUserArgs) InitDefault() { - *p = UserServiceQueryUserArgs{} } var UserServiceQueryUserArgs_Req_DEFAULT *QueryUserRequest @@ -3800,17 +3493,14 @@ func (p *UserServiceQueryUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3836,14 +3526,16 @@ ReadStructEndError: } func (p *UserServiceQueryUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewQueryUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewQueryUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceQueryUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUser_args"); err != nil { goto WriteStructBeginError @@ -3853,7 +3545,6 @@ func (p *UserServiceQueryUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3894,6 +3585,7 @@ func (p *UserServiceQueryUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceQueryUserArgs(%+v)", *p) + } func (p *UserServiceQueryUserArgs) DeepEqual(ano *UserServiceQueryUserArgs) bool { @@ -3925,7 +3617,6 @@ func NewUserServiceQueryUserResult() *UserServiceQueryUserResult { } func (p *UserServiceQueryUserResult) InitDefault() { - *p = UserServiceQueryUserResult{} } var UserServiceQueryUserResult_Success_DEFAULT *QueryUserResponse @@ -3972,17 +3663,14 @@ func (p *UserServiceQueryUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4008,14 +3696,16 @@ ReadStructEndError: } func (p *UserServiceQueryUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewQueryUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewQueryUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceQueryUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUser_result"); err != nil { goto WriteStructBeginError @@ -4025,7 +3715,6 @@ func (p *UserServiceQueryUserResult) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4068,6 +3757,7 @@ func (p *UserServiceQueryUserResult) String() string { return "" } return fmt.Sprintf("UserServiceQueryUserResult(%+v)", *p) + } func (p *UserServiceQueryUserResult) DeepEqual(ano *UserServiceQueryUserResult) bool { @@ -4099,7 +3789,6 @@ func NewUserServiceCreateUserArgs() *UserServiceCreateUserArgs { } func (p *UserServiceCreateUserArgs) InitDefault() { - *p = UserServiceCreateUserArgs{} } var UserServiceCreateUserArgs_Req_DEFAULT *CreateUserRequest @@ -4146,17 +3835,14 @@ func (p *UserServiceCreateUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4182,14 +3868,16 @@ ReadStructEndError: } func (p *UserServiceCreateUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewCreateUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewCreateUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceCreateUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUser_args"); err != nil { goto WriteStructBeginError @@ -4199,7 +3887,6 @@ func (p *UserServiceCreateUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4240,6 +3927,7 @@ func (p *UserServiceCreateUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceCreateUserArgs(%+v)", *p) + } func (p *UserServiceCreateUserArgs) DeepEqual(ano *UserServiceCreateUserArgs) bool { @@ -4271,7 +3959,6 @@ func NewUserServiceCreateUserResult() *UserServiceCreateUserResult { } func (p *UserServiceCreateUserResult) InitDefault() { - *p = UserServiceCreateUserResult{} } var UserServiceCreateUserResult_Success_DEFAULT *CreateUserResponse @@ -4318,17 +4005,14 @@ func (p *UserServiceCreateUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4354,14 +4038,16 @@ ReadStructEndError: } func (p *UserServiceCreateUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewCreateUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewCreateUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceCreateUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUser_result"); err != nil { goto WriteStructBeginError @@ -4371,7 +4057,6 @@ func (p *UserServiceCreateUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4414,6 +4099,7 @@ func (p *UserServiceCreateUserResult) String() string { return "" } return fmt.Sprintf("UserServiceCreateUserResult(%+v)", *p) + } func (p *UserServiceCreateUserResult) DeepEqual(ano *UserServiceCreateUserResult) bool { diff --git a/bizdemo/kitex_gorm/kitex_gen/user/userservice/client.go b/bizdemo/kitex_gorm/kitex_gen/user/userservice/client.go index c6b1b0f2..5af04b7e 100644 --- a/bizdemo/kitex_gorm/kitex_gen/user/userservice/client.go +++ b/bizdemo/kitex_gorm/kitex_gen/user/userservice/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice @@ -24,7 +24,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/bizdemo/kitex_gorm/kitex_gen/user/userservice/server.go b/bizdemo/kitex_gorm/kitex_gen/user/userservice/server.go index 69f1172d..1f295cd0 100644 --- a/bizdemo/kitex_gorm/kitex_gen/user/userservice/server.go +++ b/bizdemo/kitex_gorm/kitex_gen/user/userservice/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( @@ -11,6 +11,7 @@ func NewServer(handler user.UserService, opts ...server.Option) server.Server { var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler user.UserService, opts ...server.Option) server.Server { } return svr } + +func RegisterService(svr server.Server, handler user.UserService, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/bizdemo/kitex_gorm/kitex_gen/user/userservice/userservice.go b/bizdemo/kitex_gorm/kitex_gen/user/userservice/userservice.go index 5629a1f6..6807c4f3 100644 --- a/bizdemo/kitex_gorm/kitex_gen/user/userservice/userservice.go +++ b/bizdemo/kitex_gorm/kitex_gen/user/userservice/userservice.go @@ -1,39 +1,107 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( "context" + "errors" user "github.com/cloudwego/kitex-examples/bizdemo/kitex_gorm/kitex_gen/user" client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "UpdateUser": kitex.NewMethodInfo( + updateUserHandler, + newUserServiceUpdateUserArgs, + newUserServiceUpdateUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "DeleteUser": kitex.NewMethodInfo( + deleteUserHandler, + newUserServiceDeleteUserArgs, + newUserServiceDeleteUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "QueryUser": kitex.NewMethodInfo( + queryUserHandler, + newUserServiceQueryUserArgs, + newUserServiceQueryUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "CreateUser": kitex.NewMethodInfo( + createUserHandler, + newUserServiceCreateUserArgs, + newUserServiceCreateUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + userServiceServiceInfo = NewServiceInfo() + userServiceServiceInfoForClient = NewServiceInfoForClient() + userServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return userServiceServiceInfo } -var userServiceServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return userServiceServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return userServiceServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "UserService" handlerType := (*user.UserService)(nil) - methods := map[string]kitex.MethodInfo{ - "UpdateUser": kitex.NewMethodInfo(updateUserHandler, newUserServiceUpdateUserArgs, newUserServiceUpdateUserResult, false), - "DeleteUser": kitex.NewMethodInfo(deleteUserHandler, newUserServiceDeleteUserArgs, newUserServiceDeleteUserResult, false), - "QueryUser": kitex.NewMethodInfo(queryUserHandler, newUserServiceQueryUserArgs, newUserServiceQueryUserResult, false), - "CreateUser": kitex.NewMethodInfo(createUserHandler, newUserServiceCreateUserArgs, newUserServiceCreateUserResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ - "PackageName": "user", - "ServiceFilePath": `idl/user.thrift`, + "PackageName": "user", + } + if hasStreaming { + extra["streaming"] = hasStreaming } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/bizdemo/kitex_gorm_gen/go.mod b/bizdemo/kitex_gorm_gen/go.mod index 4d9d03ea..ccc7be33 100644 --- a/bizdemo/kitex_gorm_gen/go.mod +++ b/bizdemo/kitex_gorm_gen/go.mod @@ -5,8 +5,9 @@ go 1.21 replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 require ( - github.com/apache/thrift v0.13.0 - github.com/cloudwego/kitex v0.11.3 + github.com/cloudwego/gopkg v0.1.3 + github.com/cloudwego/kitex v0.12.0 + github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 gorm.io/driver/mysql v1.5.2 gorm.io/gen v0.3.25 gorm.io/gorm v1.25.7 @@ -14,24 +15,24 @@ require ( ) require ( + github.com/apache/thrift v0.13.0 // indirect github.com/bytedance/gopkg v0.1.1 // indirect - github.com/bytedance/sonic v1.12.2 // indirect + github.com/bytedance/sonic v1.12.5 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/configmanager v0.2.2 // indirect - github.com/cloudwego/dynamicgo v0.4.0 // indirect + github.com/cloudwego/dynamicgo v0.4.6 // indirect github.com/cloudwego/fastpb v0.0.5 // indirect - github.com/cloudwego/frugal v0.2.0 // indirect - github.com/cloudwego/gopkg v0.1.2 // indirect + github.com/cloudwego/frugal v0.2.3 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cloudwego/localsession v0.0.2 // indirect - github.com/cloudwego/netpoll v0.6.4 // indirect + github.com/cloudwego/localsession v0.1.1 // indirect + github.com/cloudwego/netpoll v0.6.5 // indirect github.com/cloudwego/runtimex v0.1.0 // indirect - github.com/cloudwego/thriftgo v0.3.17 // indirect + github.com/cloudwego/thriftgo v0.3.18 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/go-sql-driver/mysql v1.7.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect github.com/iancoleman/strcase v0.2.0 // indirect github.com/jhump/protoreflect v1.8.2 // indirect @@ -56,7 +57,7 @@ require ( golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.15.0 // indirect google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c // indirect gorm.io/hints v1.1.0 // indirect diff --git a/bizdemo/kitex_gorm_gen/go.sum b/bizdemo/kitex_gorm_gen/go.sum index b8e969dd..b853a1f6 100644 --- a/bizdemo/kitex_gorm_gen/go.sum +++ b/bizdemo/kitex_gorm_gen/go.sum @@ -7,8 +7,8 @@ github.com/bytedance/gopkg v0.1.0/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvD github.com/bytedance/gopkg v0.1.1 h1:3azzgSkiaw79u24a+w9arfH8OfnQQ4MHUt9lJFREEaE= github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic v1.12.2 h1:oaMFuRTpMHYLpCntGca65YWt5ny+wAceDERTkT2L9lg= -github.com/bytedance/sonic v1.12.2/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= +github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= @@ -18,26 +18,28 @@ 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/configmanager v0.2.2 h1:sVrJB8gWYTlPV2OS3wcgJSO9F2/9Zbkmcm1Z7jempOU= github.com/cloudwego/configmanager v0.2.2/go.mod h1:ppiyU+5TPLonE8qMVi/pFQk2eL3Q4P7d4hbiNJn6jwI= -github.com/cloudwego/dynamicgo v0.4.0 h1:wQqNRNiSQaLkbcn3sfpEJGZsz3xf8Il4P/3DcENsrFI= -github.com/cloudwego/dynamicgo v0.4.0/go.mod h1:zgWk2oz56EyH790LJSxrTz1j01GJBO964jJQ/y7qjJc= +github.com/cloudwego/dynamicgo v0.4.6 h1:raRdvLN1WsGl5WsNd2Ul86s8PFQPu8soF4ALSJ9MdC4= +github.com/cloudwego/dynamicgo v0.4.6/go.mod h1:DknfxjIMuGvXow409bS/AWycXONdc02HECBL0qpNqTY= github.com/cloudwego/fastpb v0.0.5 h1:vYnBPsfbAtU5TVz5+f9UTlmSCixG9F9vRwaqE0mZPZU= github.com/cloudwego/fastpb v0.0.5/go.mod h1:Bho7aAKBUtT9RPD2cNVkTdx4yQumfSv3If7wYnm1izk= -github.com/cloudwego/frugal v0.2.0 h1:0ETSzQYoYqVvdl7EKjqJ9aJnDoG6TzvNKV3PMQiQTS8= -github.com/cloudwego/frugal v0.2.0/go.mod h1:cpnV6kdRMjN3ylxRo63RNbZ9rBK6oxs70Zk6QZ4Enj4= -github.com/cloudwego/gopkg v0.1.2 h1:650t+RiZGht8qX+y0hl49JXJCuO44GhbGZuxDzr2PyI= -github.com/cloudwego/gopkg v0.1.2/go.mod h1:WoNTdXDPdvL97cBmRUWXVGkh2l2UFmpd9BUvbW2r0Aw= +github.com/cloudwego/frugal v0.2.3 h1:t1hhhAi8lXcx7Ncs4PR1pSZ90vlDU1cy5K2btDMFpoA= +github.com/cloudwego/frugal v0.2.3/go.mod h1:nC1U47gswLRiaxv6dybrhZvsDGCfQP9RGiiWC73CnoI= +github.com/cloudwego/gopkg v0.1.3 h1:y9VA5Zn5yqd1+QBV9aB0Zxy56JlAS7x4ZUoED/vJdxA= +github.com/cloudwego/gopkg v0.1.3/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= 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.11.3 h1:Qy1GtyuNbygMpwnMw+Aj1iS7fSd0IO7CzxtpZrRJ+Jc= -github.com/cloudwego/kitex v0.11.3/go.mod h1:RHT9ERKFVppJjBfGvwJAPxCIzf4oN1yASW5S4pPZNu4= -github.com/cloudwego/localsession v0.0.2 h1:N9/IDtCPj1fCL9bCTP+DbXx3f40YjVYWcwkJG0YhQkY= -github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= -github.com/cloudwego/netpoll v0.6.4 h1:z/dA4sOTUQof6zZIO4QNnLBXsDFFFEos9OOGloR6kno= -github.com/cloudwego/netpoll v0.6.4/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= +github.com/cloudwego/kitex v0.12.0 h1:TeNlAAkWc3MOIGnBQj+FcSUBan+3TBpzitnrviH0AXM= +github.com/cloudwego/kitex v0.12.0/go.mod h1:k2wQJ+3LPjQJHbBs0xE2k6z8SVRcUpB3/eRO34oM0nQ= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 h1:jU6gpAkJ3HZLZeSpxrL1xaCd/auvAbLs0SN/ylXn9TA= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2/go.mod h1:OP63V8YwwSlPVFqHZblV3mJXLPIjcIdwkT6ZYjEggcI= +github.com/cloudwego/localsession v0.1.1 h1:tbK7laDVrYfFDXoBXo4uCGMAxU4qmz2dDm8d4BGBnDo= +github.com/cloudwego/localsession v0.1.1/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= +github.com/cloudwego/netpoll v0.6.5 h1:6E/BWhSzQoyLg9Kx/4xiMdIIpovzwBtXvuqSqaTUzDQ= +github.com/cloudwego/netpoll v0.6.5/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= 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.17 h1:k0iQe2jEAN1WhPsXWvatwHzoxObUSX2Nw5NqdnywS8k= -github.com/cloudwego/thriftgo v0.3.17/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= +github.com/cloudwego/thriftgo v0.3.18 h1:gnr1vz7G3RbwwCK9AMKHZf63VYGa7ene6WbI9VrBJSw= +github.com/cloudwego/thriftgo v0.3.18/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= 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= @@ -71,8 +73,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -281,8 +284,8 @@ 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.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/bizdemo/kitex_gorm_gen/kitex_gen/user/k-user.go b/bizdemo/kitex_gorm_gen/kitex_gen/user/k-user.go index 8901cc14..c3ad759a 100644 --- a/bizdemo/kitex_gorm_gen/kitex_gen/user/k-user.go +++ b/bizdemo/kitex_gorm_gen/kitex_gen/user/k-user.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package user @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,24 +17,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *User) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -53,7 +45,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -67,7 +59,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -81,7 +73,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -95,7 +87,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -109,140 +101,120 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_User[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 *User) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *User) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *User) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *User) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *User) FastReadField5(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *User) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *User) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "User") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *User) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("User") if p != nil { l += p.field1Length() l += p.field2Length() @@ -250,115 +222,89 @@ func (p *User) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *User) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *User) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *User) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *User) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *User) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *User) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *User) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *User) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 3) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *User) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *User) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *CreateUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -375,7 +321,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -389,7 +335,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -403,7 +349,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -417,222 +363,180 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateUserRequest[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 *CreateUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *CreateUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *CreateUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *CreateUserRequest) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *CreateUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUserRequest") if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *CreateUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 2) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *CreateUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *CreateUserRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 4) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *CreateUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *CreateUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 2) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *CreateUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *CreateUserRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *CreateUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -649,7 +553,7 @@ func (p *CreateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -663,154 +567,120 @@ func (p *CreateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateUserResponse[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 *CreateUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *CreateUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *CreateUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *CreateUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *CreateUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *CreateUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *QueryUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -827,7 +697,7 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -841,7 +711,7 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -855,191 +725,153 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryUserRequest[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 *QueryUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field *string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Keyword = &v - + _field = &v } + p.Keyword = _field return offset, nil } func (p *QueryUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Page = v - + _field = v } + p.Page = _field return offset, nil } func (p *QueryUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.PageSize = v - + _field = v } + p.PageSize = _field return offset, nil } -// for compatibility func (p *QueryUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUserRequest") if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 if p.IsSetKeyword() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Keyword", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Keyword) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, *p.Keyword) } return offset } -func (p *QueryUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "page", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Page) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 2) + offset += thrift.Binary.WriteI64(buf[offset:], p.Page) return offset } -func (p *QueryUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "page_size", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.PageSize) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.PageSize) return offset } func (p *QueryUserRequest) field1Length() int { l := 0 if p.IsSetKeyword() { - l += bthrift.Binary.FieldBeginLength("Keyword", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(*p.Keyword) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(*p.Keyword) } return l } func (p *QueryUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("page", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.Page) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("page_size", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.PageSize) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1056,7 +888,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1070,7 +902,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1084,7 +916,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1098,245 +930,202 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryUserResponse[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 *QueryUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *QueryUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } func (p *QueryUserResponse) FastReadField3(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err } - p.Users = make([]*User, 0, size) + _field := make([]*User, 0, size) + values := make([]User, size) for i := 0; i < size; i++ { - _elem := NewUser() + _elem := &values[i] + _elem.InitDefault() if l, err := _elem.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Users = append(p.Users, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + _field = append(_field, _elem) } + p.Users = _field return offset, nil } func (p *QueryUserResponse) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Totoal = v - + _field = v } + p.Totoal = _field return offset, nil } -// for compatibility func (p *QueryUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUserResponse") if p != nil { - offset += p.fastWriteField4(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:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *QueryUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } -func (p *QueryUserResponse) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "users", thrift.LIST, 3) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 3) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Users { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *QueryUserResponse) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "totoal", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Totoal) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Totoal) return offset } func (p *QueryUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *QueryUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *QueryUserResponse) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("users", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Users)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Users { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *QueryUserResponse) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("totoal", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Totoal) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1353,120 +1142,89 @@ func (p *DeleteUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteUserRequest[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 *DeleteUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } -// for compatibility func (p *DeleteUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUserRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUserRequest") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } func (p *DeleteUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1483,7 +1241,7 @@ func (p *DeleteUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1497,154 +1255,120 @@ func (p *DeleteUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteUserResponse[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 *DeleteUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *DeleteUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *DeleteUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *DeleteUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *DeleteUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *DeleteUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *UpdateUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1661,7 +1385,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1675,7 +1399,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1689,7 +1413,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1703,7 +1427,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1717,140 +1441,120 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateUserRequest[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 *UpdateUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *UpdateUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *UpdateUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *UpdateUserRequest) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *UpdateUserRequest) FastReadField5(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *UpdateUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUserRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() @@ -1858,115 +1562,89 @@ func (p *UpdateUserRequest) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *UpdateUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *UpdateUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *UpdateUserRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *UpdateUserRequest) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *UpdateUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *UpdateUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 3) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *UpdateUserRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateUserRequest) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *UpdateUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1983,7 +1661,7 @@ func (p *UpdateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1997,154 +1675,120 @@ func (p *UpdateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateUserResponse[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 *UpdateUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *UpdateUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *UpdateUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *UpdateUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *UpdateUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *UpdateUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *UserServiceUpdateUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2161,117 +1805,87 @@ func (p *UserServiceUpdateUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceUpdateUserArgs[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 *UserServiceUpdateUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewUpdateUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewUpdateUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceUpdateUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceUpdateUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceUpdateUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceUpdateUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceUpdateUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceUpdateUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2288,93 +1902,69 @@ func (p *UserServiceUpdateUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceUpdateUserResult[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 *UserServiceUpdateUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewUpdateUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewUpdateUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceUpdateUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceUpdateUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceUpdateUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2382,27 +1972,21 @@ func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceUpdateUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceDeleteUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2419,117 +2003,87 @@ func (p *UserServiceDeleteUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceDeleteUserArgs[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 *UserServiceDeleteUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewDeleteUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewDeleteUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceDeleteUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceDeleteUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceDeleteUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceDeleteUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceDeleteUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceDeleteUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2546,93 +2100,69 @@ func (p *UserServiceDeleteUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceDeleteUserResult[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 *UserServiceDeleteUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewDeleteUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewDeleteUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceDeleteUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceDeleteUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceDeleteUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2640,27 +2170,21 @@ func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceDeleteUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceQueryUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2677,117 +2201,87 @@ func (p *UserServiceQueryUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceQueryUserArgs[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 *UserServiceQueryUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewQueryUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewQueryUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceQueryUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceQueryUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceQueryUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceQueryUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceQueryUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceQueryUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2804,93 +2298,69 @@ func (p *UserServiceQueryUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceQueryUserResult[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 *UserServiceQueryUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewQueryUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewQueryUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceQueryUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceQueryUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceQueryUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2898,27 +2368,21 @@ func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, binaryWriter bt func (p *UserServiceQueryUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceCreateUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2935,117 +2399,87 @@ func (p *UserServiceCreateUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceCreateUserArgs[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 *UserServiceCreateUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewCreateUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewCreateUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceCreateUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceCreateUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceCreateUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceCreateUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceCreateUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceCreateUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3062,93 +2496,69 @@ func (p *UserServiceCreateUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceCreateUserResult[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 *UserServiceCreateUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewCreateUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewCreateUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceCreateUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceCreateUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceCreateUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -3156,9 +2566,8 @@ func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceCreateUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/bizdemo/kitex_gorm_gen/kitex_gen/user/user.go b/bizdemo/kitex_gorm_gen/kitex_gen/user/user.go index b18a5d72..ef643911 100644 --- a/bizdemo/kitex_gorm_gen/kitex_gen/user/user.go +++ b/bizdemo/kitex_gorm_gen/kitex_gen/user/user.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.2.12). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package user @@ -7,7 +7,7 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" ) @@ -118,7 +118,6 @@ func NewUser() *User { } func (p *User) InitDefault() { - *p = User{} } func (p *User) GetUserId() (v int64) { @@ -188,57 +187,46 @@ func (p *User) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -264,51 +252,63 @@ ReadStructEndError: } func (p *User) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *User) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *User) ReadField3(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *User) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *User) ReadField5(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *User) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("User"); err != nil { goto WriteStructBeginError @@ -334,7 +334,6 @@ func (p *User) Write(oprot thrift.TProtocol) (err error) { fieldId = 5 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -443,6 +442,7 @@ func (p *User) String() string { return "" } return fmt.Sprintf("User(%+v)", *p) + } func (p *User) DeepEqual(ano *User) bool { @@ -517,7 +517,6 @@ func NewCreateUserRequest() *CreateUserRequest { } func (p *CreateUserRequest) InitDefault() { - *p = CreateUserRequest{} } func (p *CreateUserRequest) GetName() (v string) { @@ -579,47 +578,38 @@ func (p *CreateUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -645,42 +635,52 @@ ReadStructEndError: } func (p *CreateUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *CreateUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *CreateUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *CreateUserRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUserRequest"); err != nil { goto WriteStructBeginError @@ -702,7 +702,6 @@ func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -794,6 +793,7 @@ func (p *CreateUserRequest) String() string { return "" } return fmt.Sprintf("CreateUserRequest(%+v)", *p) + } func (p *CreateUserRequest) DeepEqual(ano *CreateUserRequest) bool { @@ -856,7 +856,6 @@ func NewCreateUserResponse() *CreateUserResponse { } func (p *CreateUserResponse) InitDefault() { - *p = CreateUserResponse{} } func (p *CreateUserResponse) GetCode() (v Code) { @@ -902,27 +901,22 @@ func (p *CreateUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -948,24 +942,30 @@ ReadStructEndError: } func (p *CreateUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *CreateUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *CreateUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUserResponse"); err != nil { goto WriteStructBeginError @@ -979,7 +979,6 @@ func (p *CreateUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1037,6 +1036,7 @@ func (p *CreateUserResponse) String() string { return "" } return fmt.Sprintf("CreateUserResponse(%+v)", *p) + } func (p *CreateUserResponse) DeepEqual(ano *CreateUserResponse) bool { @@ -1080,7 +1080,6 @@ func NewQueryUserRequest() *QueryUserRequest { } func (p *QueryUserRequest) InitDefault() { - *p = QueryUserRequest{} } var QueryUserRequest_Keyword_DEFAULT string @@ -1143,37 +1142,30 @@ func (p *QueryUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1199,33 +1191,41 @@ ReadStructEndError: } func (p *QueryUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field *string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Keyword = &v + _field = &v } + p.Keyword = _field return nil } - func (p *QueryUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Page = v + _field = v } + p.Page = _field return nil } - func (p *QueryUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.PageSize = v + _field = v } + p.PageSize = _field return nil } func (p *QueryUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUserRequest"); err != nil { goto WriteStructBeginError @@ -1243,7 +1243,6 @@ func (p *QueryUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 3 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1320,6 +1319,7 @@ func (p *QueryUserRequest) String() string { return "" } return fmt.Sprintf("QueryUserRequest(%+v)", *p) + } func (p *QueryUserRequest) DeepEqual(ano *QueryUserRequest) bool { @@ -1379,7 +1379,6 @@ func NewQueryUserResponse() *QueryUserResponse { } func (p *QueryUserResponse) InitDefault() { - *p = QueryUserResponse{} } func (p *QueryUserResponse) GetCode() (v Code) { @@ -1441,47 +1440,38 @@ func (p *QueryUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -1507,53 +1497,64 @@ ReadStructEndError: } func (p *QueryUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *QueryUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } - func (p *QueryUserResponse) ReadField3(iprot thrift.TProtocol) error { _, size, err := iprot.ReadListBegin() if err != nil { return err } - p.Users = make([]*User, 0, size) + _field := make([]*User, 0, size) + values := make([]User, size) for i := 0; i < size; i++ { - _elem := NewUser() + _elem := &values[i] + _elem.InitDefault() + if err := _elem.Read(iprot); err != nil { return err } - p.Users = append(p.Users, _elem) + _field = append(_field, _elem) } if err := iprot.ReadListEnd(); err != nil { return err } + p.Users = _field return nil } - func (p *QueryUserResponse) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Totoal = v + _field = v } + p.Totoal = _field return nil } func (p *QueryUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUserResponse"); err != nil { goto WriteStructBeginError @@ -1575,7 +1576,6 @@ func (p *QueryUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1675,6 +1675,7 @@ func (p *QueryUserResponse) String() string { return "" } return fmt.Sprintf("QueryUserResponse(%+v)", *p) + } func (p *QueryUserResponse) DeepEqual(ano *QueryUserResponse) bool { @@ -1742,7 +1743,6 @@ func NewDeleteUserRequest() *DeleteUserRequest { } func (p *DeleteUserRequest) InitDefault() { - *p = DeleteUserRequest{} } func (p *DeleteUserRequest) GetUserId() (v int64) { @@ -1780,17 +1780,14 @@ func (p *DeleteUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1816,15 +1813,19 @@ ReadStructEndError: } func (p *DeleteUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } func (p *DeleteUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUserRequest"); err != nil { goto WriteStructBeginError @@ -1834,7 +1835,6 @@ func (p *DeleteUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1875,6 +1875,7 @@ func (p *DeleteUserRequest) String() string { return "" } return fmt.Sprintf("DeleteUserRequest(%+v)", *p) + } func (p *DeleteUserRequest) DeepEqual(ano *DeleteUserRequest) bool { @@ -1907,7 +1908,6 @@ func NewDeleteUserResponse() *DeleteUserResponse { } func (p *DeleteUserResponse) InitDefault() { - *p = DeleteUserResponse{} } func (p *DeleteUserResponse) GetCode() (v Code) { @@ -1953,27 +1953,22 @@ func (p *DeleteUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -1999,24 +1994,30 @@ ReadStructEndError: } func (p *DeleteUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *DeleteUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *DeleteUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUserResponse"); err != nil { goto WriteStructBeginError @@ -2030,7 +2031,6 @@ func (p *DeleteUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2088,6 +2088,7 @@ func (p *DeleteUserResponse) String() string { return "" } return fmt.Sprintf("DeleteUserResponse(%+v)", *p) + } func (p *DeleteUserResponse) DeepEqual(ano *DeleteUserResponse) bool { @@ -2133,7 +2134,6 @@ func NewUpdateUserRequest() *UpdateUserRequest { } func (p *UpdateUserRequest) InitDefault() { - *p = UpdateUserRequest{} } func (p *UpdateUserRequest) GetUserId() (v int64) { @@ -2203,57 +2203,46 @@ func (p *UpdateUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -2279,51 +2268,63 @@ ReadStructEndError: } func (p *UpdateUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *UpdateUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *UpdateUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *UpdateUserRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *UpdateUserRequest) ReadField5(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *UpdateUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUserRequest"); err != nil { goto WriteStructBeginError @@ -2349,7 +2350,6 @@ func (p *UpdateUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 5 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2458,6 +2458,7 @@ func (p *UpdateUserRequest) String() string { return "" } return fmt.Sprintf("UpdateUserRequest(%+v)", *p) + } func (p *UpdateUserRequest) DeepEqual(ano *UpdateUserRequest) bool { @@ -2530,7 +2531,6 @@ func NewUpdateUserResponse() *UpdateUserResponse { } func (p *UpdateUserResponse) InitDefault() { - *p = UpdateUserResponse{} } func (p *UpdateUserResponse) GetCode() (v Code) { @@ -2576,27 +2576,22 @@ func (p *UpdateUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -2622,24 +2617,30 @@ ReadStructEndError: } func (p *UpdateUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *UpdateUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *UpdateUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUserResponse"); err != nil { goto WriteStructBeginError @@ -2653,7 +2654,6 @@ func (p *UpdateUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2711,6 +2711,7 @@ func (p *UpdateUserResponse) String() string { return "" } return fmt.Sprintf("UpdateUserResponse(%+v)", *p) + } func (p *UpdateUserResponse) DeepEqual(ano *UpdateUserResponse) bool { @@ -2753,305 +2754,6 @@ type UserService interface { CreateUser(ctx context.Context, req *CreateUserRequest) (r *CreateUserResponse, err error) } -type UserServiceClient struct { - c thrift.TClient -} - -func NewUserServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *UserServiceClient { - return &UserServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewUserServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *UserServiceClient { - return &UserServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewUserServiceClient(c thrift.TClient) *UserServiceClient { - return &UserServiceClient{ - c: c, - } -} - -func (p *UserServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *UserServiceClient) UpdateUser(ctx context.Context, req *UpdateUserRequest) (r *UpdateUserResponse, err error) { - var _args UserServiceUpdateUserArgs - _args.Req = req - var _result UserServiceUpdateUserResult - if err = p.Client_().Call(ctx, "UpdateUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) DeleteUser(ctx context.Context, req *DeleteUserRequest) (r *DeleteUserResponse, err error) { - var _args UserServiceDeleteUserArgs - _args.Req = req - var _result UserServiceDeleteUserResult - if err = p.Client_().Call(ctx, "DeleteUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) QueryUser(ctx context.Context, req *QueryUserRequest) (r *QueryUserResponse, err error) { - var _args UserServiceQueryUserArgs - _args.Req = req - var _result UserServiceQueryUserResult - if err = p.Client_().Call(ctx, "QueryUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) CreateUser(ctx context.Context, req *CreateUserRequest) (r *CreateUserResponse, err error) { - var _args UserServiceCreateUserArgs - _args.Req = req - var _result UserServiceCreateUserResult - if err = p.Client_().Call(ctx, "CreateUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type UserServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler UserService -} - -func (p *UserServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *UserServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *UserServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewUserServiceProcessor(handler UserService) *UserServiceProcessor { - self := &UserServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("UpdateUser", &userServiceProcessorUpdateUser{handler: handler}) - self.AddToProcessorMap("DeleteUser", &userServiceProcessorDeleteUser{handler: handler}) - self.AddToProcessorMap("QueryUser", &userServiceProcessorQueryUser{handler: handler}) - self.AddToProcessorMap("CreateUser", &userServiceProcessorCreateUser{handler: handler}) - return self -} -func (p *UserServiceProcessor) 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 userServiceProcessorUpdateUser struct { - handler UserService -} - -func (p *userServiceProcessorUpdateUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceUpdateUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("UpdateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceUpdateUserResult{} - var retval *UpdateUserResponse - if retval, err2 = p.handler.UpdateUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing UpdateUser: "+err2.Error()) - oprot.WriteMessageBegin("UpdateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("UpdateUser", 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 userServiceProcessorDeleteUser struct { - handler UserService -} - -func (p *userServiceProcessorDeleteUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceDeleteUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("DeleteUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceDeleteUserResult{} - var retval *DeleteUserResponse - if retval, err2 = p.handler.DeleteUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing DeleteUser: "+err2.Error()) - oprot.WriteMessageBegin("DeleteUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("DeleteUser", 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 userServiceProcessorQueryUser struct { - handler UserService -} - -func (p *userServiceProcessorQueryUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceQueryUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("QueryUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceQueryUserResult{} - var retval *QueryUserResponse - if retval, err2 = p.handler.QueryUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing QueryUser: "+err2.Error()) - oprot.WriteMessageBegin("QueryUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("QueryUser", 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 userServiceProcessorCreateUser struct { - handler UserService -} - -func (p *userServiceProcessorCreateUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceCreateUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("CreateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceCreateUserResult{} - var retval *CreateUserResponse - if retval, err2 = p.handler.CreateUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing CreateUser: "+err2.Error()) - oprot.WriteMessageBegin("CreateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("CreateUser", 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 UserServiceUpdateUserArgs struct { Req *UpdateUserRequest `thrift:"req,1" frugal:"1,default,UpdateUserRequest" json:"req"` } @@ -3061,7 +2763,6 @@ func NewUserServiceUpdateUserArgs() *UserServiceUpdateUserArgs { } func (p *UserServiceUpdateUserArgs) InitDefault() { - *p = UserServiceUpdateUserArgs{} } var UserServiceUpdateUserArgs_Req_DEFAULT *UpdateUserRequest @@ -3108,17 +2809,14 @@ func (p *UserServiceUpdateUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3144,14 +2842,16 @@ ReadStructEndError: } func (p *UserServiceUpdateUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewUpdateUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewUpdateUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceUpdateUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUser_args"); err != nil { goto WriteStructBeginError @@ -3161,7 +2861,6 @@ func (p *UserServiceUpdateUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3202,6 +2901,7 @@ func (p *UserServiceUpdateUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceUpdateUserArgs(%+v)", *p) + } func (p *UserServiceUpdateUserArgs) DeepEqual(ano *UserServiceUpdateUserArgs) bool { @@ -3233,7 +2933,6 @@ func NewUserServiceUpdateUserResult() *UserServiceUpdateUserResult { } func (p *UserServiceUpdateUserResult) InitDefault() { - *p = UserServiceUpdateUserResult{} } var UserServiceUpdateUserResult_Success_DEFAULT *UpdateUserResponse @@ -3280,17 +2979,14 @@ func (p *UserServiceUpdateUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3316,14 +3012,16 @@ ReadStructEndError: } func (p *UserServiceUpdateUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewUpdateUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewUpdateUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceUpdateUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUser_result"); err != nil { goto WriteStructBeginError @@ -3333,7 +3031,6 @@ func (p *UserServiceUpdateUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3376,6 +3073,7 @@ func (p *UserServiceUpdateUserResult) String() string { return "" } return fmt.Sprintf("UserServiceUpdateUserResult(%+v)", *p) + } func (p *UserServiceUpdateUserResult) DeepEqual(ano *UserServiceUpdateUserResult) bool { @@ -3407,7 +3105,6 @@ func NewUserServiceDeleteUserArgs() *UserServiceDeleteUserArgs { } func (p *UserServiceDeleteUserArgs) InitDefault() { - *p = UserServiceDeleteUserArgs{} } var UserServiceDeleteUserArgs_Req_DEFAULT *DeleteUserRequest @@ -3454,17 +3151,14 @@ func (p *UserServiceDeleteUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3490,14 +3184,16 @@ ReadStructEndError: } func (p *UserServiceDeleteUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewDeleteUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewDeleteUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceDeleteUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUser_args"); err != nil { goto WriteStructBeginError @@ -3507,7 +3203,6 @@ func (p *UserServiceDeleteUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3548,6 +3243,7 @@ func (p *UserServiceDeleteUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceDeleteUserArgs(%+v)", *p) + } func (p *UserServiceDeleteUserArgs) DeepEqual(ano *UserServiceDeleteUserArgs) bool { @@ -3579,7 +3275,6 @@ func NewUserServiceDeleteUserResult() *UserServiceDeleteUserResult { } func (p *UserServiceDeleteUserResult) InitDefault() { - *p = UserServiceDeleteUserResult{} } var UserServiceDeleteUserResult_Success_DEFAULT *DeleteUserResponse @@ -3626,17 +3321,14 @@ func (p *UserServiceDeleteUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3662,14 +3354,16 @@ ReadStructEndError: } func (p *UserServiceDeleteUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewDeleteUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewDeleteUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceDeleteUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUser_result"); err != nil { goto WriteStructBeginError @@ -3679,7 +3373,6 @@ func (p *UserServiceDeleteUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3722,6 +3415,7 @@ func (p *UserServiceDeleteUserResult) String() string { return "" } return fmt.Sprintf("UserServiceDeleteUserResult(%+v)", *p) + } func (p *UserServiceDeleteUserResult) DeepEqual(ano *UserServiceDeleteUserResult) bool { @@ -3753,7 +3447,6 @@ func NewUserServiceQueryUserArgs() *UserServiceQueryUserArgs { } func (p *UserServiceQueryUserArgs) InitDefault() { - *p = UserServiceQueryUserArgs{} } var UserServiceQueryUserArgs_Req_DEFAULT *QueryUserRequest @@ -3800,17 +3493,14 @@ func (p *UserServiceQueryUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3836,14 +3526,16 @@ ReadStructEndError: } func (p *UserServiceQueryUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewQueryUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewQueryUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceQueryUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUser_args"); err != nil { goto WriteStructBeginError @@ -3853,7 +3545,6 @@ func (p *UserServiceQueryUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3894,6 +3585,7 @@ func (p *UserServiceQueryUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceQueryUserArgs(%+v)", *p) + } func (p *UserServiceQueryUserArgs) DeepEqual(ano *UserServiceQueryUserArgs) bool { @@ -3925,7 +3617,6 @@ func NewUserServiceQueryUserResult() *UserServiceQueryUserResult { } func (p *UserServiceQueryUserResult) InitDefault() { - *p = UserServiceQueryUserResult{} } var UserServiceQueryUserResult_Success_DEFAULT *QueryUserResponse @@ -3972,17 +3663,14 @@ func (p *UserServiceQueryUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4008,14 +3696,16 @@ ReadStructEndError: } func (p *UserServiceQueryUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewQueryUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewQueryUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceQueryUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUser_result"); err != nil { goto WriteStructBeginError @@ -4025,7 +3715,6 @@ func (p *UserServiceQueryUserResult) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4068,6 +3757,7 @@ func (p *UserServiceQueryUserResult) String() string { return "" } return fmt.Sprintf("UserServiceQueryUserResult(%+v)", *p) + } func (p *UserServiceQueryUserResult) DeepEqual(ano *UserServiceQueryUserResult) bool { @@ -4099,7 +3789,6 @@ func NewUserServiceCreateUserArgs() *UserServiceCreateUserArgs { } func (p *UserServiceCreateUserArgs) InitDefault() { - *p = UserServiceCreateUserArgs{} } var UserServiceCreateUserArgs_Req_DEFAULT *CreateUserRequest @@ -4146,17 +3835,14 @@ func (p *UserServiceCreateUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4182,14 +3868,16 @@ ReadStructEndError: } func (p *UserServiceCreateUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewCreateUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewCreateUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceCreateUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUser_args"); err != nil { goto WriteStructBeginError @@ -4199,7 +3887,6 @@ func (p *UserServiceCreateUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4240,6 +3927,7 @@ func (p *UserServiceCreateUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceCreateUserArgs(%+v)", *p) + } func (p *UserServiceCreateUserArgs) DeepEqual(ano *UserServiceCreateUserArgs) bool { @@ -4271,7 +3959,6 @@ func NewUserServiceCreateUserResult() *UserServiceCreateUserResult { } func (p *UserServiceCreateUserResult) InitDefault() { - *p = UserServiceCreateUserResult{} } var UserServiceCreateUserResult_Success_DEFAULT *CreateUserResponse @@ -4318,17 +4005,14 @@ func (p *UserServiceCreateUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4354,14 +4038,16 @@ ReadStructEndError: } func (p *UserServiceCreateUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewCreateUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewCreateUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceCreateUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUser_result"); err != nil { goto WriteStructBeginError @@ -4371,7 +4057,6 @@ func (p *UserServiceCreateUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4414,6 +4099,7 @@ func (p *UserServiceCreateUserResult) String() string { return "" } return fmt.Sprintf("UserServiceCreateUserResult(%+v)", *p) + } func (p *UserServiceCreateUserResult) DeepEqual(ano *UserServiceCreateUserResult) bool { diff --git a/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/client.go b/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/client.go index f8d3efca..146c6f8b 100644 --- a/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/client.go +++ b/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice @@ -24,7 +24,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/server.go b/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/server.go index 00ca9a6f..20a16876 100644 --- a/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/server.go +++ b/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( @@ -11,6 +11,7 @@ func NewServer(handler user.UserService, opts ...server.Option) server.Server { var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler user.UserService, opts ...server.Option) server.Server { } return svr } + +func RegisterService(svr server.Server, handler user.UserService, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/userservice.go b/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/userservice.go index a9f6d005..8bcc21cf 100644 --- a/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/userservice.go +++ b/bizdemo/kitex_gorm_gen/kitex_gen/user/userservice/userservice.go @@ -1,39 +1,107 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( "context" + "errors" user "github.com/cloudwego/kitex-examples/bizdemo/kitex_gorm_gen/kitex_gen/user" client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "UpdateUser": kitex.NewMethodInfo( + updateUserHandler, + newUserServiceUpdateUserArgs, + newUserServiceUpdateUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "DeleteUser": kitex.NewMethodInfo( + deleteUserHandler, + newUserServiceDeleteUserArgs, + newUserServiceDeleteUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "QueryUser": kitex.NewMethodInfo( + queryUserHandler, + newUserServiceQueryUserArgs, + newUserServiceQueryUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "CreateUser": kitex.NewMethodInfo( + createUserHandler, + newUserServiceCreateUserArgs, + newUserServiceCreateUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + userServiceServiceInfo = NewServiceInfo() + userServiceServiceInfoForClient = NewServiceInfoForClient() + userServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return userServiceServiceInfo } -var userServiceServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return userServiceServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return userServiceServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "UserService" handlerType := (*user.UserService)(nil) - methods := map[string]kitex.MethodInfo{ - "UpdateUser": kitex.NewMethodInfo(updateUserHandler, newUserServiceUpdateUserArgs, newUserServiceUpdateUserResult, false), - "DeleteUser": kitex.NewMethodInfo(deleteUserHandler, newUserServiceDeleteUserArgs, newUserServiceDeleteUserResult, false), - "QueryUser": kitex.NewMethodInfo(queryUserHandler, newUserServiceQueryUserArgs, newUserServiceQueryUserResult, false), - "CreateUser": kitex.NewMethodInfo(createUserHandler, newUserServiceCreateUserArgs, newUserServiceCreateUserResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ - "PackageName": "user", - "ServiceFilePath": `idl/user.thrift`, + "PackageName": "user", + } + if hasStreaming { + extra["streaming"] = hasStreaming } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/bizdemo/kitex_swagger_gen/go.mod b/bizdemo/kitex_swagger_gen/go.mod index 06854d3b..c321f893 100644 --- a/bizdemo/kitex_swagger_gen/go.mod +++ b/bizdemo/kitex_swagger_gen/go.mod @@ -5,10 +5,11 @@ go 1.21 replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 require ( - github.com/apache/thrift v0.13.0 github.com/bytedance/gopkg v0.1.1 + github.com/cloudwego/gopkg v0.1.3 github.com/cloudwego/hertz v0.9.3 - github.com/cloudwego/kitex v0.11.3 + github.com/cloudwego/kitex v0.12.0 + github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 github.com/hertz-contrib/cors v0.1.0 github.com/hertz-contrib/swagger v0.1.0 github.com/swaggo/files v1.0.1 @@ -18,20 +19,20 @@ require ( require ( github.com/KyleBanks/depth v1.2.1 // indirect + github.com/apache/thrift v0.13.0 // indirect github.com/bytedance/go-tagexpr/v2 v2.9.2 // indirect - github.com/bytedance/sonic v1.12.2 // indirect + github.com/bytedance/sonic v1.12.5 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/configmanager v0.2.2 // indirect - github.com/cloudwego/dynamicgo v0.4.0 // indirect + github.com/cloudwego/dynamicgo v0.4.6 // indirect github.com/cloudwego/fastpb v0.0.5 // indirect - github.com/cloudwego/frugal v0.2.0 // indirect - github.com/cloudwego/gopkg v0.1.2 // indirect + github.com/cloudwego/frugal v0.2.3 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cloudwego/localsession v0.0.2 // indirect - github.com/cloudwego/netpoll v0.6.4 // indirect + github.com/cloudwego/localsession v0.1.1 // indirect + github.com/cloudwego/netpoll v0.6.5 // indirect github.com/cloudwego/runtimex v0.1.0 // indirect - github.com/cloudwego/thriftgo v0.3.17 // indirect + github.com/cloudwego/thriftgo v0.3.18 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect @@ -40,7 +41,7 @@ require ( github.com/go-openapi/spec v0.20.9 // indirect github.com/go-openapi/swag v0.22.4 // indirect github.com/go-sql-driver/mysql v1.7.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect github.com/henrylee2cn/ameda v1.4.10 // indirect github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 // indirect @@ -70,6 +71,6 @@ require ( golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.11.0 // indirect google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/bizdemo/kitex_swagger_gen/go.sum b/bizdemo/kitex_swagger_gen/go.sum index ebf2147c..9ccb7352 100644 --- a/bizdemo/kitex_swagger_gen/go.sum +++ b/bizdemo/kitex_swagger_gen/go.sum @@ -17,8 +17,8 @@ github.com/bytedance/mockey v1.2.12/go.mod h1:3ZA4MQasmqC87Tw0w7Ygdy7eHIc2xgpZ8P github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.8.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic v1.12.2 h1:oaMFuRTpMHYLpCntGca65YWt5ny+wAceDERTkT2L9lg= -github.com/bytedance/sonic v1.12.2/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= +github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= @@ -30,32 +30,32 @@ 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/configmanager v0.2.2 h1:sVrJB8gWYTlPV2OS3wcgJSO9F2/9Zbkmcm1Z7jempOU= github.com/cloudwego/configmanager v0.2.2/go.mod h1:ppiyU+5TPLonE8qMVi/pFQk2eL3Q4P7d4hbiNJn6jwI= -github.com/cloudwego/dynamicgo v0.4.0 h1:wQqNRNiSQaLkbcn3sfpEJGZsz3xf8Il4P/3DcENsrFI= -github.com/cloudwego/dynamicgo v0.4.0/go.mod h1:zgWk2oz56EyH790LJSxrTz1j01GJBO964jJQ/y7qjJc= +github.com/cloudwego/dynamicgo v0.4.6 h1:raRdvLN1WsGl5WsNd2Ul86s8PFQPu8soF4ALSJ9MdC4= +github.com/cloudwego/dynamicgo v0.4.6/go.mod h1:DknfxjIMuGvXow409bS/AWycXONdc02HECBL0qpNqTY= github.com/cloudwego/fastpb v0.0.5 h1:vYnBPsfbAtU5TVz5+f9UTlmSCixG9F9vRwaqE0mZPZU= github.com/cloudwego/fastpb v0.0.5/go.mod h1:Bho7aAKBUtT9RPD2cNVkTdx4yQumfSv3If7wYnm1izk= -github.com/cloudwego/frugal v0.2.0 h1:0ETSzQYoYqVvdl7EKjqJ9aJnDoG6TzvNKV3PMQiQTS8= -github.com/cloudwego/frugal v0.2.0/go.mod h1:cpnV6kdRMjN3ylxRo63RNbZ9rBK6oxs70Zk6QZ4Enj4= -github.com/cloudwego/gopkg v0.1.2 h1:650t+RiZGht8qX+y0hl49JXJCuO44GhbGZuxDzr2PyI= -github.com/cloudwego/gopkg v0.1.2/go.mod h1:WoNTdXDPdvL97cBmRUWXVGkh2l2UFmpd9BUvbW2r0Aw= +github.com/cloudwego/frugal v0.2.3 h1:t1hhhAi8lXcx7Ncs4PR1pSZ90vlDU1cy5K2btDMFpoA= +github.com/cloudwego/frugal v0.2.3/go.mod h1:nC1U47gswLRiaxv6dybrhZvsDGCfQP9RGiiWC73CnoI= +github.com/cloudwego/gopkg v0.1.3 h1:y9VA5Zn5yqd1+QBV9aB0Zxy56JlAS7x4ZUoED/vJdxA= +github.com/cloudwego/gopkg v0.1.3/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= github.com/cloudwego/hertz v0.6.2/go.mod h1:2em2hGREvCBawsTQcQxyWBGVlCeo+N1pp2q0HkkbwR0= github.com/cloudwego/hertz v0.9.3 h1:uajvLn6LjEPjUqN/ewUZtWoRQWa2es2XTELdqDlOYMw= github.com/cloudwego/hertz v0.9.3/go.mod h1:gGVUfJU/BOkJv/ZTzrw7FS7uy7171JeYIZvAyV3wS3o= 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.11.3 h1:Qy1GtyuNbygMpwnMw+Aj1iS7fSd0IO7CzxtpZrRJ+Jc= -github.com/cloudwego/kitex v0.11.3/go.mod h1:RHT9ERKFVppJjBfGvwJAPxCIzf4oN1yASW5S4pPZNu4= -github.com/cloudwego/kitex-examples/bizdemo/kitex_gorm v0.0.0-20240917060902-d739c15185ba h1:0r/xgvhuYO4jx/xePlZyrOIWIdYVnIphRWlzWjzw2jY= -github.com/cloudwego/kitex-examples/bizdemo/kitex_gorm v0.0.0-20240917060902-d739c15185ba/go.mod h1:W0P1BI8fVJsksLXU9+eRoe14atfo3ztZcbH8DqZvlEg= -github.com/cloudwego/localsession v0.0.2 h1:N9/IDtCPj1fCL9bCTP+DbXx3f40YjVYWcwkJG0YhQkY= -github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= +github.com/cloudwego/kitex v0.12.0 h1:TeNlAAkWc3MOIGnBQj+FcSUBan+3TBpzitnrviH0AXM= +github.com/cloudwego/kitex v0.12.0/go.mod h1:k2wQJ+3LPjQJHbBs0xE2k6z8SVRcUpB3/eRO34oM0nQ= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 h1:jU6gpAkJ3HZLZeSpxrL1xaCd/auvAbLs0SN/ylXn9TA= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2/go.mod h1:OP63V8YwwSlPVFqHZblV3mJXLPIjcIdwkT6ZYjEggcI= +github.com/cloudwego/localsession v0.1.1 h1:tbK7laDVrYfFDXoBXo4uCGMAxU4qmz2dDm8d4BGBnDo= +github.com/cloudwego/localsession v0.1.1/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= github.com/cloudwego/netpoll v0.3.1/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= -github.com/cloudwego/netpoll v0.6.4 h1:z/dA4sOTUQof6zZIO4QNnLBXsDFFFEos9OOGloR6kno= -github.com/cloudwego/netpoll v0.6.4/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= +github.com/cloudwego/netpoll v0.6.5 h1:6E/BWhSzQoyLg9Kx/4xiMdIIpovzwBtXvuqSqaTUzDQ= +github.com/cloudwego/netpoll v0.6.5/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= 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.17 h1:k0iQe2jEAN1WhPsXWvatwHzoxObUSX2Nw5NqdnywS8k= -github.com/cloudwego/thriftgo v0.3.17/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= +github.com/cloudwego/thriftgo v0.3.18 h1:gnr1vz7G3RbwwCK9AMKHZf63VYGa7ene6WbI9VrBJSw= +github.com/cloudwego/thriftgo v0.3.18/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -102,8 +102,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -149,8 +150,11 @@ github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8t github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -171,6 +175,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= 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= @@ -329,8 +335,8 @@ google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX7 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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/bizdemo/kitex_swagger_gen/kitex_gen/openapi/k-openapi.go b/bizdemo/kitex_swagger_gen/kitex_gen/openapi/k-openapi.go index 243f78b2..56c9326d 100644 --- a/bizdemo/kitex_swagger_gen/kitex_gen/openapi/k-openapi.go +++ b/bizdemo/kitex_swagger_gen/kitex_gen/openapi/k-openapi.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.10.3. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package openapi @@ -8,8 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -18,25 +17,19 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *__ServiceOptions) FastRead(buf []byte) (int, error) { + var err error var offset int var l int var fieldTypeId thrift.TType var fieldId int16 var issetDocument 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -54,30 +47,19 @@ func (p *__ServiceOptions) FastRead(buf []byte) (int, error) { } issetDocument = true } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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 !issetDocument { @@ -85,20 +67,14 @@ func (p *__ServiceOptions) FastRead(buf []byte) (int, error) { 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___ServiceOptions[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___ServiceOptions[fieldId])) + return offset, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName___ServiceOptions[fieldId])) } func (p *__ServiceOptions) FastReadField1(buf []byte) (int, error) { @@ -113,64 +89,52 @@ func (p *__ServiceOptions) FastReadField1(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *__ServiceOptions) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *__ServiceOptions) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__ServiceOptions) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "_ServiceOptions") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *__ServiceOptions) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("_ServiceOptions") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *__ServiceOptions) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__ServiceOptions) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "document", thrift.STRUCT, 1) - offset += p.Document.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Document.FastWriteNocopy(buf[offset:], w) return offset } func (p *__ServiceOptions) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("document", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Document.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *__StructOptions) FastRead(buf []byte) (int, error) { + var err error var offset int var l int var fieldTypeId thrift.TType var fieldId int16 var issetSchema 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -188,30 +152,19 @@ func (p *__StructOptions) FastRead(buf []byte) (int, error) { } issetSchema = true } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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 !issetSchema { @@ -219,20 +172,14 @@ func (p *__StructOptions) FastRead(buf []byte) (int, error) { 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___StructOptions[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___StructOptions[fieldId])) + return offset, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName___StructOptions[fieldId])) } func (p *__StructOptions) FastReadField1(buf []byte) (int, error) { @@ -247,64 +194,52 @@ func (p *__StructOptions) FastReadField1(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *__StructOptions) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *__StructOptions) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__StructOptions) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "_StructOptions") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *__StructOptions) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("_StructOptions") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *__StructOptions) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__StructOptions) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "schema", thrift.STRUCT, 1) - offset += p.Schema.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Schema.FastWriteNocopy(buf[offset:], w) return offset } func (p *__StructOptions) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("schema", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Schema.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *__MethodOptions) FastRead(buf []byte) (int, error) { + var err error var offset int var l int var fieldTypeId thrift.TType var fieldId int16 var issetOperation 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -322,30 +257,19 @@ func (p *__MethodOptions) FastRead(buf []byte) (int, error) { } issetOperation = true } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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 !issetOperation { @@ -353,20 +277,14 @@ func (p *__MethodOptions) FastRead(buf []byte) (int, error) { 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___MethodOptions[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___MethodOptions[fieldId])) + return offset, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName___MethodOptions[fieldId])) } func (p *__MethodOptions) FastReadField1(buf []byte) (int, error) { @@ -381,50 +299,44 @@ func (p *__MethodOptions) FastReadField1(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *__MethodOptions) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *__MethodOptions) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__MethodOptions) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "_MethodOptions") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *__MethodOptions) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("_MethodOptions") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *__MethodOptions) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__MethodOptions) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "operation", thrift.STRUCT, 1) - offset += p.Operation.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Operation.FastWriteNocopy(buf[offset:], w) return offset } func (p *__MethodOptions) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("operation", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Operation.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *__FieldOptions) FastRead(buf []byte) (int, error) { + var err error var offset int var l int @@ -432,14 +344,8 @@ func (p *__FieldOptions) FastRead(buf []byte) (int, error) { var fieldId int16 var issetParameter bool = false var issetProperty 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -457,7 +363,7 @@ func (p *__FieldOptions) FastRead(buf []byte) (int, error) { } issetParameter = true } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -472,30 +378,19 @@ func (p *__FieldOptions) FastRead(buf []byte) (int, error) { } issetProperty = true } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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 !issetParameter { @@ -508,20 +403,14 @@ func (p *__FieldOptions) FastRead(buf []byte) (int, error) { 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___FieldOptions[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___FieldOptions[fieldId])) + return offset, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName___FieldOptions[fieldId])) } func (p *__FieldOptions) FastReadField1(buf []byte) (int, error) { @@ -548,81 +437,67 @@ func (p *__FieldOptions) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *__FieldOptions) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *__FieldOptions) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__FieldOptions) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "_FieldOptions") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *__FieldOptions) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("_FieldOptions") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *__FieldOptions) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__FieldOptions) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "parameter", thrift.STRUCT, 1) - offset += p.Parameter.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Parameter.FastWriteNocopy(buf[offset:], w) return offset } -func (p *__FieldOptions) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__FieldOptions) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "property", thrift.STRUCT, 2) - offset += p.Property.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Property.FastWriteNocopy(buf[offset:], w) return offset } func (p *__FieldOptions) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("parameter", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Parameter.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *__FieldOptions) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("property", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Property.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *AdditionalPropertiesItem) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -639,7 +514,7 @@ func (p *AdditionalPropertiesItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -653,45 +528,28 @@ func (p *AdditionalPropertiesItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_AdditionalPropertiesItem[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 *AdditionalPropertiesItem) FastReadField1(buf []byte) (int, error) { @@ -710,93 +568,77 @@ func (p *AdditionalPropertiesItem) FastReadField2(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Boolean = _field return offset, nil } -// for compatibility func (p *AdditionalPropertiesItem) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *AdditionalPropertiesItem) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *AdditionalPropertiesItem) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "AdditionalPropertiesItem") if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *AdditionalPropertiesItem) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("AdditionalPropertiesItem") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *AdditionalPropertiesItem) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *AdditionalPropertiesItem) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "schema_or_reference", thrift.STRUCT, 1) - offset += p.SchemaOrReference.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.SchemaOrReference.FastWriteNocopy(buf[offset:], w) return offset } -func (p *AdditionalPropertiesItem) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *AdditionalPropertiesItem) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "boolean", thrift.BOOL, 2) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Boolean) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 2) + offset += thrift.Binary.WriteBool(buf[offset:], p.Boolean) return offset } func (p *AdditionalPropertiesItem) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("schema_or_reference", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.SchemaOrReference.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *AdditionalPropertiesItem) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("boolean", thrift.BOOL, 2) - l += bthrift.Binary.BoolLength(p.Boolean) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Any) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -813,7 +655,7 @@ func (p *Any) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -827,45 +669,28 @@ func (p *Any) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Any[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 *Any) FastReadField1(buf []byte) (int, error) { @@ -884,93 +709,77 @@ func (p *Any) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Yaml = _field return offset, nil } -// for compatibility func (p *Any) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Any) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Any) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Any") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Any) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Any") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Any) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Any) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 1) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Any) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Any) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "yaml", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Yaml) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Yaml) return offset } func (p *Any) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Any) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("yaml", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Yaml) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Yaml) return l } func (p *__Any) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -987,7 +796,7 @@ func (p *__Any) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1001,58 +810,39 @@ func (p *__Any) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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___Any[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 *__Any) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.TypeUrl = _field return offset, nil @@ -1062,93 +852,78 @@ func (p *__Any) FastReadField2(buf []byte) (int, error) { offset := 0 var _field []byte - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBinary(buf[offset:]); err != nil { return offset, err } else { offset += l _field = []byte(v) - } p.Value = _field return offset, nil } -// for compatibility func (p *__Any) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *__Any) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__Any) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "_Any") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *__Any) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("_Any") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *__Any) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__Any) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "type_url", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.TypeUrl) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.TypeUrl) return offset } -func (p *__Any) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *__Any) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRING, 2) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Value)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteBinaryNocopy(buf[offset:], w, []byte(p.Value)) return offset } func (p *__Any) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("type_url", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.TypeUrl) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.TypeUrl) return l } func (p *__Any) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRING, 2) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Value)) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BinaryLengthNocopy([]byte(p.Value)) return l } func (p *AnyOrExpression) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1165,7 +940,7 @@ func (p *AnyOrExpression) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1179,45 +954,28 @@ func (p *AnyOrExpression) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_AnyOrExpression[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 *AnyOrExpression) FastReadField1(buf []byte) (int, error) { @@ -1244,81 +1002,67 @@ func (p *AnyOrExpression) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *AnyOrExpression) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *AnyOrExpression) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *AnyOrExpression) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "AnyOrExpression") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *AnyOrExpression) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("AnyOrExpression") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *AnyOrExpression) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *AnyOrExpression) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "any", thrift.STRUCT, 1) - offset += p.Any.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Any.FastWriteNocopy(buf[offset:], w) return offset } -func (p *AnyOrExpression) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *AnyOrExpression) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "expression", thrift.STRUCT, 2) - offset += p.Expression.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Expression.FastWriteNocopy(buf[offset:], w) return offset } func (p *AnyOrExpression) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("any", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Any.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *AnyOrExpression) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("expression", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Expression.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Callback) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1335,7 +1079,7 @@ func (p *Callback) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1349,51 +1093,34 @@ func (p *Callback) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Callback[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 *Callback) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -1411,11 +1138,6 @@ func (p *Callback) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Path = _field return offset, nil } @@ -1423,7 +1145,7 @@ func (p *Callback) FastReadField1(buf []byte) (int, error) { func (p *Callback) FastReadField2(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -1441,114 +1163,93 @@ func (p *Callback) FastReadField2(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Callback) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Callback) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Callback) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Callback") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Callback) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Callback") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Callback) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Callback) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "path", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Path { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Callback) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Callback) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 2) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 2) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Callback) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("path", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Path)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Path { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Callback) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 2) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *CallbackOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1565,7 +1266,7 @@ func (p *CallbackOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1579,45 +1280,28 @@ func (p *CallbackOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CallbackOrReference[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 *CallbackOrReference) FastReadField1(buf []byte) (int, error) { @@ -1644,81 +1328,67 @@ func (p *CallbackOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *CallbackOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CallbackOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CallbackOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CallbackOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CallbackOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CallbackOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CallbackOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CallbackOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "callback", thrift.STRUCT, 1) - offset += p.Callback.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Callback.FastWriteNocopy(buf[offset:], w) return offset } -func (p *CallbackOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CallbackOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "reference", thrift.STRUCT, 2) - offset += p.Reference.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Reference.FastWriteNocopy(buf[offset:], w) return offset } func (p *CallbackOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("callback", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Callback.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *CallbackOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("reference", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Reference.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *CallbacksOrReferences) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1735,51 +1405,34 @@ func (p *CallbacksOrReferences) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CallbacksOrReferences[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 *CallbacksOrReferences) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -1797,84 +1450,66 @@ func (p *CallbacksOrReferences) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *CallbacksOrReferences) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CallbacksOrReferences) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CallbacksOrReferences) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CallbacksOrReferences") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CallbacksOrReferences) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CallbacksOrReferences") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CallbacksOrReferences) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CallbacksOrReferences) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *CallbacksOrReferences) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Components) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1891,7 +1526,7 @@ func (p *Components) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1905,7 +1540,7 @@ func (p *Components) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1919,7 +1554,7 @@ func (p *Components) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1933,7 +1568,7 @@ func (p *Components) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1947,7 +1582,7 @@ func (p *Components) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1961,7 +1596,7 @@ func (p *Components) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1975,7 +1610,7 @@ func (p *Components) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1989,7 +1624,7 @@ func (p *Components) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2003,7 +1638,7 @@ func (p *Components) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2017,45 +1652,28 @@ func (p *Components) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Components[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 *Components) FastReadField1(buf []byte) (int, error) { @@ -2169,7 +1787,7 @@ func (p *Components) FastReadField9(buf []byte) (int, error) { func (p *Components) FastReadField10(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -2187,43 +1805,34 @@ func (p *Components) FastReadField10(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Components) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Components) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Components") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField8(buf[offset:], w) + offset += p.fastWriteField9(buf[offset:], w) + offset += p.fastWriteField10(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Components) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Components") if p != nil { l += p.field1Length() l += p.field2Length() @@ -2236,197 +1845,170 @@ func (p *Components) BLength() int { l += p.field9Length() l += p.field10Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Components) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "schemas", thrift.STRUCT, 1) - offset += p.Schemas.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Schemas.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Components) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "responses", thrift.STRUCT, 2) - offset += p.Responses.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Responses.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Components) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "parameters", thrift.STRUCT, 3) - offset += p.Parameters.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 3) + offset += p.Parameters.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Components) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "examples", thrift.STRUCT, 4) - offset += p.Examples.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 4) + offset += p.Examples.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Components) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "request_bodies", thrift.STRUCT, 5) - offset += p.RequestBodies.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 5) + offset += p.RequestBodies.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Components) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "headers", thrift.STRUCT, 6) - offset += p.Headers.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 6) + offset += p.Headers.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Components) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "security_schemes", thrift.STRUCT, 7) - offset += p.SecuritySchemes.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 7) + offset += p.SecuritySchemes.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Components) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) fastWriteField8(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "links", thrift.STRUCT, 8) - offset += p.Links.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 8) + offset += p.Links.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Components) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) fastWriteField9(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "callbacks", thrift.STRUCT, 9) - offset += p.Callbacks.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 9) + offset += p.Callbacks.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Components) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Components) fastWriteField10(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 10) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 10) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Components) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("schemas", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Schemas.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Components) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("responses", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Responses.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Components) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("parameters", thrift.STRUCT, 3) + l += thrift.Binary.FieldBeginLength() l += p.Parameters.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Components) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("examples", thrift.STRUCT, 4) + l += thrift.Binary.FieldBeginLength() l += p.Examples.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Components) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("request_bodies", thrift.STRUCT, 5) + l += thrift.Binary.FieldBeginLength() l += p.RequestBodies.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Components) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("headers", thrift.STRUCT, 6) + l += thrift.Binary.FieldBeginLength() l += p.Headers.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Components) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("security_schemes", thrift.STRUCT, 7) + l += thrift.Binary.FieldBeginLength() l += p.SecuritySchemes.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Components) field8Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("links", thrift.STRUCT, 8) + l += thrift.Binary.FieldBeginLength() l += p.Links.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Components) field9Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("callbacks", thrift.STRUCT, 9) + l += thrift.Binary.FieldBeginLength() l += p.Callbacks.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Components) field10Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 10) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Contact) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2443,7 +2025,7 @@ func (p *Contact) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2457,7 +2039,7 @@ func (p *Contact) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2471,7 +2053,7 @@ func (p *Contact) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2485,58 +2067,39 @@ func (p *Contact) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Contact[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 *Contact) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -2546,13 +2109,11 @@ func (p *Contact) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Url = _field return offset, nil @@ -2562,13 +2123,11 @@ func (p *Contact) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Email = _field return offset, nil @@ -2577,7 +2136,7 @@ func (p *Contact) FastReadField3(buf []byte) (int, error) { func (p *Contact) FastReadField4(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -2595,138 +2154,114 @@ func (p *Contact) FastReadField4(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Contact) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Contact) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Contact) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Contact") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Contact) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Contact") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Contact) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Contact) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *Contact) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Contact) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "url", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Url) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Url) return offset } -func (p *Contact) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Contact) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "email", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Email) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Email) return offset } -func (p *Contact) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Contact) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 4) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 4) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Contact) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *Contact) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("url", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Url) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Url) return l } func (p *Contact) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("email", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Email) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Email) return l } func (p *Contact) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 4) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *DefaultType) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2743,7 +2278,7 @@ func (p *DefaultType) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2757,7 +2292,7 @@ func (p *DefaultType) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2771,58 +2306,39 @@ func (p *DefaultType) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DefaultType[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 *DefaultType) FastReadField1(buf []byte) (int, error) { offset := 0 var _field float64 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadDouble(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Number = _field return offset, nil @@ -2832,13 +2348,11 @@ func (p *DefaultType) FastReadField2(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Boolean = _field return offset, nil @@ -2848,111 +2362,93 @@ func (p *DefaultType) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.String_ = _field return offset, nil } -// for compatibility func (p *DefaultType) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DefaultType) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DefaultType) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DefaultType") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DefaultType) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DefaultType") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DefaultType) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DefaultType) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "number", thrift.DOUBLE, 1) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Number) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.DOUBLE, 1) + offset += thrift.Binary.WriteDouble(buf[offset:], p.Number) return offset } -func (p *DefaultType) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DefaultType) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "boolean", thrift.BOOL, 2) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Boolean) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 2) + offset += thrift.Binary.WriteBool(buf[offset:], p.Boolean) return offset } -func (p *DefaultType) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DefaultType) fastWriteField3(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.String_) return offset } func (p *DefaultType) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("number", thrift.DOUBLE, 1) - l += bthrift.Binary.DoubleLength(p.Number) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.DoubleLength() return l } func (p *DefaultType) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("boolean", thrift.BOOL, 2) - l += bthrift.Binary.BoolLength(p.Boolean) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *DefaultType) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("string", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.String_) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.String_) return l } func (p *Discriminator) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2969,7 +2465,7 @@ func (p *Discriminator) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2983,7 +2479,7 @@ func (p *Discriminator) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2997,58 +2493,39 @@ func (p *Discriminator) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Discriminator[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 *Discriminator) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.PropertyName = _field return offset, nil @@ -3069,7 +2546,7 @@ func (p *Discriminator) FastReadField2(buf []byte) (int, error) { func (p *Discriminator) FastReadField3(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -3087,120 +2564,98 @@ func (p *Discriminator) FastReadField3(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Discriminator) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Discriminator) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Discriminator) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Discriminator") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Discriminator) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Discriminator") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Discriminator) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Discriminator) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "property_name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.PropertyName) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.PropertyName) return offset } -func (p *Discriminator) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Discriminator) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "mapping", thrift.STRUCT, 2) - offset += p.Mapping.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Mapping.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Discriminator) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Discriminator) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 3) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 3) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Discriminator) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("property_name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.PropertyName) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.PropertyName) return l } func (p *Discriminator) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("mapping", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Mapping.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Discriminator) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Document) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3217,7 +2672,7 @@ func (p *Document) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3231,7 +2686,7 @@ func (p *Document) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3245,7 +2700,7 @@ func (p *Document) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3259,7 +2714,7 @@ func (p *Document) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3273,7 +2728,7 @@ func (p *Document) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3287,7 +2742,7 @@ func (p *Document) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3301,7 +2756,7 @@ func (p *Document) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3315,7 +2770,7 @@ func (p *Document) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3329,58 +2784,39 @@ func (p *Document) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Document[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 *Document) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Openapi = _field return offset, nil @@ -3401,7 +2837,7 @@ func (p *Document) FastReadField2(buf []byte) (int, error) { func (p *Document) FastReadField3(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -3419,11 +2855,6 @@ func (p *Document) FastReadField3(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Servers = _field return offset, nil } @@ -3455,7 +2886,7 @@ func (p *Document) FastReadField5(buf []byte) (int, error) { func (p *Document) FastReadField6(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -3473,11 +2904,6 @@ func (p *Document) FastReadField6(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Security = _field return offset, nil } @@ -3485,7 +2911,7 @@ func (p *Document) FastReadField6(buf []byte) (int, error) { func (p *Document) FastReadField7(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -3503,11 +2929,6 @@ func (p *Document) FastReadField7(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Tags = _field return offset, nil } @@ -3527,7 +2948,7 @@ func (p *Document) FastReadField8(buf []byte) (int, error) { func (p *Document) FastReadField9(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -3545,42 +2966,33 @@ func (p *Document) FastReadField9(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Document) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Document) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Document) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Document") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField8(buf[offset:], w) + offset += p.fastWriteField9(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Document) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Document") if p != nil { l += p.field1Length() l += p.field2Length() @@ -3592,217 +3004,189 @@ func (p *Document) BLength() int { l += p.field8Length() l += p.field9Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Document) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Document) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "openapi", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Openapi) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Openapi) return offset } -func (p *Document) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Document) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "info", thrift.STRUCT, 2) - offset += p.Info.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Info.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Document) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Document) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "servers", thrift.LIST, 3) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 3) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Servers { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Document) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Document) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "paths", thrift.STRUCT, 4) - offset += p.Paths.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 4) + offset += p.Paths.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Document) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Document) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "components", thrift.STRUCT, 5) - offset += p.Components.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 5) + offset += p.Components.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Document) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Document) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "security", thrift.LIST, 6) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 6) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Security { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Document) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Document) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "tags", thrift.LIST, 7) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 7) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Tags { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Document) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Document) fastWriteField8(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "external_docs", thrift.STRUCT, 8) - offset += p.ExternalDocs.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 8) + offset += p.ExternalDocs.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Document) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Document) fastWriteField9(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 9) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 9) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Document) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("openapi", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Openapi) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Openapi) return l } func (p *Document) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("info", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Info.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Document) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("servers", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Servers)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Servers { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Document) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("paths", thrift.STRUCT, 4) + l += thrift.Binary.FieldBeginLength() l += p.Paths.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Document) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("components", thrift.STRUCT, 5) + l += thrift.Binary.FieldBeginLength() l += p.Components.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Document) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("security", thrift.LIST, 6) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Security)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Security { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Document) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("tags", thrift.LIST, 7) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Tags)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Tags { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Document) field8Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("external_docs", thrift.STRUCT, 8) + l += thrift.Binary.FieldBeginLength() l += p.ExternalDocs.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Document) field9Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 9) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Encoding) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3819,7 +3203,7 @@ func (p *Encoding) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3833,7 +3217,7 @@ func (p *Encoding) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3847,7 +3231,7 @@ func (p *Encoding) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3861,7 +3245,7 @@ func (p *Encoding) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3875,7 +3259,7 @@ func (p *Encoding) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -3889,58 +3273,39 @@ func (p *Encoding) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Encoding[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 *Encoding) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.ContentType = _field return offset, nil @@ -3962,13 +3327,11 @@ func (p *Encoding) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Style = _field return offset, nil @@ -3978,13 +3341,11 @@ func (p *Encoding) FastReadField4(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Explode = _field return offset, nil @@ -3994,13 +3355,11 @@ func (p *Encoding) FastReadField5(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.AllowReserved = _field return offset, nil @@ -4009,7 +3368,7 @@ func (p *Encoding) FastReadField5(buf []byte) (int, error) { func (p *Encoding) FastReadField6(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -4027,39 +3386,30 @@ func (p *Encoding) FastReadField6(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Encoding) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Encoding) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Encoding) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Encoding") if p != nil { - offset += p.fastWriteField4(buf[offset:], binaryWriter) - 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.fastWriteField6(buf[offset:], binaryWriter) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Encoding) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Encoding") if p != nil { l += p.field1Length() l += p.field2Length() @@ -4068,133 +3418,114 @@ func (p *Encoding) BLength() int { l += p.field5Length() l += p.field6Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Encoding) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Encoding) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "content_type", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.ContentType) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.ContentType) return offset } -func (p *Encoding) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Encoding) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "headers", thrift.STRUCT, 2) - offset += p.Headers.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Headers.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Encoding) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Encoding) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "style", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Style) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Style) return offset } -func (p *Encoding) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Encoding) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "explode", thrift.BOOL, 4) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Explode) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 4) + offset += thrift.Binary.WriteBool(buf[offset:], p.Explode) return offset } -func (p *Encoding) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Encoding) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "allow_reserved", thrift.BOOL, 5) - offset += bthrift.Binary.WriteBool(buf[offset:], p.AllowReserved) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 5) + offset += thrift.Binary.WriteBool(buf[offset:], p.AllowReserved) return offset } -func (p *Encoding) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Encoding) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 6) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 6) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Encoding) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("content_type", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.ContentType) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.ContentType) return l } func (p *Encoding) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("headers", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Headers.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Encoding) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("style", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Style) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Style) return l } func (p *Encoding) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("explode", thrift.BOOL, 4) - l += bthrift.Binary.BoolLength(p.Explode) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Encoding) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("allow_reserved", thrift.BOOL, 5) - l += bthrift.Binary.BoolLength(p.AllowReserved) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Encoding) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 6) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Encodings) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -4211,51 +3542,34 @@ func (p *Encodings) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Encodings[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 *Encodings) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -4273,84 +3587,66 @@ func (p *Encodings) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *Encodings) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Encodings) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Encodings) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Encodings") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Encodings) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Encodings") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Encodings) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Encodings) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Encodings) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Example) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -4367,7 +3663,7 @@ func (p *Example) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -4381,7 +3677,7 @@ func (p *Example) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -4395,7 +3691,7 @@ func (p *Example) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -4409,7 +3705,7 @@ func (p *Example) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -4423,58 +3719,39 @@ func (p *Example) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Example[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 *Example) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Summary = _field return offset, nil @@ -4484,13 +3761,11 @@ func (p *Example) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -4512,13 +3787,11 @@ func (p *Example) FastReadField4(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.ExternalValue = _field return offset, nil @@ -4527,7 +3800,7 @@ func (p *Example) FastReadField4(buf []byte) (int, error) { func (p *Example) FastReadField5(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -4545,38 +3818,29 @@ func (p *Example) FastReadField5(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Example) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Example) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Example) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Example") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Example) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Example") if p != nil { l += p.field1Length() l += p.field2Length() @@ -4584,117 +3848,100 @@ func (p *Example) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Example) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Example) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "summary", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Summary) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Summary) return offset } -func (p *Example) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Example) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Example) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Example) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 3) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 3) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Example) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Example) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "external_value", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.ExternalValue) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 4) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.ExternalValue) return offset } -func (p *Example) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Example) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 5) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 5) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Example) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("summary", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Summary) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Summary) return l } func (p *Example) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Example) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 3) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Example) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("external_value", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.ExternalValue) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.ExternalValue) return l } func (p *Example) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 5) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ExampleOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -4711,7 +3958,7 @@ func (p *ExampleOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -4725,45 +3972,28 @@ func (p *ExampleOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ExampleOrReference[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 *ExampleOrReference) FastReadField1(buf []byte) (int, error) { @@ -4790,81 +4020,67 @@ func (p *ExampleOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *ExampleOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ExampleOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ExampleOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ExampleOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("ExampleOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ExampleOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ExampleOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "example", thrift.STRUCT, 1) - offset += p.Example.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Example.FastWriteNocopy(buf[offset:], w) return offset } -func (p *ExampleOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ExampleOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "reference", thrift.STRUCT, 2) - offset += p.Reference.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Reference.FastWriteNocopy(buf[offset:], w) return offset } func (p *ExampleOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("example", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Example.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ExampleOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("reference", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Reference.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ExamplesOrReferences) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -4881,51 +4097,34 @@ func (p *ExamplesOrReferences) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ExamplesOrReferences[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 *ExamplesOrReferences) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -4943,84 +4142,66 @@ func (p *ExamplesOrReferences) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *ExamplesOrReferences) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ExamplesOrReferences) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ExamplesOrReferences) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExamplesOrReferences") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ExamplesOrReferences) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("ExamplesOrReferences") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ExamplesOrReferences) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ExamplesOrReferences) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *ExamplesOrReferences) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Expression) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -5037,51 +4218,34 @@ func (p *Expression) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Expression[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 *Expression) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -5099,84 +4263,66 @@ func (p *Expression) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *Expression) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Expression) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Expression) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Expression") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Expression) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Expression") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Expression) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Expression) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Expression) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ExternalDocs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -5193,7 +4339,7 @@ func (p *ExternalDocs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5207,7 +4353,7 @@ func (p *ExternalDocs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5221,58 +4367,39 @@ func (p *ExternalDocs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ExternalDocs[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 *ExternalDocs) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -5282,13 +4409,11 @@ func (p *ExternalDocs) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Url = _field return offset, nil @@ -5297,7 +4422,7 @@ func (p *ExternalDocs) FastReadField2(buf []byte) (int, error) { func (p *ExternalDocs) FastReadField3(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -5315,120 +4440,98 @@ func (p *ExternalDocs) FastReadField3(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *ExternalDocs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ExternalDocs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ExternalDocs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExternalDocs") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ExternalDocs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("ExternalDocs") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ExternalDocs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ExternalDocs) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *ExternalDocs) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ExternalDocs) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "url", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Url) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Url) return offset } -func (p *ExternalDocs) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ExternalDocs) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 3) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 3) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *ExternalDocs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *ExternalDocs) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("url", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Url) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Url) return l } func (p *ExternalDocs) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Header) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -5445,7 +4548,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5459,7 +4562,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5473,7 +4576,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5487,7 +4590,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5501,7 +4604,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5515,7 +4618,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5529,7 +4632,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5543,7 +4646,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5557,7 +4660,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5571,7 +4674,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5585,7 +4688,7 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -5599,58 +4702,39 @@ func (p *Header) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Header[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 *Header) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -5660,13 +4744,11 @@ func (p *Header) FastReadField2(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Required = _field return offset, nil @@ -5676,13 +4758,11 @@ func (p *Header) FastReadField3(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Deprecated = _field return offset, nil @@ -5692,13 +4772,11 @@ func (p *Header) FastReadField4(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.AllowEmptyValue = _field return offset, nil @@ -5708,13 +4786,11 @@ func (p *Header) FastReadField5(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Style = _field return offset, nil @@ -5724,13 +4800,11 @@ func (p *Header) FastReadField6(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Explode = _field return offset, nil @@ -5740,13 +4814,11 @@ func (p *Header) FastReadField7(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.AllowReserved = _field return offset, nil @@ -5803,7 +4875,7 @@ func (p *Header) FastReadField11(buf []byte) (int, error) { func (p *Header) FastReadField12(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -5821,45 +4893,36 @@ func (p *Header) FastReadField12(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Header) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Header) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Header") 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.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField5(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.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField8(buf[offset:], w) + offset += p.fastWriteField9(buf[offset:], w) + offset += p.fastWriteField10(buf[offset:], w) + offset += p.fastWriteField11(buf[offset:], w) + offset += p.fastWriteField12(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Header) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Header") if p != nil { l += p.field1Length() l += p.field2Length() @@ -5874,229 +4937,198 @@ func (p *Header) BLength() int { l += p.field11Length() l += p.field12Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Header) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Header) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "required", thrift.BOOL, 2) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Required) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 2) + offset += thrift.Binary.WriteBool(buf[offset:], p.Required) return offset } -func (p *Header) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "deprecated", thrift.BOOL, 3) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Deprecated) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 3) + offset += thrift.Binary.WriteBool(buf[offset:], p.Deprecated) return offset } -func (p *Header) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "allow_empty_value", thrift.BOOL, 4) - offset += bthrift.Binary.WriteBool(buf[offset:], p.AllowEmptyValue) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 4) + offset += thrift.Binary.WriteBool(buf[offset:], p.AllowEmptyValue) return offset } -func (p *Header) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "style", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Style) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Style) return offset } -func (p *Header) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "explode", thrift.BOOL, 6) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Explode) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 6) + offset += thrift.Binary.WriteBool(buf[offset:], p.Explode) return offset } -func (p *Header) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "allow_reserved", thrift.BOOL, 7) - offset += bthrift.Binary.WriteBool(buf[offset:], p.AllowReserved) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 7) + offset += thrift.Binary.WriteBool(buf[offset:], p.AllowReserved) return offset } -func (p *Header) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField8(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "schema", thrift.STRUCT, 8) - offset += p.Schema.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 8) + offset += p.Schema.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Header) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField9(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "example", thrift.STRUCT, 9) - offset += p.Example.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 9) + offset += p.Example.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Header) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField10(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "examples", thrift.STRUCT, 10) - offset += p.Examples.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 10) + offset += p.Examples.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Header) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField11(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "content", thrift.STRUCT, 11) - offset += p.Content.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 11) + offset += p.Content.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Header) fastWriteField12(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Header) fastWriteField12(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 12) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 12) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Header) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Header) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("required", thrift.BOOL, 2) - l += bthrift.Binary.BoolLength(p.Required) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Header) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("deprecated", thrift.BOOL, 3) - l += bthrift.Binary.BoolLength(p.Deprecated) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Header) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("allow_empty_value", thrift.BOOL, 4) - l += bthrift.Binary.BoolLength(p.AllowEmptyValue) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Header) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("style", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Style) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Style) return l } func (p *Header) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("explode", thrift.BOOL, 6) - l += bthrift.Binary.BoolLength(p.Explode) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Header) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("allow_reserved", thrift.BOOL, 7) - l += bthrift.Binary.BoolLength(p.AllowReserved) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Header) field8Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("schema", thrift.STRUCT, 8) + l += thrift.Binary.FieldBeginLength() l += p.Schema.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Header) field9Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("example", thrift.STRUCT, 9) + l += thrift.Binary.FieldBeginLength() l += p.Example.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Header) field10Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("examples", thrift.STRUCT, 10) + l += thrift.Binary.FieldBeginLength() l += p.Examples.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Header) field11Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("content", thrift.STRUCT, 11) + l += thrift.Binary.FieldBeginLength() l += p.Content.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Header) field12Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 12) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *HeaderOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -6113,7 +5145,7 @@ func (p *HeaderOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -6127,45 +5159,28 @@ func (p *HeaderOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_HeaderOrReference[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 *HeaderOrReference) FastReadField1(buf []byte) (int, error) { @@ -6192,81 +5207,67 @@ func (p *HeaderOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *HeaderOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *HeaderOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *HeaderOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "HeaderOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *HeaderOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("HeaderOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *HeaderOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *HeaderOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "header", thrift.STRUCT, 1) - offset += p.Header.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Header.FastWriteNocopy(buf[offset:], w) return offset } -func (p *HeaderOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *HeaderOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "reference", thrift.STRUCT, 2) - offset += p.Reference.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Reference.FastWriteNocopy(buf[offset:], w) return offset } func (p *HeaderOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("header", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Header.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *HeaderOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("reference", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Reference.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *HeadersOrReferences) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -6283,51 +5284,34 @@ func (p *HeadersOrReferences) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_HeadersOrReferences[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 *HeadersOrReferences) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -6345,84 +5329,66 @@ func (p *HeadersOrReferences) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *HeadersOrReferences) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *HeadersOrReferences) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *HeadersOrReferences) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "HeadersOrReferences") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *HeadersOrReferences) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("HeadersOrReferences") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *HeadersOrReferences) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *HeadersOrReferences) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *HeadersOrReferences) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Info) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -6439,7 +5405,7 @@ func (p *Info) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -6453,7 +5419,7 @@ func (p *Info) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -6467,7 +5433,7 @@ func (p *Info) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -6481,7 +5447,7 @@ func (p *Info) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -6495,7 +5461,7 @@ func (p *Info) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -6509,7 +5475,7 @@ func (p *Info) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -6523,7 +5489,7 @@ func (p *Info) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -6537,58 +5503,39 @@ func (p *Info) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Info[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 *Info) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Title = _field return offset, nil @@ -6598,13 +5545,11 @@ func (p *Info) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -6614,13 +5559,11 @@ func (p *Info) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.TermsOfService = _field return offset, nil @@ -6654,13 +5597,11 @@ func (p *Info) FastReadField6(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Version = _field return offset, nil @@ -6669,7 +5610,7 @@ func (p *Info) FastReadField6(buf []byte) (int, error) { func (p *Info) FastReadField7(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -6687,11 +5628,6 @@ func (p *Info) FastReadField7(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } @@ -6700,44 +5636,38 @@ func (p *Info) FastReadField8(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Summary = _field return offset, nil } -// for compatibility func (p *Info) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Info) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Info) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Info") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField8(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Info) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Info") if p != nil { l += p.field1Length() l += p.field2Length() @@ -6748,165 +5678,142 @@ func (p *Info) BLength() int { l += p.field7Length() l += p.field8Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Info) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Info) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "title", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Title) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Title) return offset } -func (p *Info) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Info) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Info) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Info) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "terms_of_service", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.TermsOfService) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.TermsOfService) return offset } -func (p *Info) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Info) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "contact", thrift.STRUCT, 4) - offset += p.Contact.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 4) + offset += p.Contact.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Info) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Info) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "license", thrift.STRUCT, 5) - offset += p.License.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 5) + offset += p.License.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Info) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Info) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "version", thrift.STRING, 6) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Version) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 6) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Version) return offset } -func (p *Info) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Info) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 7) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 7) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Info) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Info) fastWriteField8(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "summary", thrift.STRING, 8) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Summary) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 8) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Summary) return offset } func (p *Info) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("title", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Title) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Title) return l } func (p *Info) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Info) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("terms_of_service", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.TermsOfService) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.TermsOfService) return l } func (p *Info) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("contact", thrift.STRUCT, 4) + l += thrift.Binary.FieldBeginLength() l += p.Contact.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Info) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("license", thrift.STRUCT, 5) + l += thrift.Binary.FieldBeginLength() l += p.License.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Info) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("version", thrift.STRING, 6) - l += bthrift.Binary.StringLengthNocopy(p.Version) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Version) return l } func (p *Info) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 7) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Info) field8Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("summary", thrift.STRING, 8) - l += bthrift.Binary.StringLengthNocopy(p.Summary) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Summary) return l } func (p *ItemsItem) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -6923,51 +5830,34 @@ func (p *ItemsItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ItemsItem[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 *ItemsItem) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -6985,84 +5875,66 @@ func (p *ItemsItem) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SchemaOrReference = _field return offset, nil } -// for compatibility func (p *ItemsItem) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ItemsItem) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ItemsItem) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ItemsItem") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ItemsItem) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("ItemsItem") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ItemsItem) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ItemsItem) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "schema_or_reference", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SchemaOrReference { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *ItemsItem) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("schema_or_reference", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SchemaOrReference)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SchemaOrReference { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *License) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -7079,7 +5951,7 @@ func (p *License) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -7093,7 +5965,7 @@ func (p *License) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -7107,58 +5979,39 @@ func (p *License) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_License[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 *License) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -7168,13 +6021,11 @@ func (p *License) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Url = _field return offset, nil @@ -7183,7 +6034,7 @@ func (p *License) FastReadField2(buf []byte) (int, error) { func (p *License) FastReadField3(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -7201,120 +6052,98 @@ func (p *License) FastReadField3(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *License) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *License) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *License) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "License") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *License) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("License") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *License) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *License) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *License) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *License) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "url", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Url) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Url) return offset } -func (p *License) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *License) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 3) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 3) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *License) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *License) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("url", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Url) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Url) return l } func (p *License) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Link) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -7331,7 +6160,7 @@ func (p *Link) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -7345,7 +6174,7 @@ func (p *Link) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -7359,7 +6188,7 @@ func (p *Link) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -7373,7 +6202,7 @@ func (p *Link) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -7387,7 +6216,7 @@ func (p *Link) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -7401,7 +6230,7 @@ func (p *Link) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -7415,58 +6244,39 @@ func (p *Link) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Link[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 *Link) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.OperationRef = _field return offset, nil @@ -7476,13 +6286,11 @@ func (p *Link) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.OperationId = _field return offset, nil @@ -7516,13 +6324,11 @@ func (p *Link) FastReadField5(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -7543,7 +6349,7 @@ func (p *Link) FastReadField6(buf []byte) (int, error) { func (p *Link) FastReadField7(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -7561,40 +6367,31 @@ func (p *Link) FastReadField7(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Link) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Link) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Link) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Link") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Link) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Link") if p != nil { l += p.field1Length() l += p.field2Length() @@ -7604,149 +6401,128 @@ func (p *Link) BLength() int { l += p.field6Length() l += p.field7Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Link) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Link) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "operation_ref", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.OperationRef) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.OperationRef) return offset } -func (p *Link) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Link) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "operation_id", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.OperationId) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.OperationId) return offset } -func (p *Link) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Link) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "parameters", thrift.STRUCT, 3) - offset += p.Parameters.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 3) + offset += p.Parameters.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Link) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Link) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "request_body", thrift.STRUCT, 4) - offset += p.RequestBody.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 4) + offset += p.RequestBody.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Link) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Link) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Link) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Link) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "server", thrift.STRUCT, 6) - offset += p.Server.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 6) + offset += p.Server.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Link) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Link) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 7) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 7) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Link) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("operation_ref", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.OperationRef) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.OperationRef) return l } func (p *Link) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("operation_id", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.OperationId) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.OperationId) return l } func (p *Link) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("parameters", thrift.STRUCT, 3) + l += thrift.Binary.FieldBeginLength() l += p.Parameters.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Link) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("request_body", thrift.STRUCT, 4) + l += thrift.Binary.FieldBeginLength() l += p.RequestBody.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Link) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Link) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("server", thrift.STRUCT, 6) + l += thrift.Binary.FieldBeginLength() l += p.Server.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Link) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 7) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *LinkOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -7763,7 +6539,7 @@ func (p *LinkOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -7777,45 +6553,28 @@ func (p *LinkOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_LinkOrReference[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 *LinkOrReference) FastReadField1(buf []byte) (int, error) { @@ -7842,81 +6601,67 @@ func (p *LinkOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *LinkOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *LinkOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *LinkOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "LinkOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *LinkOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("LinkOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *LinkOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *LinkOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "link", thrift.STRUCT, 1) - offset += p.Link.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Link.FastWriteNocopy(buf[offset:], w) return offset } -func (p *LinkOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *LinkOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "reference", thrift.STRUCT, 2) - offset += p.Reference.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Reference.FastWriteNocopy(buf[offset:], w) return offset } func (p *LinkOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("link", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Link.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *LinkOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("reference", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Reference.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *LinksOrReferences) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -7933,51 +6678,34 @@ func (p *LinksOrReferences) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_LinksOrReferences[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 *LinksOrReferences) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -7995,84 +6723,66 @@ func (p *LinksOrReferences) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *LinksOrReferences) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *LinksOrReferences) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *LinksOrReferences) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "LinksOrReferences") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *LinksOrReferences) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("LinksOrReferences") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *LinksOrReferences) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *LinksOrReferences) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *LinksOrReferences) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *MediaType) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -8089,7 +6799,7 @@ func (p *MediaType) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -8103,7 +6813,7 @@ func (p *MediaType) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -8117,7 +6827,7 @@ func (p *MediaType) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -8131,7 +6841,7 @@ func (p *MediaType) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -8145,45 +6855,28 @@ func (p *MediaType) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_MediaType[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 *MediaType) FastReadField1(buf []byte) (int, error) { @@ -8237,7 +6930,7 @@ func (p *MediaType) FastReadField4(buf []byte) (int, error) { func (p *MediaType) FastReadField5(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -8255,38 +6948,29 @@ func (p *MediaType) FastReadField5(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *MediaType) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *MediaType) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MediaType) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "MediaType") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *MediaType) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("MediaType") if p != nil { l += p.field1Length() l += p.field2Length() @@ -8294,117 +6978,100 @@ func (p *MediaType) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *MediaType) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MediaType) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "schema", thrift.STRUCT, 1) - offset += p.Schema.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Schema.FastWriteNocopy(buf[offset:], w) return offset } -func (p *MediaType) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MediaType) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "example", thrift.STRUCT, 2) - offset += p.Example.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Example.FastWriteNocopy(buf[offset:], w) return offset } -func (p *MediaType) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MediaType) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "examples", thrift.STRUCT, 3) - offset += p.Examples.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 3) + offset += p.Examples.FastWriteNocopy(buf[offset:], w) return offset } -func (p *MediaType) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MediaType) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "encoding", thrift.STRUCT, 4) - offset += p.Encoding.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 4) + offset += p.Encoding.FastWriteNocopy(buf[offset:], w) return offset } -func (p *MediaType) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MediaType) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 5) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 5) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *MediaType) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("schema", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Schema.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *MediaType) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("example", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Example.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *MediaType) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("examples", thrift.STRUCT, 3) + l += thrift.Binary.FieldBeginLength() l += p.Examples.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *MediaType) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("encoding", thrift.STRUCT, 4) + l += thrift.Binary.FieldBeginLength() l += p.Encoding.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *MediaType) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 5) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *MediaTypes) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -8421,51 +7088,34 @@ func (p *MediaTypes) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_MediaTypes[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 *MediaTypes) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -8483,84 +7133,66 @@ func (p *MediaTypes) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *MediaTypes) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *MediaTypes) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MediaTypes) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "MediaTypes") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *MediaTypes) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("MediaTypes") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *MediaTypes) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *MediaTypes) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *MediaTypes) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedAny) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -8577,7 +7209,7 @@ func (p *NamedAny) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -8591,58 +7223,39 @@ func (p *NamedAny) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedAny[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 *NamedAny) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -8660,81 +7273,67 @@ func (p *NamedAny) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedAny) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedAny) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedAny) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedAny") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedAny) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedAny") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedAny) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedAny) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedAny) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedAny) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedAny) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedAny) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedCallbackOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -8751,7 +7350,7 @@ func (p *NamedCallbackOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -8765,58 +7364,39 @@ func (p *NamedCallbackOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedCallbackOrReference[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 *NamedCallbackOrReference) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -8834,81 +7414,67 @@ func (p *NamedCallbackOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedCallbackOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedCallbackOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedCallbackOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedCallbackOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedCallbackOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedCallbackOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedCallbackOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedCallbackOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedCallbackOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedCallbackOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedCallbackOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedCallbackOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedEncoding) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -8925,7 +7491,7 @@ func (p *NamedEncoding) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -8939,58 +7505,39 @@ func (p *NamedEncoding) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedEncoding[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 *NamedEncoding) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -9008,81 +7555,67 @@ func (p *NamedEncoding) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedEncoding) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedEncoding) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedEncoding) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedEncoding") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedEncoding) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedEncoding") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedEncoding) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedEncoding) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedEncoding) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedEncoding) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedEncoding) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedEncoding) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedExampleOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -9099,7 +7632,7 @@ func (p *NamedExampleOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -9113,58 +7646,39 @@ func (p *NamedExampleOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedExampleOrReference[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 *NamedExampleOrReference) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -9182,81 +7696,67 @@ func (p *NamedExampleOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedExampleOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedExampleOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedExampleOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedExampleOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedExampleOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedExampleOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedExampleOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedExampleOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedExampleOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedExampleOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedExampleOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedExampleOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedHeaderOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -9273,7 +7773,7 @@ func (p *NamedHeaderOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -9287,58 +7787,39 @@ func (p *NamedHeaderOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedHeaderOrReference[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 *NamedHeaderOrReference) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -9356,81 +7837,67 @@ func (p *NamedHeaderOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedHeaderOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedHeaderOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedHeaderOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedHeaderOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedHeaderOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedHeaderOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedHeaderOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedHeaderOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedHeaderOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedHeaderOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedHeaderOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedHeaderOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedLinkOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -9447,7 +7914,7 @@ func (p *NamedLinkOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -9461,58 +7928,39 @@ func (p *NamedLinkOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedLinkOrReference[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 *NamedLinkOrReference) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -9530,81 +7978,67 @@ func (p *NamedLinkOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedLinkOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedLinkOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedLinkOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedLinkOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedLinkOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedLinkOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedLinkOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedLinkOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedLinkOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedLinkOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedLinkOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedLinkOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedMediaType) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -9621,7 +8055,7 @@ func (p *NamedMediaType) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -9635,58 +8069,39 @@ func (p *NamedMediaType) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedMediaType[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 *NamedMediaType) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -9704,81 +8119,67 @@ func (p *NamedMediaType) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedMediaType) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedMediaType) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedMediaType) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedMediaType") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedMediaType) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedMediaType") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedMediaType) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedMediaType) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedMediaType) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedMediaType) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedMediaType) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedMediaType) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedParameterOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -9795,7 +8196,7 @@ func (p *NamedParameterOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -9809,58 +8210,39 @@ func (p *NamedParameterOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedParameterOrReference[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 *NamedParameterOrReference) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -9878,81 +8260,67 @@ func (p *NamedParameterOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedParameterOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedParameterOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedParameterOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedParameterOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedParameterOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedParameterOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedParameterOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedParameterOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedParameterOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedParameterOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedParameterOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedParameterOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedPathItem) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -9969,7 +8337,7 @@ func (p *NamedPathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -9983,58 +8351,39 @@ func (p *NamedPathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedPathItem[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 *NamedPathItem) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -10052,81 +8401,67 @@ func (p *NamedPathItem) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedPathItem) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedPathItem) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedPathItem) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedPathItem") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedPathItem) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedPathItem") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedPathItem) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedPathItem) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedPathItem) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedPathItem) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedPathItem) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedPathItem) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedRequestBodyOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -10143,7 +8478,7 @@ func (p *NamedRequestBodyOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -10157,58 +8492,39 @@ func (p *NamedRequestBodyOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedRequestBodyOrReference[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 *NamedRequestBodyOrReference) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -10226,81 +8542,67 @@ func (p *NamedRequestBodyOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedRequestBodyOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedRequestBodyOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedRequestBodyOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedRequestBodyOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedRequestBodyOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedRequestBodyOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedRequestBodyOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedRequestBodyOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedRequestBodyOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedRequestBodyOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedRequestBodyOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedRequestBodyOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedResponseOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -10317,7 +8619,7 @@ func (p *NamedResponseOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -10331,58 +8633,39 @@ func (p *NamedResponseOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedResponseOrReference[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 *NamedResponseOrReference) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -10400,81 +8683,67 @@ func (p *NamedResponseOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedResponseOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedResponseOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedResponseOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedResponseOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedResponseOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedResponseOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedResponseOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedResponseOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedResponseOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedResponseOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedResponseOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedResponseOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedSchemaOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -10491,7 +8760,7 @@ func (p *NamedSchemaOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -10505,58 +8774,39 @@ func (p *NamedSchemaOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedSchemaOrReference[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 *NamedSchemaOrReference) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -10574,81 +8824,67 @@ func (p *NamedSchemaOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedSchemaOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedSchemaOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedSchemaOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedSchemaOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedSchemaOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedSchemaOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedSchemaOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedSchemaOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedSchemaOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedSchemaOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedSchemaOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedSchemaOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedSecuritySchemeOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -10665,7 +8901,7 @@ func (p *NamedSecuritySchemeOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -10679,58 +8915,39 @@ func (p *NamedSecuritySchemeOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedSecuritySchemeOrReference[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 *NamedSecuritySchemeOrReference) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -10748,81 +8965,67 @@ func (p *NamedSecuritySchemeOrReference) FastReadField2(buf []byte) (int, error) return offset, nil } -// for compatibility func (p *NamedSecuritySchemeOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedSecuritySchemeOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedSecuritySchemeOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedSecuritySchemeOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedSecuritySchemeOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedSecuritySchemeOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedSecuritySchemeOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedSecuritySchemeOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedSecuritySchemeOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedSecuritySchemeOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedSecuritySchemeOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedSecuritySchemeOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedServerVariable) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -10839,7 +9042,7 @@ func (p *NamedServerVariable) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -10853,58 +9056,39 @@ func (p *NamedServerVariable) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedServerVariable[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 *NamedServerVariable) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -10922,81 +9106,67 @@ func (p *NamedServerVariable) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedServerVariable) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedServerVariable) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedServerVariable) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedServerVariable") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedServerVariable) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedServerVariable") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedServerVariable) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedServerVariable) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedServerVariable) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedServerVariable) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedServerVariable) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedServerVariable) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *NamedString) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -11013,7 +9183,7 @@ func (p *NamedString) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -11027,58 +9197,39 @@ func (p *NamedString) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedString[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 *NamedString) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -11088,93 +9239,77 @@ func (p *NamedString) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Value = _field return offset, nil } -// for compatibility func (p *NamedString) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedString) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedString) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedString") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedString) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedString") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedString) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedString) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedString) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedString) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Value) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Value) return offset } func (p *NamedString) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedString) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Value) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Value) return l } func (p *NamedStringArray) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -11191,7 +9326,7 @@ func (p *NamedStringArray) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -11205,58 +9340,39 @@ func (p *NamedStringArray) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_NamedStringArray[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 *NamedStringArray) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -11274,81 +9390,67 @@ func (p *NamedStringArray) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *NamedStringArray) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *NamedStringArray) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedStringArray) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NamedStringArray") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *NamedStringArray) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("NamedStringArray") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *NamedStringArray) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedStringArray) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *NamedStringArray) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *NamedStringArray) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "value", thrift.STRUCT, 2) - offset += p.Value.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Value.FastWriteNocopy(buf[offset:], w) return offset } func (p *NamedStringArray) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *NamedStringArray) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("value", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Value.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *OauthFlow) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -11365,7 +9467,7 @@ func (p *OauthFlow) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -11379,7 +9481,7 @@ func (p *OauthFlow) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -11393,7 +9495,7 @@ func (p *OauthFlow) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -11407,7 +9509,7 @@ func (p *OauthFlow) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -11421,58 +9523,39 @@ func (p *OauthFlow) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_OauthFlow[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 *OauthFlow) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.AuthorizationUrl = _field return offset, nil @@ -11482,13 +9565,11 @@ func (p *OauthFlow) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.TokenUrl = _field return offset, nil @@ -11498,13 +9579,11 @@ func (p *OauthFlow) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.RefreshUrl = _field return offset, nil @@ -11525,7 +9604,7 @@ func (p *OauthFlow) FastReadField4(buf []byte) (int, error) { func (p *OauthFlow) FastReadField5(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -11543,38 +9622,29 @@ func (p *OauthFlow) FastReadField5(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *OauthFlow) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *OauthFlow) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlow) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "OauthFlow") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *OauthFlow) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("OauthFlow") if p != nil { l += p.field1Length() l += p.field2Length() @@ -11582,117 +9652,100 @@ func (p *OauthFlow) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *OauthFlow) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlow) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "authorization_url", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.AuthorizationUrl) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.AuthorizationUrl) return offset } -func (p *OauthFlow) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlow) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "token_url", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.TokenUrl) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.TokenUrl) return offset } -func (p *OauthFlow) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlow) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "refresh_url", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.RefreshUrl) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.RefreshUrl) return offset } -func (p *OauthFlow) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlow) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "scopes", thrift.STRUCT, 4) - offset += p.Scopes.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 4) + offset += p.Scopes.FastWriteNocopy(buf[offset:], w) return offset } -func (p *OauthFlow) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlow) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 5) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 5) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *OauthFlow) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("authorization_url", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.AuthorizationUrl) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.AuthorizationUrl) return l } func (p *OauthFlow) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("token_url", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.TokenUrl) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.TokenUrl) return l } func (p *OauthFlow) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("refresh_url", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.RefreshUrl) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.RefreshUrl) return l } func (p *OauthFlow) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("scopes", thrift.STRUCT, 4) + l += thrift.Binary.FieldBeginLength() l += p.Scopes.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *OauthFlow) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 5) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *OauthFlows) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -11709,7 +9762,7 @@ func (p *OauthFlows) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -11723,7 +9776,7 @@ func (p *OauthFlows) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -11737,7 +9790,7 @@ func (p *OauthFlows) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -11751,7 +9804,7 @@ func (p *OauthFlows) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -11765,45 +9818,28 @@ func (p *OauthFlows) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_OauthFlows[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 *OauthFlows) FastReadField1(buf []byte) (int, error) { @@ -11857,7 +9893,7 @@ func (p *OauthFlows) FastReadField4(buf []byte) (int, error) { func (p *OauthFlows) FastReadField5(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -11875,38 +9911,29 @@ func (p *OauthFlows) FastReadField5(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *OauthFlows) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *OauthFlows) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlows) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "OauthFlows") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *OauthFlows) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("OauthFlows") if p != nil { l += p.field1Length() l += p.field2Length() @@ -11914,117 +9941,100 @@ func (p *OauthFlows) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *OauthFlows) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlows) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "implicit", thrift.STRUCT, 1) - offset += p.Implicit.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Implicit.FastWriteNocopy(buf[offset:], w) return offset } -func (p *OauthFlows) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlows) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "password", thrift.STRUCT, 2) - offset += p.Password.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Password.FastWriteNocopy(buf[offset:], w) return offset } -func (p *OauthFlows) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlows) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "client_credentials", thrift.STRUCT, 3) - offset += p.ClientCredentials.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 3) + offset += p.ClientCredentials.FastWriteNocopy(buf[offset:], w) return offset } -func (p *OauthFlows) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlows) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "authorization_code", thrift.STRUCT, 4) - offset += p.AuthorizationCode.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 4) + offset += p.AuthorizationCode.FastWriteNocopy(buf[offset:], w) return offset } -func (p *OauthFlows) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *OauthFlows) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 5) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 5) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *OauthFlows) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("implicit", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Implicit.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *OauthFlows) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("password", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Password.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *OauthFlows) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("client_credentials", thrift.STRUCT, 3) + l += thrift.Binary.FieldBeginLength() l += p.ClientCredentials.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *OauthFlows) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("authorization_code", thrift.STRUCT, 4) + l += thrift.Binary.FieldBeginLength() l += p.AuthorizationCode.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *OauthFlows) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 5) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Object) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -12041,51 +10051,34 @@ func (p *Object) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Object[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 *Object) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -12103,84 +10096,66 @@ func (p *Object) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *Object) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Object) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Object) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Object") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Object) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Object") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Object) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Object) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Object) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Operation) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -12197,7 +10172,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12211,7 +10186,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12225,7 +10200,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12239,7 +10214,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12253,7 +10228,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12267,7 +10242,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12281,7 +10256,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12295,7 +10270,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12309,7 +10284,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12323,7 +10298,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12337,7 +10312,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12351,7 +10326,7 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -12365,51 +10340,34 @@ func (p *Operation) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Operation[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 *Operation) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -12417,22 +10375,15 @@ func (p *Operation) FastReadField1(buf []byte) (int, error) { _field := make([]string, 0, size) for i := 0; i < size; i++ { var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _elem = v - } _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Tags = _field return offset, nil } @@ -12441,13 +10392,11 @@ func (p *Operation) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Summary = _field return offset, nil @@ -12457,13 +10406,11 @@ func (p *Operation) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -12485,13 +10432,11 @@ func (p *Operation) FastReadField5(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.OperationId = _field return offset, nil @@ -12500,7 +10445,7 @@ func (p *Operation) FastReadField5(buf []byte) (int, error) { func (p *Operation) FastReadField6(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -12518,11 +10463,6 @@ func (p *Operation) FastReadField6(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Parameters = _field return offset, nil } @@ -12567,13 +10507,11 @@ func (p *Operation) FastReadField10(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Deprecated = _field return offset, nil @@ -12582,7 +10520,7 @@ func (p *Operation) FastReadField10(buf []byte) (int, error) { func (p *Operation) FastReadField11(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -12600,11 +10538,6 @@ func (p *Operation) FastReadField11(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Security = _field return offset, nil } @@ -12612,7 +10545,7 @@ func (p *Operation) FastReadField11(buf []byte) (int, error) { func (p *Operation) FastReadField12(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -12630,11 +10563,6 @@ func (p *Operation) FastReadField12(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Servers = _field return offset, nil } @@ -12642,7 +10570,7 @@ func (p *Operation) FastReadField12(buf []byte) (int, error) { func (p *Operation) FastReadField13(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -12660,46 +10588,37 @@ func (p *Operation) FastReadField13(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Operation) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Operation) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Operation") if p != nil { - offset += p.fastWriteField10(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 += 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.fastWriteField11(buf[offset:], binaryWriter) - offset += p.fastWriteField12(buf[offset:], binaryWriter) - offset += p.fastWriteField13(buf[offset:], binaryWriter) + offset += p.fastWriteField10(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField8(buf[offset:], w) + offset += p.fastWriteField9(buf[offset:], w) + offset += p.fastWriteField11(buf[offset:], w) + offset += p.fastWriteField12(buf[offset:], w) + offset += p.fastWriteField13(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Operation) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Operation") if p != nil { l += p.field1Length() l += p.field2Length() @@ -12715,293 +10634,256 @@ func (p *Operation) BLength() int { l += p.field12Length() l += p.field13Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Operation) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "tags", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRING, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Tags { length++ - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, v) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) return offset } -func (p *Operation) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "summary", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Summary) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Summary) return offset } -func (p *Operation) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Operation) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "external_docs", thrift.STRUCT, 4) - offset += p.ExternalDocs.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 4) + offset += p.ExternalDocs.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Operation) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "operation_id", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.OperationId) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.OperationId) return offset } -func (p *Operation) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "parameters", thrift.LIST, 6) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 6) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Parameters { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Operation) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "request_body", thrift.STRUCT, 7) - offset += p.RequestBody.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 7) + offset += p.RequestBody.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Operation) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField8(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "responses", thrift.STRUCT, 8) - offset += p.Responses.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 8) + offset += p.Responses.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Operation) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField9(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "callbacks", thrift.STRUCT, 9) - offset += p.Callbacks.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 9) + offset += p.Callbacks.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Operation) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField10(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "deprecated", thrift.BOOL, 10) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Deprecated) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 10) + offset += thrift.Binary.WriteBool(buf[offset:], p.Deprecated) return offset } -func (p *Operation) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField11(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "security", thrift.LIST, 11) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 11) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Security { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Operation) fastWriteField12(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField12(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "servers", thrift.LIST, 12) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 12) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Servers { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Operation) fastWriteField13(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Operation) fastWriteField13(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 13) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 13) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Operation) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("tags", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.Tags)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Tags { - l += bthrift.Binary.StringLengthNocopy(v) + _ = v + l += thrift.Binary.StringLengthNocopy(v) } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Operation) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("summary", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Summary) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Summary) return l } func (p *Operation) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Operation) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("external_docs", thrift.STRUCT, 4) + l += thrift.Binary.FieldBeginLength() l += p.ExternalDocs.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Operation) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("operation_id", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.OperationId) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.OperationId) return l } func (p *Operation) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("parameters", thrift.LIST, 6) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Parameters)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Parameters { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Operation) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("request_body", thrift.STRUCT, 7) + l += thrift.Binary.FieldBeginLength() l += p.RequestBody.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Operation) field8Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("responses", thrift.STRUCT, 8) + l += thrift.Binary.FieldBeginLength() l += p.Responses.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Operation) field9Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("callbacks", thrift.STRUCT, 9) + l += thrift.Binary.FieldBeginLength() l += p.Callbacks.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Operation) field10Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("deprecated", thrift.BOOL, 10) - l += bthrift.Binary.BoolLength(p.Deprecated) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Operation) field11Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("security", thrift.LIST, 11) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Security)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Security { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Operation) field12Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("servers", thrift.LIST, 12) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Servers)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Servers { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Operation) field13Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 13) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Parameter) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -13018,7 +10900,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13032,7 +10914,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13046,7 +10928,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13060,7 +10942,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13074,7 +10956,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13088,7 +10970,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13102,7 +10984,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13116,7 +10998,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13130,7 +11012,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13144,7 +11026,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13158,7 +11040,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13172,7 +11054,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13186,7 +11068,7 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13200,58 +11082,39 @@ func (p *Parameter) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Parameter[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 *Parameter) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -13261,13 +11124,11 @@ func (p *Parameter) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.In = _field return offset, nil @@ -13277,13 +11138,11 @@ func (p *Parameter) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -13293,13 +11152,11 @@ func (p *Parameter) FastReadField4(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Required = _field return offset, nil @@ -13309,13 +11166,11 @@ func (p *Parameter) FastReadField5(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Deprecated = _field return offset, nil @@ -13325,13 +11180,11 @@ func (p *Parameter) FastReadField6(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.AllowEmptyValue = _field return offset, nil @@ -13341,13 +11194,11 @@ func (p *Parameter) FastReadField7(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Style = _field return offset, nil @@ -13357,13 +11208,11 @@ func (p *Parameter) FastReadField8(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Explode = _field return offset, nil @@ -13373,13 +11222,11 @@ func (p *Parameter) FastReadField9(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.AllowReserved = _field return offset, nil @@ -13436,7 +11283,7 @@ func (p *Parameter) FastReadField13(buf []byte) (int, error) { func (p *Parameter) FastReadField14(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -13454,47 +11301,38 @@ func (p *Parameter) FastReadField14(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Parameter) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Parameter) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Parameter") if p != nil { - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - offset += p.fastWriteField8(buf[offset:], binaryWriter) - offset += p.fastWriteField9(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField7(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 += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) + offset += p.fastWriteField8(buf[offset:], w) + offset += p.fastWriteField9(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField10(buf[offset:], w) + offset += p.fastWriteField11(buf[offset:], w) + offset += p.fastWriteField12(buf[offset:], w) + offset += p.fastWriteField13(buf[offset:], w) + offset += p.fastWriteField14(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Parameter) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Parameter") if p != nil { l += p.field1Length() l += p.field2Length() @@ -13511,261 +11349,226 @@ func (p *Parameter) BLength() int { l += p.field13Length() l += p.field14Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Parameter) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *Parameter) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "in", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.In) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.In) return offset } -func (p *Parameter) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Parameter) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "required", thrift.BOOL, 4) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Required) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 4) + offset += thrift.Binary.WriteBool(buf[offset:], p.Required) return offset } -func (p *Parameter) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "deprecated", thrift.BOOL, 5) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Deprecated) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 5) + offset += thrift.Binary.WriteBool(buf[offset:], p.Deprecated) return offset } -func (p *Parameter) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "allow_empty_value", thrift.BOOL, 6) - offset += bthrift.Binary.WriteBool(buf[offset:], p.AllowEmptyValue) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 6) + offset += thrift.Binary.WriteBool(buf[offset:], p.AllowEmptyValue) return offset } -func (p *Parameter) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "style", thrift.STRING, 7) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Style) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 7) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Style) return offset } -func (p *Parameter) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField8(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "explode", thrift.BOOL, 8) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Explode) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 8) + offset += thrift.Binary.WriteBool(buf[offset:], p.Explode) return offset } -func (p *Parameter) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField9(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "allow_reserved", thrift.BOOL, 9) - offset += bthrift.Binary.WriteBool(buf[offset:], p.AllowReserved) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 9) + offset += thrift.Binary.WriteBool(buf[offset:], p.AllowReserved) return offset } -func (p *Parameter) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField10(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "schema", thrift.STRUCT, 10) - offset += p.Schema.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 10) + offset += p.Schema.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Parameter) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField11(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "example", thrift.STRUCT, 11) - offset += p.Example.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 11) + offset += p.Example.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Parameter) fastWriteField12(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField12(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "examples", thrift.STRUCT, 12) - offset += p.Examples.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 12) + offset += p.Examples.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Parameter) fastWriteField13(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField13(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "content", thrift.STRUCT, 13) - offset += p.Content.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 13) + offset += p.Content.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Parameter) fastWriteField14(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Parameter) fastWriteField14(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 14) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 14) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Parameter) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *Parameter) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("in", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.In) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.In) return l } func (p *Parameter) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Parameter) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("required", thrift.BOOL, 4) - l += bthrift.Binary.BoolLength(p.Required) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Parameter) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("deprecated", thrift.BOOL, 5) - l += bthrift.Binary.BoolLength(p.Deprecated) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Parameter) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("allow_empty_value", thrift.BOOL, 6) - l += bthrift.Binary.BoolLength(p.AllowEmptyValue) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Parameter) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("style", thrift.STRING, 7) - l += bthrift.Binary.StringLengthNocopy(p.Style) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Style) return l } func (p *Parameter) field8Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("explode", thrift.BOOL, 8) - l += bthrift.Binary.BoolLength(p.Explode) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Parameter) field9Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("allow_reserved", thrift.BOOL, 9) - l += bthrift.Binary.BoolLength(p.AllowReserved) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Parameter) field10Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("schema", thrift.STRUCT, 10) + l += thrift.Binary.FieldBeginLength() l += p.Schema.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Parameter) field11Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("example", thrift.STRUCT, 11) + l += thrift.Binary.FieldBeginLength() l += p.Example.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Parameter) field12Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("examples", thrift.STRUCT, 12) + l += thrift.Binary.FieldBeginLength() l += p.Examples.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Parameter) field13Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("content", thrift.STRUCT, 13) + l += thrift.Binary.FieldBeginLength() l += p.Content.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Parameter) field14Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 14) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ParameterOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -13782,7 +11585,7 @@ func (p *ParameterOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -13796,45 +11599,28 @@ func (p *ParameterOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ParameterOrReference[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 *ParameterOrReference) FastReadField1(buf []byte) (int, error) { @@ -13861,81 +11647,67 @@ func (p *ParameterOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *ParameterOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ParameterOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ParameterOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ParameterOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ParameterOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("ParameterOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ParameterOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ParameterOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "parameter", thrift.STRUCT, 1) - offset += p.Parameter.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Parameter.FastWriteNocopy(buf[offset:], w) return offset } -func (p *ParameterOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ParameterOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "reference", thrift.STRUCT, 2) - offset += p.Reference.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Reference.FastWriteNocopy(buf[offset:], w) return offset } func (p *ParameterOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("parameter", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Parameter.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ParameterOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("reference", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Reference.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ParametersOrReferences) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -13952,51 +11724,34 @@ func (p *ParametersOrReferences) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ParametersOrReferences[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 *ParametersOrReferences) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -14014,84 +11769,66 @@ func (p *ParametersOrReferences) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *ParametersOrReferences) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ParametersOrReferences) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ParametersOrReferences) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ParametersOrReferences") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ParametersOrReferences) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("ParametersOrReferences") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ParametersOrReferences) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ParametersOrReferences) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *ParametersOrReferences) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -14108,7 +11845,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14122,7 +11859,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14136,7 +11873,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14150,7 +11887,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14164,7 +11901,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14178,7 +11915,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14192,7 +11929,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14206,7 +11943,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14220,7 +11957,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14234,7 +11971,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14248,7 +11985,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14262,7 +11999,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14276,7 +12013,7 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14290,58 +12027,39 @@ func (p *PathItem) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_PathItem[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 *PathItem) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Xref = _field return offset, nil @@ -14351,13 +12069,11 @@ func (p *PathItem) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Summary = _field return offset, nil @@ -14367,13 +12083,11 @@ func (p *PathItem) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -14478,7 +12192,7 @@ func (p *PathItem) FastReadField11(buf []byte) (int, error) { func (p *PathItem) FastReadField12(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -14496,11 +12210,6 @@ func (p *PathItem) FastReadField12(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Servers = _field return offset, nil } @@ -14508,7 +12217,7 @@ func (p *PathItem) FastReadField12(buf []byte) (int, error) { func (p *PathItem) FastReadField13(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -14526,11 +12235,6 @@ func (p *PathItem) FastReadField13(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Parameters = _field return offset, nil } @@ -14538,7 +12242,7 @@ func (p *PathItem) FastReadField13(buf []byte) (int, error) { func (p *PathItem) FastReadField14(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -14556,47 +12260,38 @@ func (p *PathItem) FastReadField14(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *PathItem) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *PathItem) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PathItem") 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 += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField8(buf[offset:], w) + offset += p.fastWriteField9(buf[offset:], w) + offset += p.fastWriteField10(buf[offset:], w) + offset += p.fastWriteField11(buf[offset:], w) + offset += p.fastWriteField12(buf[offset:], w) + offset += p.fastWriteField13(buf[offset:], w) + offset += p.fastWriteField14(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *PathItem) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("PathItem") if p != nil { l += p.field1Length() l += p.field2Length() @@ -14613,285 +12308,248 @@ func (p *PathItem) BLength() int { l += p.field13Length() l += p.field14Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *PathItem) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "xref", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Xref) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Xref) return offset } -func (p *PathItem) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "summary", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Summary) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Summary) return offset } -func (p *PathItem) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *PathItem) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "get", thrift.STRUCT, 4) - offset += p.Get.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 4) + offset += p.Get.FastWriteNocopy(buf[offset:], w) return offset } -func (p *PathItem) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "put", thrift.STRUCT, 5) - offset += p.Put.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 5) + offset += p.Put.FastWriteNocopy(buf[offset:], w) return offset } -func (p *PathItem) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "post", thrift.STRUCT, 6) - offset += p.Post.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 6) + offset += p.Post.FastWriteNocopy(buf[offset:], w) return offset } -func (p *PathItem) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "delete", thrift.STRUCT, 7) - offset += p.Delete.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 7) + offset += p.Delete.FastWriteNocopy(buf[offset:], w) return offset } -func (p *PathItem) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField8(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "options", thrift.STRUCT, 8) - offset += p.Options.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 8) + offset += p.Options.FastWriteNocopy(buf[offset:], w) return offset } -func (p *PathItem) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField9(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "head", thrift.STRUCT, 9) - offset += p.Head.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 9) + offset += p.Head.FastWriteNocopy(buf[offset:], w) return offset } -func (p *PathItem) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField10(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "patch", thrift.STRUCT, 10) - offset += p.Patch.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 10) + offset += p.Patch.FastWriteNocopy(buf[offset:], w) return offset } -func (p *PathItem) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField11(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "trace", thrift.STRUCT, 11) - offset += p.Trace.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 11) + offset += p.Trace.FastWriteNocopy(buf[offset:], w) return offset } -func (p *PathItem) fastWriteField12(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField12(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "servers", thrift.LIST, 12) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 12) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Servers { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *PathItem) fastWriteField13(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField13(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "parameters", thrift.LIST, 13) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 13) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Parameters { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *PathItem) fastWriteField14(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PathItem) fastWriteField14(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 14) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 14) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *PathItem) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("xref", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Xref) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Xref) return l } func (p *PathItem) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("summary", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Summary) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Summary) return l } func (p *PathItem) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *PathItem) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("get", thrift.STRUCT, 4) + l += thrift.Binary.FieldBeginLength() l += p.Get.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("put", thrift.STRUCT, 5) + l += thrift.Binary.FieldBeginLength() l += p.Put.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("post", thrift.STRUCT, 6) + l += thrift.Binary.FieldBeginLength() l += p.Post.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("delete", thrift.STRUCT, 7) + l += thrift.Binary.FieldBeginLength() l += p.Delete.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) field8Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("options", thrift.STRUCT, 8) + l += thrift.Binary.FieldBeginLength() l += p.Options.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) field9Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("head", thrift.STRUCT, 9) + l += thrift.Binary.FieldBeginLength() l += p.Head.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) field10Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("patch", thrift.STRUCT, 10) + l += thrift.Binary.FieldBeginLength() l += p.Patch.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) field11Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("trace", thrift.STRUCT, 11) + l += thrift.Binary.FieldBeginLength() l += p.Trace.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) field12Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("servers", thrift.LIST, 12) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Servers)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Servers { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) field13Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("parameters", thrift.LIST, 13) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Parameters)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Parameters { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *PathItem) field14Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 14) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Paths) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -14908,7 +12566,7 @@ func (p *Paths) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -14922,51 +12580,34 @@ func (p *Paths) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Paths[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 *Paths) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -14984,11 +12625,6 @@ func (p *Paths) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Path = _field return offset, nil } @@ -14996,7 +12632,7 @@ func (p *Paths) FastReadField1(buf []byte) (int, error) { func (p *Paths) FastReadField2(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -15014,114 +12650,93 @@ func (p *Paths) FastReadField2(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Paths) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Paths) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Paths) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Paths") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Paths) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Paths") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Paths) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Paths) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "path", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Path { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Paths) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Paths) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 2) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 2) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Paths) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("path", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Path)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Path { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Paths) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 2) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Properties) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -15138,51 +12753,34 @@ func (p *Properties) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Properties[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 *Properties) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -15200,84 +12798,66 @@ func (p *Properties) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *Properties) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Properties) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Properties) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Properties") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Properties) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Properties") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Properties) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Properties) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Properties) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Reference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -15294,7 +12874,7 @@ func (p *Reference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -15308,7 +12888,7 @@ func (p *Reference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -15322,58 +12902,39 @@ func (p *Reference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Reference[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 *Reference) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Xref = _field return offset, nil @@ -15383,13 +12944,11 @@ func (p *Reference) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Summary = _field return offset, nil @@ -15399,111 +12958,93 @@ func (p *Reference) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil } -// for compatibility func (p *Reference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Reference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Reference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Reference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Reference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Reference") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Reference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Reference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "xref", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Xref) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Xref) return offset } -func (p *Reference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Reference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "summary", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Summary) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Summary) return offset } -func (p *Reference) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Reference) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } func (p *Reference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("xref", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Xref) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Xref) return l } func (p *Reference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("summary", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Summary) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Summary) return l } func (p *Reference) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *RequestBody) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -15520,7 +13061,7 @@ func (p *RequestBody) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -15534,7 +13075,7 @@ func (p *RequestBody) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -15548,7 +13089,7 @@ func (p *RequestBody) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -15562,58 +13103,39 @@ func (p *RequestBody) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_RequestBody[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 *RequestBody) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -15635,13 +13157,11 @@ func (p *RequestBody) FastReadField3(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Required = _field return offset, nil @@ -15650,7 +13170,7 @@ func (p *RequestBody) FastReadField3(buf []byte) (int, error) { func (p *RequestBody) FastReadField4(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -15668,138 +13188,114 @@ func (p *RequestBody) FastReadField4(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *RequestBody) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *RequestBody) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *RequestBody) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "RequestBody") if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *RequestBody) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("RequestBody") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *RequestBody) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *RequestBody) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *RequestBody) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *RequestBody) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "content", thrift.STRUCT, 2) - offset += p.Content.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Content.FastWriteNocopy(buf[offset:], w) return offset } -func (p *RequestBody) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *RequestBody) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "required", thrift.BOOL, 3) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Required) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 3) + offset += thrift.Binary.WriteBool(buf[offset:], p.Required) return offset } -func (p *RequestBody) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *RequestBody) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 4) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 4) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *RequestBody) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *RequestBody) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("content", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Content.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *RequestBody) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("required", thrift.BOOL, 3) - l += bthrift.Binary.BoolLength(p.Required) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *RequestBody) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 4) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *RequestBodyOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -15816,7 +13312,7 @@ func (p *RequestBodyOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -15830,45 +13326,28 @@ func (p *RequestBodyOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_RequestBodyOrReference[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 *RequestBodyOrReference) FastReadField1(buf []byte) (int, error) { @@ -15895,81 +13374,67 @@ func (p *RequestBodyOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *RequestBodyOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *RequestBodyOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *RequestBodyOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "RequestBodyOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *RequestBodyOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("RequestBodyOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *RequestBodyOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *RequestBodyOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "request_body", thrift.STRUCT, 1) - offset += p.RequestBody.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.RequestBody.FastWriteNocopy(buf[offset:], w) return offset } -func (p *RequestBodyOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *RequestBodyOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "reference", thrift.STRUCT, 2) - offset += p.Reference.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Reference.FastWriteNocopy(buf[offset:], w) return offset } func (p *RequestBodyOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("request_body", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.RequestBody.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *RequestBodyOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("reference", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Reference.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *RequestBodiesOrReferences) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -15986,51 +13451,34 @@ func (p *RequestBodiesOrReferences) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_RequestBodiesOrReferences[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 *RequestBodiesOrReferences) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -16048,84 +13496,66 @@ func (p *RequestBodiesOrReferences) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *RequestBodiesOrReferences) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *RequestBodiesOrReferences) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *RequestBodiesOrReferences) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "RequestBodiesOrReferences") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *RequestBodiesOrReferences) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("RequestBodiesOrReferences") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *RequestBodiesOrReferences) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *RequestBodiesOrReferences) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *RequestBodiesOrReferences) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Response) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -16142,7 +13572,7 @@ func (p *Response) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -16156,7 +13586,7 @@ func (p *Response) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -16170,7 +13600,7 @@ func (p *Response) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -16184,7 +13614,7 @@ func (p *Response) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -16198,58 +13628,39 @@ func (p *Response) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Response[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 *Response) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -16294,7 +13705,7 @@ func (p *Response) FastReadField4(buf []byte) (int, error) { func (p *Response) FastReadField5(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -16312,38 +13723,29 @@ func (p *Response) FastReadField5(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Response) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Response) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Response") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Response) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Response") if p != nil { l += p.field1Length() l += p.field2Length() @@ -16351,117 +13753,100 @@ func (p *Response) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Response) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Response) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "headers", thrift.STRUCT, 2) - offset += p.Headers.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Headers.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Response) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "content", thrift.STRUCT, 3) - offset += p.Content.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 3) + offset += p.Content.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Response) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "links", thrift.STRUCT, 4) - offset += p.Links.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 4) + offset += p.Links.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Response) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 5) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 5) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Response) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Response) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("headers", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Headers.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Response) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("content", thrift.STRUCT, 3) + l += thrift.Binary.FieldBeginLength() l += p.Content.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Response) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("links", thrift.STRUCT, 4) + l += thrift.Binary.FieldBeginLength() l += p.Links.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Response) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 5) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ResponseOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -16478,7 +13863,7 @@ func (p *ResponseOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -16492,45 +13877,28 @@ func (p *ResponseOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ResponseOrReference[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 *ResponseOrReference) FastReadField1(buf []byte) (int, error) { @@ -16557,81 +13925,67 @@ func (p *ResponseOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *ResponseOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ResponseOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ResponseOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ResponseOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ResponseOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("ResponseOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ResponseOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ResponseOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "response", thrift.STRUCT, 1) - offset += p.Response.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Response.FastWriteNocopy(buf[offset:], w) return offset } -func (p *ResponseOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ResponseOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "reference", thrift.STRUCT, 2) - offset += p.Reference.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Reference.FastWriteNocopy(buf[offset:], w) return offset } func (p *ResponseOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("response", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Response.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ResponseOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("reference", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Reference.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Responses) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -16648,7 +14002,7 @@ func (p *Responses) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -16662,7 +14016,7 @@ func (p *Responses) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -16676,45 +14030,28 @@ func (p *Responses) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Responses[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 *Responses) FastReadField1(buf []byte) (int, error) { @@ -16732,7 +14069,7 @@ func (p *Responses) FastReadField1(buf []byte) (int, error) { func (p *Responses) FastReadField2(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -16750,11 +14087,6 @@ func (p *Responses) FastReadField2(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.ResponseOrReference = _field return offset, nil } @@ -16762,7 +14094,7 @@ func (p *Responses) FastReadField2(buf []byte) (int, error) { func (p *Responses) FastReadField3(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -16780,132 +14112,109 @@ func (p *Responses) FastReadField3(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Responses) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Responses) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Responses) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Responses") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Responses) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Responses") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Responses) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Responses) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "default", thrift.STRUCT, 1) - offset += p.Default.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Default.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Responses) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Responses) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "response_or_reference", thrift.LIST, 2) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 2) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.ResponseOrReference { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Responses) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Responses) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 3) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 3) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Responses) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("default", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Default.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Responses) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("response_or_reference", thrift.LIST, 2) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ResponseOrReference)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.ResponseOrReference { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Responses) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ResponsesOrReferences) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -16922,51 +14231,34 @@ func (p *ResponsesOrReferences) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ResponsesOrReferences[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 *ResponsesOrReferences) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -16984,84 +14276,66 @@ func (p *ResponsesOrReferences) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *ResponsesOrReferences) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ResponsesOrReferences) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ResponsesOrReferences) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ResponsesOrReferences") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ResponsesOrReferences) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("ResponsesOrReferences") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ResponsesOrReferences) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ResponsesOrReferences) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *ResponsesOrReferences) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -17078,7 +14352,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17092,7 +14366,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17106,7 +14380,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17120,7 +14394,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17134,7 +14408,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17148,7 +14422,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17162,7 +14436,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17176,7 +14450,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17190,7 +14464,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17204,7 +14478,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17218,7 +14492,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17232,7 +14506,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17246,7 +14520,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17260,7 +14534,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17274,7 +14548,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17288,7 +14562,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17302,7 +14576,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17316,7 +14590,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17330,7 +14604,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17344,7 +14618,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17358,7 +14632,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17372,7 +14646,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17386,7 +14660,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17400,7 +14674,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17414,7 +14688,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17428,7 +14702,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17442,7 +14716,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17456,7 +14730,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17470,7 +14744,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17484,7 +14758,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17498,7 +14772,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17512,7 +14786,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17526,7 +14800,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17540,7 +14814,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17554,7 +14828,7 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -17568,58 +14842,39 @@ func (p *Schema) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Schema[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 *Schema) FastReadField1(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Nullable = _field return offset, nil @@ -17641,13 +14896,11 @@ func (p *Schema) FastReadField3(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.ReadOnly = _field return offset, nil @@ -17657,13 +14910,11 @@ func (p *Schema) FastReadField4(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.WriteOnly = _field return offset, nil @@ -17709,13 +14960,11 @@ func (p *Schema) FastReadField8(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Deprecated = _field return offset, nil @@ -17725,13 +14974,11 @@ func (p *Schema) FastReadField9(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Title = _field return offset, nil @@ -17741,13 +14988,11 @@ func (p *Schema) FastReadField10(buf []byte) (int, error) { offset := 0 var _field float64 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadDouble(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.MultipleOf = _field return offset, nil @@ -17757,13 +15002,11 @@ func (p *Schema) FastReadField11(buf []byte) (int, error) { offset := 0 var _field float64 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadDouble(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Maximum = _field return offset, nil @@ -17773,13 +15016,11 @@ func (p *Schema) FastReadField12(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.ExclusiveMaximum = _field return offset, nil @@ -17789,13 +15030,11 @@ func (p *Schema) FastReadField13(buf []byte) (int, error) { offset := 0 var _field float64 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadDouble(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Minimum = _field return offset, nil @@ -17805,13 +15044,11 @@ func (p *Schema) FastReadField14(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.ExclusiveMinimum = _field return offset, nil @@ -17821,13 +15058,11 @@ func (p *Schema) FastReadField15(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.MaxLength = _field return offset, nil @@ -17837,13 +15072,11 @@ func (p *Schema) FastReadField16(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.MinLength = _field return offset, nil @@ -17853,13 +15086,11 @@ func (p *Schema) FastReadField17(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Pattern = _field return offset, nil @@ -17869,13 +15100,11 @@ func (p *Schema) FastReadField18(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.MaxItems = _field return offset, nil @@ -17885,13 +15114,11 @@ func (p *Schema) FastReadField19(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.MinItems = _field return offset, nil @@ -17901,13 +15128,11 @@ func (p *Schema) FastReadField20(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.UniqueItems = _field return offset, nil @@ -17917,13 +15142,11 @@ func (p *Schema) FastReadField21(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.MaxProperties = _field return offset, nil @@ -17933,13 +15156,11 @@ func (p *Schema) FastReadField22(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.MinProperties = _field return offset, nil @@ -17948,7 +15169,7 @@ func (p *Schema) FastReadField22(buf []byte) (int, error) { func (p *Schema) FastReadField23(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -17956,22 +15177,15 @@ func (p *Schema) FastReadField23(buf []byte) (int, error) { _field := make([]string, 0, size) for i := 0; i < size; i++ { var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _elem = v - } _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Required = _field return offset, nil } @@ -17979,7 +15193,7 @@ func (p *Schema) FastReadField23(buf []byte) (int, error) { func (p *Schema) FastReadField24(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -17997,11 +15211,6 @@ func (p *Schema) FastReadField24(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Enum = _field return offset, nil } @@ -18010,13 +15219,11 @@ func (p *Schema) FastReadField25(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Type = _field return offset, nil @@ -18025,7 +15232,7 @@ func (p *Schema) FastReadField25(buf []byte) (int, error) { func (p *Schema) FastReadField26(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -18043,11 +15250,6 @@ func (p *Schema) FastReadField26(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AllOf = _field return offset, nil } @@ -18055,7 +15257,7 @@ func (p *Schema) FastReadField26(buf []byte) (int, error) { func (p *Schema) FastReadField27(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -18073,11 +15275,6 @@ func (p *Schema) FastReadField27(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.OneOf = _field return offset, nil } @@ -18085,7 +15282,7 @@ func (p *Schema) FastReadField27(buf []byte) (int, error) { func (p *Schema) FastReadField28(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -18103,11 +15300,6 @@ func (p *Schema) FastReadField28(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AnyOf = _field return offset, nil } @@ -18176,13 +15368,11 @@ func (p *Schema) FastReadField34(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -18192,13 +15382,11 @@ func (p *Schema) FastReadField35(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Format = _field return offset, nil @@ -18207,7 +15395,7 @@ func (p *Schema) FastReadField35(buf []byte) (int, error) { func (p *Schema) FastReadField36(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -18225,69 +15413,60 @@ func (p *Schema) FastReadField36(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Schema) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Schema) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Schema") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField8(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.fastWriteField21(buf[offset:], binaryWriter) - offset += p.fastWriteField22(buf[offset:], binaryWriter) - offset += p.fastWriteField2(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.fastWriteField17(buf[offset:], binaryWriter) - offset += p.fastWriteField23(buf[offset:], binaryWriter) - offset += p.fastWriteField24(buf[offset:], binaryWriter) - offset += p.fastWriteField25(buf[offset:], binaryWriter) - offset += p.fastWriteField26(buf[offset:], binaryWriter) - offset += p.fastWriteField27(buf[offset:], binaryWriter) - offset += p.fastWriteField28(buf[offset:], binaryWriter) - offset += p.fastWriteField29(buf[offset:], binaryWriter) - offset += p.fastWriteField30(buf[offset:], binaryWriter) - offset += p.fastWriteField31(buf[offset:], binaryWriter) - offset += p.fastWriteField32(buf[offset:], binaryWriter) - offset += p.fastWriteField33(buf[offset:], binaryWriter) - offset += p.fastWriteField34(buf[offset:], binaryWriter) - offset += p.fastWriteField35(buf[offset:], binaryWriter) - offset += p.fastWriteField36(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField8(buf[offset:], w) + offset += p.fastWriteField10(buf[offset:], w) + offset += p.fastWriteField11(buf[offset:], w) + offset += p.fastWriteField12(buf[offset:], w) + offset += p.fastWriteField13(buf[offset:], w) + offset += p.fastWriteField14(buf[offset:], w) + offset += p.fastWriteField15(buf[offset:], w) + offset += p.fastWriteField16(buf[offset:], w) + offset += p.fastWriteField18(buf[offset:], w) + offset += p.fastWriteField19(buf[offset:], w) + offset += p.fastWriteField20(buf[offset:], w) + offset += p.fastWriteField21(buf[offset:], w) + offset += p.fastWriteField22(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField9(buf[offset:], w) + offset += p.fastWriteField17(buf[offset:], w) + offset += p.fastWriteField23(buf[offset:], w) + offset += p.fastWriteField24(buf[offset:], w) + offset += p.fastWriteField25(buf[offset:], w) + offset += p.fastWriteField26(buf[offset:], w) + offset += p.fastWriteField27(buf[offset:], w) + offset += p.fastWriteField28(buf[offset:], w) + offset += p.fastWriteField29(buf[offset:], w) + offset += p.fastWriteField30(buf[offset:], w) + offset += p.fastWriteField31(buf[offset:], w) + offset += p.fastWriteField32(buf[offset:], w) + offset += p.fastWriteField33(buf[offset:], w) + offset += p.fastWriteField34(buf[offset:], w) + offset += p.fastWriteField35(buf[offset:], w) + offset += p.fastWriteField36(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Schema) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Schema") if p != nil { l += p.field1Length() l += p.field2Length() @@ -18326,673 +15505,589 @@ func (p *Schema) BLength() int { l += p.field35Length() l += p.field36Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Schema) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "nullable", thrift.BOOL, 1) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Nullable) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 1) + offset += thrift.Binary.WriteBool(buf[offset:], p.Nullable) return offset } -func (p *Schema) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "discriminator", thrift.STRUCT, 2) - offset += p.Discriminator.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Discriminator.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Schema) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "read_only", thrift.BOOL, 3) - offset += bthrift.Binary.WriteBool(buf[offset:], p.ReadOnly) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 3) + offset += thrift.Binary.WriteBool(buf[offset:], p.ReadOnly) return offset } -func (p *Schema) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "write_only", thrift.BOOL, 4) - offset += bthrift.Binary.WriteBool(buf[offset:], p.WriteOnly) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 4) + offset += thrift.Binary.WriteBool(buf[offset:], p.WriteOnly) return offset } -func (p *Schema) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "xml", thrift.STRUCT, 5) - offset += p.Xml.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 5) + offset += p.Xml.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Schema) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "external_docs", thrift.STRUCT, 6) - offset += p.ExternalDocs.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 6) + offset += p.ExternalDocs.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Schema) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "example", thrift.STRUCT, 7) - offset += p.Example.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 7) + offset += p.Example.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Schema) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField8(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "deprecated", thrift.BOOL, 8) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Deprecated) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 8) + offset += thrift.Binary.WriteBool(buf[offset:], p.Deprecated) return offset } -func (p *Schema) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField9(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "title", thrift.STRING, 9) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Title) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 9) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Title) return offset } -func (p *Schema) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField10(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "multiple_of", thrift.DOUBLE, 10) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.MultipleOf) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.DOUBLE, 10) + offset += thrift.Binary.WriteDouble(buf[offset:], p.MultipleOf) return offset } -func (p *Schema) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField11(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "maximum", thrift.DOUBLE, 11) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Maximum) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.DOUBLE, 11) + offset += thrift.Binary.WriteDouble(buf[offset:], p.Maximum) return offset } -func (p *Schema) fastWriteField12(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField12(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "exclusive_maximum", thrift.BOOL, 12) - offset += bthrift.Binary.WriteBool(buf[offset:], p.ExclusiveMaximum) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 12) + offset += thrift.Binary.WriteBool(buf[offset:], p.ExclusiveMaximum) return offset } -func (p *Schema) fastWriteField13(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField13(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "minimum", thrift.DOUBLE, 13) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Minimum) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.DOUBLE, 13) + offset += thrift.Binary.WriteDouble(buf[offset:], p.Minimum) return offset } -func (p *Schema) fastWriteField14(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField14(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "exclusive_minimum", thrift.BOOL, 14) - offset += bthrift.Binary.WriteBool(buf[offset:], p.ExclusiveMinimum) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 14) + offset += thrift.Binary.WriteBool(buf[offset:], p.ExclusiveMinimum) return offset } -func (p *Schema) fastWriteField15(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField15(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "max_length", thrift.I64, 15) - offset += bthrift.Binary.WriteI64(buf[offset:], p.MaxLength) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 15) + offset += thrift.Binary.WriteI64(buf[offset:], p.MaxLength) return offset } -func (p *Schema) fastWriteField16(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField16(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "min_length", thrift.I64, 16) - offset += bthrift.Binary.WriteI64(buf[offset:], p.MinLength) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 16) + offset += thrift.Binary.WriteI64(buf[offset:], p.MinLength) return offset } -func (p *Schema) fastWriteField17(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField17(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "pattern", thrift.STRING, 17) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Pattern) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 17) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Pattern) return offset } -func (p *Schema) fastWriteField18(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField18(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "max_items", thrift.I64, 18) - offset += bthrift.Binary.WriteI64(buf[offset:], p.MaxItems) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 18) + offset += thrift.Binary.WriteI64(buf[offset:], p.MaxItems) return offset } -func (p *Schema) fastWriteField19(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField19(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "min_items", thrift.I64, 19) - offset += bthrift.Binary.WriteI64(buf[offset:], p.MinItems) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 19) + offset += thrift.Binary.WriteI64(buf[offset:], p.MinItems) return offset } -func (p *Schema) fastWriteField20(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField20(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "unique_items", thrift.BOOL, 20) - offset += bthrift.Binary.WriteBool(buf[offset:], p.UniqueItems) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 20) + offset += thrift.Binary.WriteBool(buf[offset:], p.UniqueItems) return offset } -func (p *Schema) fastWriteField21(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField21(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "max_properties", thrift.I64, 21) - offset += bthrift.Binary.WriteI64(buf[offset:], p.MaxProperties) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 21) + offset += thrift.Binary.WriteI64(buf[offset:], p.MaxProperties) return offset } -func (p *Schema) fastWriteField22(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField22(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "min_properties", thrift.I64, 22) - offset += bthrift.Binary.WriteI64(buf[offset:], p.MinProperties) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 22) + offset += thrift.Binary.WriteI64(buf[offset:], p.MinProperties) return offset } -func (p *Schema) fastWriteField23(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField23(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "required", thrift.LIST, 23) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 23) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRING, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Required { length++ - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, v) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) return offset } -func (p *Schema) fastWriteField24(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField24(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "enum", thrift.LIST, 24) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 24) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Enum { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Schema) fastWriteField25(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField25(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "type", thrift.STRING, 25) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Type) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 25) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Type) return offset } -func (p *Schema) fastWriteField26(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField26(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "all_of", thrift.LIST, 26) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 26) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AllOf { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Schema) fastWriteField27(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField27(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "one_of", thrift.LIST, 27) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 27) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.OneOf { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Schema) fastWriteField28(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField28(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "any_of", thrift.LIST, 28) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 28) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AnyOf { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *Schema) fastWriteField29(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField29(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "not", thrift.STRUCT, 29) - offset += p.Not.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 29) + offset += p.Not.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Schema) fastWriteField30(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField30(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "items", thrift.STRUCT, 30) - offset += p.Items.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 30) + offset += p.Items.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Schema) fastWriteField31(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField31(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "properties", thrift.STRUCT, 31) - offset += p.Properties.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 31) + offset += p.Properties.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Schema) fastWriteField32(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField32(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.STRUCT, 32) - offset += p.AdditionalProperties.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 32) + offset += p.AdditionalProperties.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Schema) fastWriteField33(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField33(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "default", thrift.STRUCT, 33) - offset += p.Default.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 33) + offset += p.Default.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Schema) fastWriteField34(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField34(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 34) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 34) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Schema) fastWriteField35(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField35(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "format", thrift.STRING, 35) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Format) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 35) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Format) return offset } -func (p *Schema) fastWriteField36(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Schema) fastWriteField36(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 36) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 36) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Schema) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("nullable", thrift.BOOL, 1) - l += bthrift.Binary.BoolLength(p.Nullable) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Schema) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("discriminator", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Discriminator.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("read_only", thrift.BOOL, 3) - l += bthrift.Binary.BoolLength(p.ReadOnly) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Schema) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("write_only", thrift.BOOL, 4) - l += bthrift.Binary.BoolLength(p.WriteOnly) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Schema) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("xml", thrift.STRUCT, 5) + l += thrift.Binary.FieldBeginLength() l += p.Xml.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("external_docs", thrift.STRUCT, 6) + l += thrift.Binary.FieldBeginLength() l += p.ExternalDocs.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("example", thrift.STRUCT, 7) + l += thrift.Binary.FieldBeginLength() l += p.Example.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field8Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("deprecated", thrift.BOOL, 8) - l += bthrift.Binary.BoolLength(p.Deprecated) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Schema) field9Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("title", thrift.STRING, 9) - l += bthrift.Binary.StringLengthNocopy(p.Title) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Title) return l } func (p *Schema) field10Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("multiple_of", thrift.DOUBLE, 10) - l += bthrift.Binary.DoubleLength(p.MultipleOf) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.DoubleLength() return l } func (p *Schema) field11Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("maximum", thrift.DOUBLE, 11) - l += bthrift.Binary.DoubleLength(p.Maximum) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.DoubleLength() return l } func (p *Schema) field12Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("exclusive_maximum", thrift.BOOL, 12) - l += bthrift.Binary.BoolLength(p.ExclusiveMaximum) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Schema) field13Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("minimum", thrift.DOUBLE, 13) - l += bthrift.Binary.DoubleLength(p.Minimum) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.DoubleLength() return l } func (p *Schema) field14Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("exclusive_minimum", thrift.BOOL, 14) - l += bthrift.Binary.BoolLength(p.ExclusiveMinimum) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Schema) field15Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("max_length", thrift.I64, 15) - l += bthrift.Binary.I64Length(p.MaxLength) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *Schema) field16Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("min_length", thrift.I64, 16) - l += bthrift.Binary.I64Length(p.MinLength) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *Schema) field17Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("pattern", thrift.STRING, 17) - l += bthrift.Binary.StringLengthNocopy(p.Pattern) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Pattern) return l } func (p *Schema) field18Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("max_items", thrift.I64, 18) - l += bthrift.Binary.I64Length(p.MaxItems) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *Schema) field19Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("min_items", thrift.I64, 19) - l += bthrift.Binary.I64Length(p.MinItems) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *Schema) field20Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("unique_items", thrift.BOOL, 20) - l += bthrift.Binary.BoolLength(p.UniqueItems) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Schema) field21Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("max_properties", thrift.I64, 21) - l += bthrift.Binary.I64Length(p.MaxProperties) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *Schema) field22Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("min_properties", thrift.I64, 22) - l += bthrift.Binary.I64Length(p.MinProperties) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *Schema) field23Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("required", thrift.LIST, 23) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.Required)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Required { - l += bthrift.Binary.StringLengthNocopy(v) + _ = v + l += thrift.Binary.StringLengthNocopy(v) } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field24Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("enum", thrift.LIST, 24) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Enum)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Enum { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field25Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("type", thrift.STRING, 25) - l += bthrift.Binary.StringLengthNocopy(p.Type) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Type) return l } func (p *Schema) field26Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("all_of", thrift.LIST, 26) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AllOf)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AllOf { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field27Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("one_of", thrift.LIST, 27) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.OneOf)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.OneOf { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field28Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("any_of", thrift.LIST, 28) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AnyOf)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AnyOf { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field29Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("not", thrift.STRUCT, 29) + l += thrift.Binary.FieldBeginLength() l += p.Not.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field30Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("items", thrift.STRUCT, 30) + l += thrift.Binary.FieldBeginLength() l += p.Items.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field31Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("properties", thrift.STRUCT, 31) + l += thrift.Binary.FieldBeginLength() l += p.Properties.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field32Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.STRUCT, 32) + l += thrift.Binary.FieldBeginLength() l += p.AdditionalProperties.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field33Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("default", thrift.STRUCT, 33) + l += thrift.Binary.FieldBeginLength() l += p.Default.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Schema) field34Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 34) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Schema) field35Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("format", thrift.STRING, 35) - l += bthrift.Binary.StringLengthNocopy(p.Format) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Format) return l } func (p *Schema) field36Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 36) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *SchemaOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -19009,7 +16104,7 @@ func (p *SchemaOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -19023,45 +16118,28 @@ func (p *SchemaOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_SchemaOrReference[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 *SchemaOrReference) FastReadField1(buf []byte) (int, error) { @@ -19088,81 +16166,67 @@ func (p *SchemaOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *SchemaOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *SchemaOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SchemaOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SchemaOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *SchemaOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("SchemaOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *SchemaOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SchemaOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "schema", thrift.STRUCT, 1) - offset += p.Schema.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Schema.FastWriteNocopy(buf[offset:], w) return offset } -func (p *SchemaOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SchemaOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "reference", thrift.STRUCT, 2) - offset += p.Reference.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Reference.FastWriteNocopy(buf[offset:], w) return offset } func (p *SchemaOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("schema", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Schema.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *SchemaOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("reference", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Reference.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *SchemasOrReferences) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -19179,51 +16243,34 @@ func (p *SchemasOrReferences) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_SchemasOrReferences[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 *SchemasOrReferences) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -19241,84 +16288,66 @@ func (p *SchemasOrReferences) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *SchemasOrReferences) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *SchemasOrReferences) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SchemasOrReferences) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SchemasOrReferences") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *SchemasOrReferences) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("SchemasOrReferences") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *SchemasOrReferences) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SchemasOrReferences) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *SchemasOrReferences) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *SecurityRequirement) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -19335,51 +16364,34 @@ func (p *SecurityRequirement) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_SecurityRequirement[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 *SecurityRequirement) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -19397,84 +16409,66 @@ func (p *SecurityRequirement) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *SecurityRequirement) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *SecurityRequirement) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityRequirement) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SecurityRequirement") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *SecurityRequirement) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("SecurityRequirement") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *SecurityRequirement) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityRequirement) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *SecurityRequirement) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *SecurityScheme) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -19491,7 +16485,7 @@ func (p *SecurityScheme) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -19505,7 +16499,7 @@ func (p *SecurityScheme) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -19519,7 +16513,7 @@ func (p *SecurityScheme) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -19533,7 +16527,7 @@ func (p *SecurityScheme) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -19547,7 +16541,7 @@ func (p *SecurityScheme) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -19561,7 +16555,7 @@ func (p *SecurityScheme) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -19575,7 +16569,7 @@ func (p *SecurityScheme) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -19589,7 +16583,7 @@ func (p *SecurityScheme) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -19603,58 +16597,39 @@ func (p *SecurityScheme) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_SecurityScheme[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 *SecurityScheme) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p._Type = _field return offset, nil @@ -19664,13 +16639,11 @@ func (p *SecurityScheme) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -19680,13 +16653,11 @@ func (p *SecurityScheme) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -19696,13 +16667,11 @@ func (p *SecurityScheme) FastReadField4(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p._In = _field return offset, nil @@ -19712,13 +16681,11 @@ func (p *SecurityScheme) FastReadField5(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Scheme = _field return offset, nil @@ -19728,13 +16695,11 @@ func (p *SecurityScheme) FastReadField6(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.BearerFormat = _field return offset, nil @@ -19756,13 +16721,11 @@ func (p *SecurityScheme) FastReadField8(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.OpenIdConnectUrl = _field return offset, nil @@ -19771,7 +16734,7 @@ func (p *SecurityScheme) FastReadField8(buf []byte) (int, error) { func (p *SecurityScheme) FastReadField9(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -19789,42 +16752,33 @@ func (p *SecurityScheme) FastReadField9(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *SecurityScheme) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *SecurityScheme) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityScheme) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SecurityScheme") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField8(buf[offset:], w) + offset += p.fastWriteField9(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *SecurityScheme) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("SecurityScheme") if p != nil { l += p.field1Length() l += p.field2Length() @@ -19836,181 +16790,156 @@ func (p *SecurityScheme) BLength() int { l += p.field8Length() l += p.field9Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *SecurityScheme) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityScheme) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "_type", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p._Type) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p._Type) return offset } -func (p *SecurityScheme) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityScheme) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *SecurityScheme) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityScheme) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *SecurityScheme) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityScheme) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "_in", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p._In) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 4) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p._In) return offset } -func (p *SecurityScheme) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityScheme) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "scheme", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Scheme) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Scheme) return offset } -func (p *SecurityScheme) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityScheme) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "bearer_format", thrift.STRING, 6) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.BearerFormat) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 6) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.BearerFormat) return offset } -func (p *SecurityScheme) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityScheme) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "flows", thrift.STRUCT, 7) - offset += p.Flows.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 7) + offset += p.Flows.FastWriteNocopy(buf[offset:], w) return offset } -func (p *SecurityScheme) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityScheme) fastWriteField8(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "open_id_connect_url", thrift.STRING, 8) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.OpenIdConnectUrl) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 8) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.OpenIdConnectUrl) return offset } -func (p *SecurityScheme) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecurityScheme) fastWriteField9(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 9) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 9) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *SecurityScheme) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("_type", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p._Type) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p._Type) return l } func (p *SecurityScheme) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *SecurityScheme) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *SecurityScheme) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("_in", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p._In) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p._In) return l } func (p *SecurityScheme) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("scheme", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Scheme) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Scheme) return l } func (p *SecurityScheme) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("bearer_format", thrift.STRING, 6) - l += bthrift.Binary.StringLengthNocopy(p.BearerFormat) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.BearerFormat) return l } func (p *SecurityScheme) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("flows", thrift.STRUCT, 7) + l += thrift.Binary.FieldBeginLength() l += p.Flows.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *SecurityScheme) field8Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("open_id_connect_url", thrift.STRING, 8) - l += bthrift.Binary.StringLengthNocopy(p.OpenIdConnectUrl) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.OpenIdConnectUrl) return l } func (p *SecurityScheme) field9Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 9) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *SecuritySchemeOrReference) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -20027,7 +16956,7 @@ func (p *SecuritySchemeOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -20041,45 +16970,28 @@ func (p *SecuritySchemeOrReference) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_SecuritySchemeOrReference[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 *SecuritySchemeOrReference) FastReadField1(buf []byte) (int, error) { @@ -20106,81 +17018,67 @@ func (p *SecuritySchemeOrReference) FastReadField2(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *SecuritySchemeOrReference) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *SecuritySchemeOrReference) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecuritySchemeOrReference) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SecuritySchemeOrReference") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *SecuritySchemeOrReference) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("SecuritySchemeOrReference") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *SecuritySchemeOrReference) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecuritySchemeOrReference) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "security_scheme", thrift.STRUCT, 1) - offset += p.SecurityScheme.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.SecurityScheme.FastWriteNocopy(buf[offset:], w) return offset } -func (p *SecuritySchemeOrReference) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecuritySchemeOrReference) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "reference", thrift.STRUCT, 2) - offset += p.Reference.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 2) + offset += p.Reference.FastWriteNocopy(buf[offset:], w) return offset } func (p *SecuritySchemeOrReference) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("security_scheme", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.SecurityScheme.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *SecuritySchemeOrReference) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("reference", thrift.STRUCT, 2) + l += thrift.Binary.FieldBeginLength() l += p.Reference.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *SecuritySchemesOrReferences) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -20197,51 +17095,34 @@ func (p *SecuritySchemesOrReferences) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_SecuritySchemesOrReferences[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 *SecuritySchemesOrReferences) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -20259,84 +17140,66 @@ func (p *SecuritySchemesOrReferences) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *SecuritySchemesOrReferences) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *SecuritySchemesOrReferences) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecuritySchemesOrReferences) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SecuritySchemesOrReferences") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *SecuritySchemesOrReferences) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("SecuritySchemesOrReferences") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *SecuritySchemesOrReferences) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SecuritySchemesOrReferences) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *SecuritySchemesOrReferences) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Server) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -20353,7 +17216,7 @@ func (p *Server) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -20367,7 +17230,7 @@ func (p *Server) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -20381,7 +17244,7 @@ func (p *Server) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -20395,58 +17258,39 @@ func (p *Server) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Server[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 *Server) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Url = _field return offset, nil @@ -20456,13 +17300,11 @@ func (p *Server) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -20483,7 +17325,7 @@ func (p *Server) FastReadField3(buf []byte) (int, error) { func (p *Server) FastReadField4(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -20501,138 +17343,114 @@ func (p *Server) FastReadField4(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Server) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Server) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Server) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Server") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Server) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Server") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Server) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Server) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "url", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Url) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Url) return offset } -func (p *Server) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Server) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Server) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Server) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "variables", thrift.STRUCT, 3) - offset += p.Variables.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 3) + offset += p.Variables.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Server) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Server) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 4) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 4) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Server) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("url", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Url) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Url) return l } func (p *Server) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Server) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("variables", thrift.STRUCT, 3) + l += thrift.Binary.FieldBeginLength() l += p.Variables.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Server) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 4) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ServerVariable) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -20649,7 +17467,7 @@ func (p *ServerVariable) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -20663,7 +17481,7 @@ func (p *ServerVariable) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -20677,7 +17495,7 @@ func (p *ServerVariable) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -20691,58 +17509,39 @@ func (p *ServerVariable) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ServerVariable[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 *ServerVariable) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p._Default = _field return offset, nil @@ -20751,7 +17550,7 @@ func (p *ServerVariable) FastReadField1(buf []byte) (int, error) { func (p *ServerVariable) FastReadField2(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -20759,22 +17558,15 @@ func (p *ServerVariable) FastReadField2(buf []byte) (int, error) { _field := make([]string, 0, size) for i := 0; i < size; i++ { var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _elem = v - } _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Enum = _field return offset, nil } @@ -20783,13 +17575,11 @@ func (p *ServerVariable) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -20798,7 +17588,7 @@ func (p *ServerVariable) FastReadField3(buf []byte) (int, error) { func (p *ServerVariable) FastReadField4(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -20816,150 +17606,125 @@ func (p *ServerVariable) FastReadField4(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *ServerVariable) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ServerVariable) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServerVariable) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ServerVariable") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ServerVariable) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("ServerVariable") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ServerVariable) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServerVariable) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "_default", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p._Default) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p._Default) return offset } -func (p *ServerVariable) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServerVariable) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "enum", thrift.LIST, 2) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 2) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRING, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Enum { length++ - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, v) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) return offset } -func (p *ServerVariable) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServerVariable) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *ServerVariable) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServerVariable) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 4) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 4) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *ServerVariable) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("_default", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p._Default) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p._Default) return l } func (p *ServerVariable) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("enum", thrift.LIST, 2) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.Enum)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Enum { - l += bthrift.Binary.StringLengthNocopy(v) + _ = v + l += thrift.Binary.StringLengthNocopy(v) } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ServerVariable) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *ServerVariable) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 4) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ServerVariables) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -20976,51 +17741,34 @@ func (p *ServerVariables) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ServerVariables[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 *ServerVariables) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -21038,84 +17786,66 @@ func (p *ServerVariables) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *ServerVariables) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ServerVariables) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServerVariables) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ServerVariables") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ServerVariables) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("ServerVariables") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ServerVariables) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServerVariables) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *ServerVariables) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *SpecificationExtension) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -21132,7 +17862,7 @@ func (p *SpecificationExtension) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -21146,7 +17876,7 @@ func (p *SpecificationExtension) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -21160,58 +17890,39 @@ func (p *SpecificationExtension) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_SpecificationExtension[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 *SpecificationExtension) FastReadField1(buf []byte) (int, error) { offset := 0 var _field float64 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadDouble(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Number = _field return offset, nil @@ -21221,13 +17932,11 @@ func (p *SpecificationExtension) FastReadField2(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Boolean = _field return offset, nil @@ -21237,111 +17946,93 @@ func (p *SpecificationExtension) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.String_ = _field return offset, nil } -// for compatibility func (p *SpecificationExtension) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *SpecificationExtension) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SpecificationExtension) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SpecificationExtension") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *SpecificationExtension) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("SpecificationExtension") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *SpecificationExtension) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SpecificationExtension) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "number", thrift.DOUBLE, 1) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Number) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.DOUBLE, 1) + offset += thrift.Binary.WriteDouble(buf[offset:], p.Number) return offset } -func (p *SpecificationExtension) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SpecificationExtension) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "boolean", thrift.BOOL, 2) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Boolean) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 2) + offset += thrift.Binary.WriteBool(buf[offset:], p.Boolean) return offset } -func (p *SpecificationExtension) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *SpecificationExtension) fastWriteField3(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.String_) return offset } func (p *SpecificationExtension) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("number", thrift.DOUBLE, 1) - l += bthrift.Binary.DoubleLength(p.Number) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.DoubleLength() return l } func (p *SpecificationExtension) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("boolean", thrift.BOOL, 2) - l += bthrift.Binary.BoolLength(p.Boolean) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *SpecificationExtension) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("string", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.String_) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.String_) return l } func (p *StringArray) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -21358,51 +18049,34 @@ func (p *StringArray) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_StringArray[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 *StringArray) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -21410,95 +18084,75 @@ func (p *StringArray) FastReadField1(buf []byte) (int, error) { _field := make([]string, 0, size) for i := 0; i < size; i++ { var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _elem = v - } _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Values = _field return offset, nil } -// for compatibility func (p *StringArray) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *StringArray) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *StringArray) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "StringArray") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *StringArray) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("StringArray") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *StringArray) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *StringArray) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "values", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRING, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Values { length++ - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, v) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) return offset } func (p *StringArray) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("values", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.Values)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Values { - l += bthrift.Binary.StringLengthNocopy(v) + _ = v + l += thrift.Binary.StringLengthNocopy(v) } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Strings) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -21515,51 +18169,34 @@ func (p *Strings) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Strings[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 *Strings) FastReadField1(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -21577,84 +18214,66 @@ func (p *Strings) FastReadField1(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.AdditionalProperties = _field return offset, nil } -// for compatibility func (p *Strings) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Strings) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Strings) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Strings") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Strings) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Strings") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Strings) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Strings) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "additional_properties", thrift.LIST, 1) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 1) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.AdditionalProperties { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Strings) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("additional_properties", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.AdditionalProperties)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.AdditionalProperties { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Tag) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -21671,7 +18290,7 @@ func (p *Tag) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -21685,7 +18304,7 @@ func (p *Tag) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -21699,7 +18318,7 @@ func (p *Tag) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -21713,58 +18332,39 @@ func (p *Tag) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Tag[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 *Tag) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -21774,13 +18374,11 @@ func (p *Tag) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Description = _field return offset, nil @@ -21801,7 +18399,7 @@ func (p *Tag) FastReadField3(buf []byte) (int, error) { func (p *Tag) FastReadField4(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -21819,138 +18417,114 @@ func (p *Tag) FastReadField4(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Tag) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Tag) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Tag) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Tag") 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.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Tag) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Tag") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Tag) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Tag) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *Tag) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Tag) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "description", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Description) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Description) return offset } -func (p *Tag) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Tag) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "external_docs", thrift.STRUCT, 3) - offset += p.ExternalDocs.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 3) + offset += p.ExternalDocs.FastWriteNocopy(buf[offset:], w) return offset } -func (p *Tag) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Tag) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 4) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 4) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Tag) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *Tag) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("description", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Description) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Description) return l } func (p *Tag) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("external_docs", thrift.STRUCT, 3) + l += thrift.Binary.FieldBeginLength() l += p.ExternalDocs.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Tag) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 4) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *Xml) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -21967,7 +18541,7 @@ func (p *Xml) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -21981,7 +18555,7 @@ func (p *Xml) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -21995,7 +18569,7 @@ func (p *Xml) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -22009,7 +18583,7 @@ func (p *Xml) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -22023,7 +18597,7 @@ func (p *Xml) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -22037,58 +18611,39 @@ func (p *Xml) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Xml[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 *Xml) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -22098,13 +18653,11 @@ func (p *Xml) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Namespace = _field return offset, nil @@ -22114,13 +18667,11 @@ func (p *Xml) FastReadField3(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Prefix = _field return offset, nil @@ -22130,13 +18681,11 @@ func (p *Xml) FastReadField4(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Attribute = _field return offset, nil @@ -22146,13 +18695,11 @@ func (p *Xml) FastReadField5(buf []byte) (int, error) { offset := 0 var _field bool - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadBool(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Wrapped = _field return offset, nil @@ -22161,7 +18708,7 @@ func (p *Xml) FastReadField5(buf []byte) (int, error) { func (p *Xml) FastReadField6(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -22179,39 +18726,30 @@ func (p *Xml) FastReadField6(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.SpecificationExtension = _field return offset, nil } -// for compatibility func (p *Xml) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Xml) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Xml) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Xml") if p != nil { - offset += p.fastWriteField4(buf[offset:], binaryWriter) - 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.fastWriteField6(buf[offset:], binaryWriter) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Xml) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Xml") if p != nil { l += p.field1Length() l += p.field2Length() @@ -22220,115 +18758,101 @@ func (p *Xml) BLength() int { l += p.field5Length() l += p.field6Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Xml) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Xml) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *Xml) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Xml) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "namespace", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Namespace) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Namespace) return offset } -func (p *Xml) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Xml) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "prefix", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Prefix) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 3) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Prefix) return offset } -func (p *Xml) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Xml) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "attribute", thrift.BOOL, 4) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Attribute) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 4) + offset += thrift.Binary.WriteBool(buf[offset:], p.Attribute) return offset } -func (p *Xml) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Xml) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "wrapped", thrift.BOOL, 5) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Wrapped) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.BOOL, 5) + offset += thrift.Binary.WriteBool(buf[offset:], p.Wrapped) return offset } -func (p *Xml) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Xml) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "specification_extension", thrift.LIST, 6) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 6) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.SpecificationExtension { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } func (p *Xml) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *Xml) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("namespace", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Namespace) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Namespace) return l } func (p *Xml) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("prefix", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Prefix) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Prefix) return l } func (p *Xml) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("attribute", thrift.BOOL, 4) - l += bthrift.Binary.BoolLength(p.Attribute) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Xml) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("wrapped", thrift.BOOL, 5) - l += bthrift.Binary.BoolLength(p.Wrapped) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.BoolLength() return l } func (p *Xml) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("specification_extension", thrift.LIST, 6) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.SpecificationExtension)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.SpecificationExtension { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } diff --git a/bizdemo/kitex_swagger_gen/kitex_gen/openapi/openapi.go b/bizdemo/kitex_swagger_gen/kitex_gen/openapi/openapi.go index 697a805e..95b93907 100644 --- a/bizdemo/kitex_swagger_gen/kitex_gen/openapi/openapi.go +++ b/bizdemo/kitex_swagger_gen/kitex_gen/openapi/openapi.go @@ -1,13 +1,12 @@ -// Code generated by thriftgo (0.3.14). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package openapi import ( "bytes" "fmt" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" - - "github.com/apache/thrift/lib/go/thrift" ) type __ServiceOptions struct { @@ -115,6 +114,7 @@ func (p *__ServiceOptions) ReadField1(iprot thrift.TProtocol) error { } func (p *__ServiceOptions) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("_ServiceOptions"); err != nil { goto WriteStructBeginError @@ -292,6 +292,7 @@ func (p *__StructOptions) ReadField1(iprot thrift.TProtocol) error { } func (p *__StructOptions) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("_StructOptions"); err != nil { goto WriteStructBeginError @@ -469,6 +470,7 @@ func (p *__MethodOptions) ReadField1(iprot thrift.TProtocol) error { } func (p *__MethodOptions) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("_MethodOptions"); err != nil { goto WriteStructBeginError @@ -687,6 +689,7 @@ func (p *__FieldOptions) ReadField2(iprot thrift.TProtocol) error { } func (p *__FieldOptions) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("_FieldOptions"); err != nil { goto WriteStructBeginError @@ -915,6 +918,7 @@ func (p *AdditionalPropertiesItem) ReadField2(iprot thrift.TProtocol) error { } func (p *AdditionalPropertiesItem) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("AdditionalPropertiesItem"); err != nil { goto WriteStructBeginError @@ -1143,6 +1147,7 @@ func (p *Any) ReadField2(iprot thrift.TProtocol) error { } func (p *Any) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Any"); err != nil { goto WriteStructBeginError @@ -1365,6 +1370,7 @@ func (p *__Any) ReadField2(iprot thrift.TProtocol) error { } func (p *__Any) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("_Any"); err != nil { goto WriteStructBeginError @@ -1599,6 +1605,7 @@ func (p *AnyOrExpression) ReadField2(iprot thrift.TProtocol) error { } func (p *AnyOrExpression) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("AnyOrExpression"); err != nil { goto WriteStructBeginError @@ -1845,6 +1852,7 @@ func (p *Callback) ReadField2(iprot thrift.TProtocol) error { } func (p *Callback) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Callback"); err != nil { goto WriteStructBeginError @@ -2107,6 +2115,7 @@ func (p *CallbackOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *CallbackOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CallbackOrReference"); err != nil { goto WriteStructBeginError @@ -2313,6 +2322,7 @@ func (p *CallbacksOrReferences) ReadField1(iprot thrift.TProtocol) error { } func (p *CallbacksOrReferences) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CallbacksOrReferences"); err != nil { goto WriteStructBeginError @@ -2808,6 +2818,7 @@ func (p *Components) ReadField10(iprot thrift.TProtocol) error { } func (p *Components) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Components"); err != nil { goto WriteStructBeginError @@ -3360,6 +3371,7 @@ func (p *Contact) ReadField4(iprot thrift.TProtocol) error { } func (p *Contact) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Contact"); err != nil { goto WriteStructBeginError @@ -3686,6 +3698,7 @@ func (p *DefaultType) ReadField3(iprot thrift.TProtocol) error { } func (p *DefaultType) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DefaultType"); err != nil { goto WriteStructBeginError @@ -3985,6 +3998,7 @@ func (p *Discriminator) ReadField3(iprot thrift.TProtocol) error { } func (p *Discriminator) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Discriminator"); err != nil { goto WriteStructBeginError @@ -4520,6 +4534,7 @@ func (p *Document) ReadField9(iprot thrift.TProtocol) error { } func (p *Document) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Document"); err != nil { goto WriteStructBeginError @@ -5145,6 +5160,7 @@ func (p *Encoding) ReadField6(iprot thrift.TProtocol) error { } func (p *Encoding) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Encoding"); err != nil { goto WriteStructBeginError @@ -5489,6 +5505,7 @@ func (p *Encodings) ReadField1(iprot thrift.TProtocol) error { } func (p *Encodings) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Encodings"); err != nil { goto WriteStructBeginError @@ -5796,6 +5813,7 @@ func (p *Example) ReadField5(iprot thrift.TProtocol) error { } func (p *Example) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Example"); err != nil { goto WriteStructBeginError @@ -6137,6 +6155,7 @@ func (p *ExampleOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *ExampleOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("ExampleOrReference"); err != nil { goto WriteStructBeginError @@ -6343,6 +6362,7 @@ func (p *ExamplesOrReferences) ReadField1(iprot thrift.TProtocol) error { } func (p *ExamplesOrReferences) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("ExamplesOrReferences"); err != nil { goto WriteStructBeginError @@ -6532,6 +6552,7 @@ func (p *Expression) ReadField1(iprot thrift.TProtocol) error { } func (p *Expression) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Expression"); err != nil { goto WriteStructBeginError @@ -6777,6 +6798,7 @@ func (p *ExternalDocs) ReadField3(iprot thrift.TProtocol) error { } func (p *ExternalDocs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("ExternalDocs"); err != nil { goto WriteStructBeginError @@ -7360,6 +7382,7 @@ func (p *Header) ReadField12(iprot thrift.TProtocol) error { } func (p *Header) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Header"); err != nil { goto WriteStructBeginError @@ -7918,6 +7941,7 @@ func (p *HeaderOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *HeaderOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("HeaderOrReference"); err != nil { goto WriteStructBeginError @@ -8124,6 +8148,7 @@ func (p *HeadersOrReferences) ReadField1(iprot thrift.TProtocol) error { } func (p *HeadersOrReferences) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("HeadersOrReferences"); err != nil { goto WriteStructBeginError @@ -8521,6 +8546,7 @@ func (p *Info) ReadField8(iprot thrift.TProtocol) error { } func (p *Info) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Info"); err != nil { goto WriteStructBeginError @@ -8927,6 +8953,7 @@ func (p *ItemsItem) ReadField1(iprot thrift.TProtocol) error { } func (p *ItemsItem) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("ItemsItem"); err != nil { goto WriteStructBeginError @@ -9172,6 +9199,7 @@ func (p *License) ReadField3(iprot thrift.TProtocol) error { } func (p *License) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("License"); err != nil { goto WriteStructBeginError @@ -9609,6 +9637,7 @@ func (p *Link) ReadField7(iprot thrift.TProtocol) error { } func (p *Link) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Link"); err != nil { goto WriteStructBeginError @@ -10012,6 +10041,7 @@ func (p *LinkOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *LinkOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("LinkOrReference"); err != nil { goto WriteStructBeginError @@ -10218,6 +10248,7 @@ func (p *LinksOrReferences) ReadField1(iprot thrift.TProtocol) error { } func (p *LinksOrReferences) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("LinksOrReferences"); err != nil { goto WriteStructBeginError @@ -10543,6 +10574,7 @@ func (p *MediaType) ReadField5(iprot thrift.TProtocol) error { } func (p *MediaType) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("MediaType"); err != nil { goto WriteStructBeginError @@ -10856,6 +10888,7 @@ func (p *MediaTypes) ReadField1(iprot thrift.TProtocol) error { } func (p *MediaTypes) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("MediaTypes"); err != nil { goto WriteStructBeginError @@ -11067,6 +11100,7 @@ func (p *NamedAny) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedAny) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedAny"); err != nil { goto WriteStructBeginError @@ -11295,6 +11329,7 @@ func (p *NamedCallbackOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedCallbackOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedCallbackOrReference"); err != nil { goto WriteStructBeginError @@ -11523,6 +11558,7 @@ func (p *NamedEncoding) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedEncoding) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedEncoding"); err != nil { goto WriteStructBeginError @@ -11751,6 +11787,7 @@ func (p *NamedExampleOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedExampleOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedExampleOrReference"); err != nil { goto WriteStructBeginError @@ -11979,6 +12016,7 @@ func (p *NamedHeaderOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedHeaderOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedHeaderOrReference"); err != nil { goto WriteStructBeginError @@ -12207,6 +12245,7 @@ func (p *NamedLinkOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedLinkOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedLinkOrReference"); err != nil { goto WriteStructBeginError @@ -12435,6 +12474,7 @@ func (p *NamedMediaType) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedMediaType) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedMediaType"); err != nil { goto WriteStructBeginError @@ -12663,6 +12703,7 @@ func (p *NamedParameterOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedParameterOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedParameterOrReference"); err != nil { goto WriteStructBeginError @@ -12891,6 +12932,7 @@ func (p *NamedPathItem) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedPathItem) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedPathItem"); err != nil { goto WriteStructBeginError @@ -13119,6 +13161,7 @@ func (p *NamedRequestBodyOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedRequestBodyOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedRequestBodyOrReference"); err != nil { goto WriteStructBeginError @@ -13347,6 +13390,7 @@ func (p *NamedResponseOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedResponseOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedResponseOrReference"); err != nil { goto WriteStructBeginError @@ -13575,6 +13619,7 @@ func (p *NamedSchemaOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedSchemaOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedSchemaOrReference"); err != nil { goto WriteStructBeginError @@ -13803,6 +13848,7 @@ func (p *NamedSecuritySchemeOrReference) ReadField2(iprot thrift.TProtocol) erro } func (p *NamedSecuritySchemeOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedSecuritySchemeOrReference"); err != nil { goto WriteStructBeginError @@ -14031,6 +14077,7 @@ func (p *NamedServerVariable) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedServerVariable) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedServerVariable"); err != nil { goto WriteStructBeginError @@ -14253,6 +14300,7 @@ func (p *NamedString) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedString) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedString"); err != nil { goto WriteStructBeginError @@ -14481,6 +14529,7 @@ func (p *NamedStringArray) ReadField2(iprot thrift.TProtocol) error { } func (p *NamedStringArray) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("NamedStringArray"); err != nil { goto WriteStructBeginError @@ -14805,6 +14854,7 @@ func (p *OauthFlow) ReadField5(iprot thrift.TProtocol) error { } func (p *OauthFlow) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("OauthFlow"); err != nil { goto WriteStructBeginError @@ -15254,6 +15304,7 @@ func (p *OauthFlows) ReadField5(iprot thrift.TProtocol) error { } func (p *OauthFlows) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("OauthFlows"); err != nil { goto WriteStructBeginError @@ -15567,6 +15618,7 @@ func (p *Object) ReadField1(iprot thrift.TProtocol) error { } func (p *Object) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Object"); err != nil { goto WriteStructBeginError @@ -16164,6 +16216,7 @@ func (p *Operation) ReadField13(iprot thrift.TProtocol) error { } func (p *Operation) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Operation"); err != nil { goto WriteStructBeginError @@ -17169,6 +17222,7 @@ func (p *Parameter) ReadField14(iprot thrift.TProtocol) error { } func (p *Parameter) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Parameter"); err != nil { goto WriteStructBeginError @@ -17789,6 +17843,7 @@ func (p *ParameterOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *ParameterOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("ParameterOrReference"); err != nil { goto WriteStructBeginError @@ -17995,6 +18050,7 @@ func (p *ParametersOrReferences) ReadField1(iprot thrift.TProtocol) error { } func (p *ParametersOrReferences) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("ParametersOrReferences"); err != nil { goto WriteStructBeginError @@ -18620,6 +18676,7 @@ func (p *PathItem) ReadField14(iprot thrift.TProtocol) error { } func (p *PathItem) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("PathItem"); err != nil { goto WriteStructBeginError @@ -19280,6 +19337,7 @@ func (p *Paths) ReadField2(iprot thrift.TProtocol) error { } func (p *Paths) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Paths"); err != nil { goto WriteStructBeginError @@ -19514,6 +19572,7 @@ func (p *Properties) ReadField1(iprot thrift.TProtocol) error { } func (p *Properties) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Properties"); err != nil { goto WriteStructBeginError @@ -19747,6 +19806,7 @@ func (p *Reference) ReadField3(iprot thrift.TProtocol) error { } func (p *Reference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Reference"); err != nil { goto WriteStructBeginError @@ -20074,6 +20134,7 @@ func (p *RequestBody) ReadField4(iprot thrift.TProtocol) error { } func (p *RequestBody) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("RequestBody"); err != nil { goto WriteStructBeginError @@ -20384,6 +20445,7 @@ func (p *RequestBodyOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *RequestBodyOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("RequestBodyOrReference"); err != nil { goto WriteStructBeginError @@ -20590,6 +20652,7 @@ func (p *RequestBodiesOrReferences) ReadField1(iprot thrift.TProtocol) error { } func (p *RequestBodiesOrReferences) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("RequestBodiesOrReferences"); err != nil { goto WriteStructBeginError @@ -20909,6 +20972,7 @@ func (p *Response) ReadField5(iprot thrift.TProtocol) error { } func (p *Response) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Response"); err != nil { goto WriteStructBeginError @@ -21250,6 +21314,7 @@ func (p *ResponseOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *ResponseOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("ResponseOrReference"); err != nil { goto WriteStructBeginError @@ -21530,6 +21595,7 @@ func (p *Responses) ReadField3(iprot thrift.TProtocol) error { } func (p *Responses) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Responses"); err != nil { goto WriteStructBeginError @@ -21795,6 +21861,7 @@ func (p *ResponsesOrReferences) ReadField1(iprot thrift.TProtocol) error { } func (p *ResponsesOrReferences) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("ResponsesOrReferences"); err != nil { goto WriteStructBeginError @@ -23078,6 +23145,7 @@ func (p *Schema) ReadField36(iprot thrift.TProtocol) error { } func (p *Schema) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Schema"); err != nil { goto WriteStructBeginError @@ -24450,6 +24518,7 @@ func (p *SchemaOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *SchemaOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("SchemaOrReference"); err != nil { goto WriteStructBeginError @@ -24656,6 +24725,7 @@ func (p *SchemasOrReferences) ReadField1(iprot thrift.TProtocol) error { } func (p *SchemasOrReferences) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("SchemasOrReferences"); err != nil { goto WriteStructBeginError @@ -24845,6 +24915,7 @@ func (p *SecurityRequirement) ReadField1(iprot thrift.TProtocol) error { } func (p *SecurityRequirement) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("SecurityRequirement"); err != nil { goto WriteStructBeginError @@ -25264,6 +25335,7 @@ func (p *SecurityScheme) ReadField9(iprot thrift.TProtocol) error { } func (p *SecurityScheme) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("SecurityScheme"); err != nil { goto WriteStructBeginError @@ -25729,6 +25801,7 @@ func (p *SecuritySchemeOrReference) ReadField2(iprot thrift.TProtocol) error { } func (p *SecuritySchemeOrReference) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("SecuritySchemeOrReference"); err != nil { goto WriteStructBeginError @@ -25935,6 +26008,7 @@ func (p *SecuritySchemesOrReferences) ReadField1(iprot thrift.TProtocol) error { } func (p *SecuritySchemesOrReferences) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("SecuritySchemesOrReferences"); err != nil { goto WriteStructBeginError @@ -26214,6 +26288,7 @@ func (p *Server) ReadField4(iprot thrift.TProtocol) error { } func (p *Server) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Server"); err != nil { goto WriteStructBeginError @@ -26592,6 +26667,7 @@ func (p *ServerVariable) ReadField4(iprot thrift.TProtocol) error { } func (p *ServerVariable) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("ServerVariable"); err != nil { goto WriteStructBeginError @@ -26888,6 +26964,7 @@ func (p *ServerVariables) ReadField1(iprot thrift.TProtocol) error { } func (p *ServerVariables) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("ServerVariables"); err != nil { goto WriteStructBeginError @@ -27121,6 +27198,7 @@ func (p *SpecificationExtension) ReadField3(iprot thrift.TProtocol) error { } func (p *SpecificationExtension) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("SpecificationExtension"); err != nil { goto WriteStructBeginError @@ -27358,6 +27436,7 @@ func (p *StringArray) ReadField1(iprot thrift.TProtocol) error { } func (p *StringArray) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("StringArray"); err != nil { goto WriteStructBeginError @@ -27547,6 +27626,7 @@ func (p *Strings) ReadField1(iprot thrift.TProtocol) error { } func (p *Strings) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Strings"); err != nil { goto WriteStructBeginError @@ -27826,6 +27906,7 @@ func (p *Tag) ReadField4(iprot thrift.TProtocol) error { } func (p *Tag) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Tag"); err != nil { goto WriteStructBeginError @@ -28248,6 +28329,7 @@ func (p *Xml) ReadField6(iprot thrift.TProtocol) error { } func (p *Xml) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Xml"); err != nil { goto WriteStructBeginError diff --git a/bizdemo/kitex_swagger_gen/kitex_gen/user/k-user.go b/bizdemo/kitex_swagger_gen/kitex_gen/user/k-user.go index 11c3e116..06dd7abf 100644 --- a/bizdemo/kitex_swagger_gen/kitex_gen/user/k-user.go +++ b/bizdemo/kitex_swagger_gen/kitex_gen/user/k-user.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.10.3. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package user @@ -8,8 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" "github.com/cloudwego/kitex-examples/bizdemo/kitex_swagger_gen/kitex_gen/openapi" ) @@ -24,24 +23,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *User) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -58,7 +51,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -72,7 +65,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -86,7 +79,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -100,7 +93,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -114,58 +107,39 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_User[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 *User) FastReadField1(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.UserId = _field return offset, nil @@ -175,13 +149,11 @@ func (p *User) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -191,13 +163,12 @@ func (p *User) FastReadField3(buf []byte) (int, error) { offset := 0 var _field Gender - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l _field = Gender(v) - } p.Gender = _field return offset, nil @@ -207,13 +178,11 @@ func (p *User) FastReadField4(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Age = _field return offset, nil @@ -223,41 +192,35 @@ func (p *User) FastReadField5(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Introduce = _field return offset, nil } -// for compatibility func (p *User) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *User) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "User") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *User) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("User") if p != nil { l += p.field1Length() l += p.field2Length() @@ -265,105 +228,89 @@ func (p *User) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *User) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *User) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *User) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *User) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *User) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *User) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *User) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *User) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 3) - l += bthrift.Binary.I32Length(int32(p.Gender)) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *User) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Age) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *User) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *CreateUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -380,7 +327,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -394,7 +341,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -408,7 +355,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -422,58 +369,39 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateUserRequest[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 *CreateUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -483,13 +411,12 @@ func (p *CreateUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 var _field Gender - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l _field = Gender(v) - } p.Gender = _field return offset, nil @@ -499,13 +426,11 @@ func (p *CreateUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Age = _field return offset, nil @@ -515,129 +440,109 @@ func (p *CreateUserRequest) FastReadField4(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Introduce = _field return offset, nil } -// for compatibility func (p *CreateUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUserRequest") if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *CreateUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 2) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *CreateUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *CreateUserRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 4) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *CreateUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *CreateUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 2) - l += bthrift.Binary.I32Length(int32(p.Gender)) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *CreateUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.Age) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *CreateUserRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *CreateUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -654,7 +559,7 @@ func (p *CreateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -668,58 +573,40 @@ func (p *CreateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateUserResponse[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 *CreateUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 var _field Code - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l _field = Code(v) - } p.Code = _field return offset, nil @@ -729,93 +616,77 @@ func (p *CreateUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Msg = _field return offset, nil } -// for compatibility func (p *CreateUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *CreateUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *CreateUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *CreateUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *QueryUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -832,7 +703,7 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -846,7 +717,7 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -860,57 +731,39 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryUserRequest[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 *QueryUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 var _field *string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l _field = &v - } p.Keyword = _field return offset, nil @@ -920,13 +773,11 @@ func (p *QueryUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Page = _field return offset, nil @@ -936,115 +787,97 @@ func (p *QueryUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.PageSize = _field return offset, nil } -// for compatibility func (p *QueryUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUserRequest") if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 if p.IsSetKeyword() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Keyword", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Keyword) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, *p.Keyword) } return offset } -func (p *QueryUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "page", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Page) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 2) + offset += thrift.Binary.WriteI64(buf[offset:], p.Page) return offset } -func (p *QueryUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "page_size", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.PageSize) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.PageSize) return offset } func (p *QueryUserRequest) field1Length() int { l := 0 if p.IsSetKeyword() { - l += bthrift.Binary.FieldBeginLength("Keyword", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(*p.Keyword) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(*p.Keyword) } return l } func (p *QueryUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("page", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.Page) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("page_size", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.PageSize) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1061,7 +894,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1075,7 +908,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1089,7 +922,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1103,58 +936,40 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryUserResponse[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 *QueryUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 var _field Code - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l _field = Code(v) - } p.Code = _field return offset, nil @@ -1164,13 +979,11 @@ func (p *QueryUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Msg = _field return offset, nil @@ -1179,7 +992,7 @@ func (p *QueryUserResponse) FastReadField2(buf []byte) (int, error) { func (p *QueryUserResponse) FastReadField3(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err @@ -1197,11 +1010,6 @@ func (p *QueryUserResponse) FastReadField3(buf []byte) (int, error) { _field = append(_field, _elem) } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } p.Users = _field return offset, nil } @@ -1210,141 +1018,120 @@ func (p *QueryUserResponse) FastReadField4(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Total = _field return offset, nil } -// for compatibility func (p *QueryUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUserResponse") if p != nil { - offset += p.fastWriteField4(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:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *QueryUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } -func (p *QueryUserResponse) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "users", thrift.LIST, 3) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 3) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Users { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *QueryUserResponse) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "total", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Total) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Total) return offset } func (p *QueryUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *QueryUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *QueryUserResponse) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("users", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Users)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Users { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *QueryUserResponse) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("total", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Total) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1361,120 +1148,89 @@ func (p *DeleteUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteUserRequest[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 *DeleteUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.UserId = _field return offset, nil } -// for compatibility func (p *DeleteUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUserRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUserRequest") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } func (p *DeleteUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1491,7 +1247,7 @@ func (p *DeleteUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1505,58 +1261,40 @@ func (p *DeleteUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteUserResponse[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 *DeleteUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 var _field Code - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l _field = Code(v) - } p.Code = _field return offset, nil @@ -1566,93 +1304,77 @@ func (p *DeleteUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Msg = _field return offset, nil } -// for compatibility func (p *DeleteUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *DeleteUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *DeleteUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *DeleteUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *UpdateUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1669,7 +1391,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1683,7 +1405,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1697,7 +1419,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1711,7 +1433,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1725,58 +1447,39 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateUserRequest[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 *UpdateUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.UserId = _field return offset, nil @@ -1786,13 +1489,11 @@ func (p *UpdateUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Name = _field return offset, nil @@ -1802,13 +1503,12 @@ func (p *UpdateUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 var _field Gender - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l _field = Gender(v) - } p.Gender = _field return offset, nil @@ -1818,13 +1518,11 @@ func (p *UpdateUserRequest) FastReadField4(buf []byte) (int, error) { offset := 0 var _field int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Age = _field return offset, nil @@ -1834,41 +1532,35 @@ func (p *UpdateUserRequest) FastReadField5(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Introduce = _field return offset, nil } -// for compatibility func (p *UpdateUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUserRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() @@ -1876,105 +1568,89 @@ func (p *UpdateUserRequest) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *UpdateUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *UpdateUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *UpdateUserRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *UpdateUserRequest) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *UpdateUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Name) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *UpdateUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 3) - l += bthrift.Binary.I32Length(int32(p.Gender)) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *UpdateUserRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Age) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateUserRequest) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *UpdateUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1991,7 +1667,7 @@ func (p *UpdateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -2005,58 +1681,40 @@ func (p *UpdateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateUserResponse[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 *UpdateUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 var _field Code - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l _field = Code(v) - } p.Code = _field return offset, nil @@ -2066,93 +1724,77 @@ func (p *UpdateUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 var _field string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _field = v - } p.Msg = _field return offset, nil } -// for compatibility func (p *UpdateUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *UpdateUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *UpdateUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *UpdateUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *UserServiceUpdateUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2169,45 +1811,28 @@ func (p *UserServiceUpdateUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceUpdateUserArgs[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 *UserServiceUpdateUserArgs) FastReadField1(buf []byte) (int, error) { @@ -2222,63 +1847,51 @@ func (p *UserServiceUpdateUserArgs) FastReadField1(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *UserServiceUpdateUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceUpdateUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceUpdateUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceUpdateUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceUpdateUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceUpdateUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2295,45 +1908,28 @@ func (p *UserServiceUpdateUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceUpdateUserResult[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 *UserServiceUpdateUserResult) FastReadField0(buf []byte) (int, error) { @@ -2348,39 +1944,33 @@ func (p *UserServiceUpdateUserResult) FastReadField0(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *UserServiceUpdateUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceUpdateUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceUpdateUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2388,27 +1978,21 @@ func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceUpdateUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceDeleteUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2425,45 +2009,28 @@ func (p *UserServiceDeleteUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceDeleteUserArgs[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 *UserServiceDeleteUserArgs) FastReadField1(buf []byte) (int, error) { @@ -2478,63 +2045,51 @@ func (p *UserServiceDeleteUserArgs) FastReadField1(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *UserServiceDeleteUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceDeleteUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceDeleteUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceDeleteUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceDeleteUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceDeleteUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2551,45 +2106,28 @@ func (p *UserServiceDeleteUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceDeleteUserResult[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 *UserServiceDeleteUserResult) FastReadField0(buf []byte) (int, error) { @@ -2604,39 +2142,33 @@ func (p *UserServiceDeleteUserResult) FastReadField0(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *UserServiceDeleteUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceDeleteUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceDeleteUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2644,27 +2176,21 @@ func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceDeleteUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceQueryUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2681,45 +2207,28 @@ func (p *UserServiceQueryUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceQueryUserArgs[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 *UserServiceQueryUserArgs) FastReadField1(buf []byte) (int, error) { @@ -2734,63 +2243,51 @@ func (p *UserServiceQueryUserArgs) FastReadField1(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *UserServiceQueryUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceQueryUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceQueryUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceQueryUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceQueryUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceQueryUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2807,45 +2304,28 @@ func (p *UserServiceQueryUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceQueryUserResult[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 *UserServiceQueryUserResult) FastReadField0(buf []byte) (int, error) { @@ -2860,39 +2340,33 @@ func (p *UserServiceQueryUserResult) FastReadField0(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *UserServiceQueryUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceQueryUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceQueryUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2900,27 +2374,21 @@ func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, binaryWriter bt func (p *UserServiceQueryUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceCreateUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2937,45 +2405,28 @@ func (p *UserServiceCreateUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceCreateUserArgs[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 *UserServiceCreateUserArgs) FastReadField1(buf []byte) (int, error) { @@ -2990,63 +2441,51 @@ func (p *UserServiceCreateUserArgs) FastReadField1(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *UserServiceCreateUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceCreateUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceCreateUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceCreateUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceCreateUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceCreateUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3063,45 +2502,28 @@ func (p *UserServiceCreateUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceCreateUserResult[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 *UserServiceCreateUserResult) FastReadField0(buf []byte) (int, error) { @@ -3116,39 +2538,33 @@ func (p *UserServiceCreateUserResult) FastReadField0(buf []byte) (int, error) { return offset, nil } -// for compatibility func (p *UserServiceCreateUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceCreateUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceCreateUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -3156,9 +2572,8 @@ func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceCreateUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/bizdemo/kitex_swagger_gen/kitex_gen/user/user.go b/bizdemo/kitex_swagger_gen/kitex_gen/user/user.go index fdabb3b6..89b120e0 100644 --- a/bizdemo/kitex_swagger_gen/kitex_gen/user/user.go +++ b/bizdemo/kitex_swagger_gen/kitex_gen/user/user.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.3.14). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package user @@ -7,9 +7,8 @@ import ( "database/sql" "database/sql/driver" "fmt" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" - - "github.com/apache/thrift/lib/go/thrift" ) type Code int64 @@ -309,6 +308,7 @@ func (p *User) ReadField5(iprot thrift.TProtocol) error { } func (p *User) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("User"); err != nil { goto WriteStructBeginError @@ -680,6 +680,7 @@ func (p *CreateUserRequest) ReadField4(iprot thrift.TProtocol) error { } func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUserRequest"); err != nil { goto WriteStructBeginError @@ -964,6 +965,7 @@ func (p *CreateUserResponse) ReadField2(iprot thrift.TProtocol) error { } func (p *CreateUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUserResponse"); err != nil { goto WriteStructBeginError @@ -1223,6 +1225,7 @@ func (p *QueryUserRequest) ReadField3(iprot thrift.TProtocol) error { } func (p *QueryUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUserRequest"); err != nil { goto WriteStructBeginError @@ -1551,6 +1554,7 @@ func (p *QueryUserResponse) ReadField4(iprot thrift.TProtocol) error { } func (p *QueryUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUserResponse"); err != nil { goto WriteStructBeginError @@ -1821,6 +1825,7 @@ func (p *DeleteUserRequest) ReadField1(iprot thrift.TProtocol) error { } func (p *DeleteUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUserRequest"); err != nil { goto WriteStructBeginError @@ -2012,6 +2017,7 @@ func (p *DeleteUserResponse) ReadField2(iprot thrift.TProtocol) error { } func (p *DeleteUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUserResponse"); err != nil { goto WriteStructBeginError @@ -2318,6 +2324,7 @@ func (p *UpdateUserRequest) ReadField5(iprot thrift.TProtocol) error { } func (p *UpdateUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUserRequest"); err != nil { goto WriteStructBeginError @@ -2633,6 +2640,7 @@ func (p *UpdateUserResponse) ReadField2(iprot thrift.TProtocol) error { } func (p *UpdateUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUserResponse"); err != nil { goto WriteStructBeginError @@ -2843,6 +2851,7 @@ func (p *UserServiceUpdateUserArgs) ReadField1(iprot thrift.TProtocol) error { } func (p *UserServiceUpdateUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUser_args"); err != nil { goto WriteStructBeginError @@ -3012,6 +3021,7 @@ func (p *UserServiceUpdateUserResult) ReadField0(iprot thrift.TProtocol) error { } func (p *UserServiceUpdateUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUser_result"); err != nil { goto WriteStructBeginError @@ -3183,6 +3193,7 @@ func (p *UserServiceDeleteUserArgs) ReadField1(iprot thrift.TProtocol) error { } func (p *UserServiceDeleteUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUser_args"); err != nil { goto WriteStructBeginError @@ -3352,6 +3363,7 @@ func (p *UserServiceDeleteUserResult) ReadField0(iprot thrift.TProtocol) error { } func (p *UserServiceDeleteUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUser_result"); err != nil { goto WriteStructBeginError @@ -3523,6 +3535,7 @@ func (p *UserServiceQueryUserArgs) ReadField1(iprot thrift.TProtocol) error { } func (p *UserServiceQueryUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUser_args"); err != nil { goto WriteStructBeginError @@ -3692,6 +3705,7 @@ func (p *UserServiceQueryUserResult) ReadField0(iprot thrift.TProtocol) error { } func (p *UserServiceQueryUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUser_result"); err != nil { goto WriteStructBeginError @@ -3863,6 +3877,7 @@ func (p *UserServiceCreateUserArgs) ReadField1(iprot thrift.TProtocol) error { } func (p *UserServiceCreateUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUser_args"); err != nil { goto WriteStructBeginError @@ -4032,6 +4047,7 @@ func (p *UserServiceCreateUserResult) ReadField0(iprot thrift.TProtocol) error { } func (p *UserServiceCreateUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUser_result"); err != nil { goto WriteStructBeginError diff --git a/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/client.go b/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/client.go index ea8334b3..0cd05892 100644 --- a/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/client.go +++ b/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/client.go @@ -1,10 +1,9 @@ -// Code generated by Kitex v0.10.3. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( "context" - user "github.com/cloudwego/kitex-examples/bizdemo/kitex_swagger_gen/kitex_gen/user" client "github.com/cloudwego/kitex/client" callopt "github.com/cloudwego/kitex/client/callopt" diff --git a/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/server.go b/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/server.go index 64ff13db..38b23a39 100644 --- a/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/server.go +++ b/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.10.3. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( diff --git a/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/userservice.go b/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/userservice.go index af9b9612..d3d555d8 100644 --- a/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/userservice.go +++ b/bizdemo/kitex_swagger_gen/kitex_gen/user/userservice/userservice.go @@ -1,11 +1,10 @@ -// Code generated by Kitex v0.10.3. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( "context" "errors" - user "github.com/cloudwego/kitex-examples/bizdemo/kitex_swagger_gen/kitex_gen/user" client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" @@ -102,7 +101,7 @@ func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreami HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.10.3", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/bizdemo/kitex_zorm/go.mod b/bizdemo/kitex_zorm/go.mod index 40343d60..b3e058df 100644 --- a/bizdemo/kitex_zorm/go.mod +++ b/bizdemo/kitex_zorm/go.mod @@ -6,28 +6,29 @@ replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 require ( gitee.com/chunanyong/zorm v1.7.5 - github.com/apache/thrift v0.13.0 - github.com/cloudwego/kitex v0.11.3 + github.com/cloudwego/gopkg v0.1.3 + github.com/cloudwego/kitex v0.12.0 + github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 ) require ( + github.com/apache/thrift v0.13.0 // indirect github.com/bytedance/gopkg v0.1.1 // indirect - github.com/bytedance/sonic v1.12.2 // indirect + github.com/bytedance/sonic v1.12.5 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/configmanager v0.2.2 // indirect - github.com/cloudwego/dynamicgo v0.4.0 // indirect + github.com/cloudwego/dynamicgo v0.4.6 // indirect github.com/cloudwego/fastpb v0.0.5 // indirect - github.com/cloudwego/frugal v0.2.0 // indirect - github.com/cloudwego/gopkg v0.1.2 // indirect + github.com/cloudwego/frugal v0.2.3 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cloudwego/localsession v0.0.2 // indirect - github.com/cloudwego/netpoll v0.6.4 // indirect + github.com/cloudwego/localsession v0.1.1 // indirect + github.com/cloudwego/netpoll v0.6.5 // indirect github.com/cloudwego/runtimex v0.1.0 // indirect - github.com/cloudwego/thriftgo v0.3.17 // indirect + github.com/cloudwego/thriftgo v0.3.18 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fatih/structtag v1.2.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect github.com/iancoleman/strcase v0.2.0 // indirect github.com/jhump/protoreflect v1.8.2 // indirect @@ -48,6 +49,6 @@ require ( golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/bizdemo/kitex_zorm/go.sum b/bizdemo/kitex_zorm/go.sum index 365dfe31..e15f0ffd 100644 --- a/bizdemo/kitex_zorm/go.sum +++ b/bizdemo/kitex_zorm/go.sum @@ -9,8 +9,8 @@ github.com/bytedance/gopkg v0.1.0/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvD github.com/bytedance/gopkg v0.1.1 h1:3azzgSkiaw79u24a+w9arfH8OfnQQ4MHUt9lJFREEaE= github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic v1.12.2 h1:oaMFuRTpMHYLpCntGca65YWt5ny+wAceDERTkT2L9lg= -github.com/bytedance/sonic v1.12.2/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= +github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= @@ -20,26 +20,28 @@ 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/configmanager v0.2.2 h1:sVrJB8gWYTlPV2OS3wcgJSO9F2/9Zbkmcm1Z7jempOU= github.com/cloudwego/configmanager v0.2.2/go.mod h1:ppiyU+5TPLonE8qMVi/pFQk2eL3Q4P7d4hbiNJn6jwI= -github.com/cloudwego/dynamicgo v0.4.0 h1:wQqNRNiSQaLkbcn3sfpEJGZsz3xf8Il4P/3DcENsrFI= -github.com/cloudwego/dynamicgo v0.4.0/go.mod h1:zgWk2oz56EyH790LJSxrTz1j01GJBO964jJQ/y7qjJc= +github.com/cloudwego/dynamicgo v0.4.6 h1:raRdvLN1WsGl5WsNd2Ul86s8PFQPu8soF4ALSJ9MdC4= +github.com/cloudwego/dynamicgo v0.4.6/go.mod h1:DknfxjIMuGvXow409bS/AWycXONdc02HECBL0qpNqTY= github.com/cloudwego/fastpb v0.0.5 h1:vYnBPsfbAtU5TVz5+f9UTlmSCixG9F9vRwaqE0mZPZU= github.com/cloudwego/fastpb v0.0.5/go.mod h1:Bho7aAKBUtT9RPD2cNVkTdx4yQumfSv3If7wYnm1izk= -github.com/cloudwego/frugal v0.2.0 h1:0ETSzQYoYqVvdl7EKjqJ9aJnDoG6TzvNKV3PMQiQTS8= -github.com/cloudwego/frugal v0.2.0/go.mod h1:cpnV6kdRMjN3ylxRo63RNbZ9rBK6oxs70Zk6QZ4Enj4= -github.com/cloudwego/gopkg v0.1.2 h1:650t+RiZGht8qX+y0hl49JXJCuO44GhbGZuxDzr2PyI= -github.com/cloudwego/gopkg v0.1.2/go.mod h1:WoNTdXDPdvL97cBmRUWXVGkh2l2UFmpd9BUvbW2r0Aw= +github.com/cloudwego/frugal v0.2.3 h1:t1hhhAi8lXcx7Ncs4PR1pSZ90vlDU1cy5K2btDMFpoA= +github.com/cloudwego/frugal v0.2.3/go.mod h1:nC1U47gswLRiaxv6dybrhZvsDGCfQP9RGiiWC73CnoI= +github.com/cloudwego/gopkg v0.1.3 h1:y9VA5Zn5yqd1+QBV9aB0Zxy56JlAS7x4ZUoED/vJdxA= +github.com/cloudwego/gopkg v0.1.3/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= 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.11.3 h1:Qy1GtyuNbygMpwnMw+Aj1iS7fSd0IO7CzxtpZrRJ+Jc= -github.com/cloudwego/kitex v0.11.3/go.mod h1:RHT9ERKFVppJjBfGvwJAPxCIzf4oN1yASW5S4pPZNu4= -github.com/cloudwego/localsession v0.0.2 h1:N9/IDtCPj1fCL9bCTP+DbXx3f40YjVYWcwkJG0YhQkY= -github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= -github.com/cloudwego/netpoll v0.6.4 h1:z/dA4sOTUQof6zZIO4QNnLBXsDFFFEos9OOGloR6kno= -github.com/cloudwego/netpoll v0.6.4/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= +github.com/cloudwego/kitex v0.12.0 h1:TeNlAAkWc3MOIGnBQj+FcSUBan+3TBpzitnrviH0AXM= +github.com/cloudwego/kitex v0.12.0/go.mod h1:k2wQJ+3LPjQJHbBs0xE2k6z8SVRcUpB3/eRO34oM0nQ= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 h1:jU6gpAkJ3HZLZeSpxrL1xaCd/auvAbLs0SN/ylXn9TA= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2/go.mod h1:OP63V8YwwSlPVFqHZblV3mJXLPIjcIdwkT6ZYjEggcI= +github.com/cloudwego/localsession v0.1.1 h1:tbK7laDVrYfFDXoBXo4uCGMAxU4qmz2dDm8d4BGBnDo= +github.com/cloudwego/localsession v0.1.1/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= +github.com/cloudwego/netpoll v0.6.5 h1:6E/BWhSzQoyLg9Kx/4xiMdIIpovzwBtXvuqSqaTUzDQ= +github.com/cloudwego/netpoll v0.6.5/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= 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.17 h1:k0iQe2jEAN1WhPsXWvatwHzoxObUSX2Nw5NqdnywS8k= -github.com/cloudwego/thriftgo v0.3.17/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= +github.com/cloudwego/thriftgo v0.3.18 h1:gnr1vz7G3RbwwCK9AMKHZf63VYGa7ene6WbI9VrBJSw= +github.com/cloudwego/thriftgo v0.3.18/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= 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= @@ -66,8 +68,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -243,8 +246,8 @@ 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.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/bizdemo/kitex_zorm/kitex_gen/user/k-user.go b/bizdemo/kitex_zorm/kitex_gen/user/k-user.go index 8901cc14..c3ad759a 100644 --- a/bizdemo/kitex_zorm/kitex_gen/user/k-user.go +++ b/bizdemo/kitex_zorm/kitex_gen/user/k-user.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package user @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,24 +17,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *User) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -53,7 +45,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -67,7 +59,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -81,7 +73,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -95,7 +87,7 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -109,140 +101,120 @@ func (p *User) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_User[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 *User) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *User) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *User) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *User) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *User) FastReadField5(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *User) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *User) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "User") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *User) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("User") if p != nil { l += p.field1Length() l += p.field2Length() @@ -250,115 +222,89 @@ func (p *User) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *User) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *User) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *User) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *User) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *User) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *User) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *User) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *User) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *User) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 3) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *User) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *User) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *CreateUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -375,7 +321,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -389,7 +335,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -403,7 +349,7 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -417,222 +363,180 @@ func (p *CreateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateUserRequest[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 *CreateUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *CreateUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *CreateUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *CreateUserRequest) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *CreateUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUserRequest") if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *CreateUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 2) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *CreateUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *CreateUserRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 4) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *CreateUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *CreateUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 2) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *CreateUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *CreateUserRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *CreateUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -649,7 +553,7 @@ func (p *CreateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -663,154 +567,120 @@ func (p *CreateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_CreateUserResponse[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 *CreateUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *CreateUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *CreateUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *CreateUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *CreateUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *CreateUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *CreateUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *CreateUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *CreateUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *CreateUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *QueryUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -827,7 +697,7 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -841,7 +711,7 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -855,191 +725,153 @@ func (p *QueryUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryUserRequest[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 *QueryUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field *string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Keyword = &v - + _field = &v } + p.Keyword = _field return offset, nil } func (p *QueryUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Page = v - + _field = v } + p.Page = _field return offset, nil } func (p *QueryUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.PageSize = v - + _field = v } + p.PageSize = _field return offset, nil } -// for compatibility func (p *QueryUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUserRequest") if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 if p.IsSetKeyword() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Keyword", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Keyword) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, *p.Keyword) } return offset } -func (p *QueryUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "page", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Page) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 2) + offset += thrift.Binary.WriteI64(buf[offset:], p.Page) return offset } -func (p *QueryUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "page_size", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.PageSize) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 3) + offset += thrift.Binary.WriteI64(buf[offset:], p.PageSize) return offset } func (p *QueryUserRequest) field1Length() int { l := 0 if p.IsSetKeyword() { - l += bthrift.Binary.FieldBeginLength("Keyword", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(*p.Keyword) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(*p.Keyword) } return l } func (p *QueryUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("page", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.Page) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("page_size", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.PageSize) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *QueryUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1056,7 +888,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1070,7 +902,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1084,7 +916,7 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1098,245 +930,202 @@ func (p *QueryUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_QueryUserResponse[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 *QueryUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *QueryUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } func (p *QueryUserResponse) FastReadField3(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err } - p.Users = make([]*User, 0, size) + _field := make([]*User, 0, size) + values := make([]User, size) for i := 0; i < size; i++ { - _elem := NewUser() + _elem := &values[i] + _elem.InitDefault() if l, err := _elem.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Users = append(p.Users, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + _field = append(_field, _elem) } + p.Users = _field return offset, nil } func (p *QueryUserResponse) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Totoal = v - + _field = v } + p.Totoal = _field return offset, nil } -// for compatibility func (p *QueryUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *QueryUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUserResponse") if p != nil { - offset += p.fastWriteField4(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:], w) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *QueryUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field3Length() l += p.field4Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *QueryUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *QueryUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } -func (p *QueryUserResponse) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "users", thrift.LIST, 3) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 3) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Users { length++ - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + offset += v.FastWriteNocopy(buf[offset:], w) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) return offset } -func (p *QueryUserResponse) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *QueryUserResponse) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "totoal", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Totoal) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Totoal) return offset } func (p *QueryUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *QueryUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *QueryUserResponse) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("users", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Users)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Users { + _ = v l += v.BLength() } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *QueryUserResponse) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("totoal", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Totoal) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1353,120 +1142,89 @@ func (p *DeleteUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteUserRequest[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 *DeleteUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } -// for compatibility func (p *DeleteUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUserRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUserRequest") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } func (p *DeleteUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *DeleteUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1483,7 +1241,7 @@ func (p *DeleteUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1497,154 +1255,120 @@ func (p *DeleteUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_DeleteUserResponse[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 *DeleteUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *DeleteUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *DeleteUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *DeleteUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *DeleteUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *DeleteUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *DeleteUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *DeleteUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *DeleteUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *DeleteUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *UpdateUserRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1661,7 +1385,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1675,7 +1399,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1689,7 +1413,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1703,7 +1427,7 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1717,140 +1441,120 @@ func (p *UpdateUserRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateUserRequest[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 *UpdateUserRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.UserId = v - + _field = v } + p.UserId = _field return offset, nil } func (p *UpdateUserRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Name = v - + _field = v } + p.Name = _field return offset, nil } func (p *UpdateUserRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Gender + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Gender = Gender(v) - + _field = Gender(v) } + p.Gender = _field return offset, nil } func (p *UpdateUserRequest) FastReadField4(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Age = v - + _field = v } + p.Age = _field return offset, nil } func (p *UpdateUserRequest) FastReadField5(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Introduce = v - + _field = v } + p.Introduce = _field return offset, nil } -// for compatibility func (p *UpdateUserRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateUserRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUserRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField4(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + } + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateUserRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUserRequest") if p != nil { l += p.field1Length() l += p.field2Length() @@ -1858,115 +1562,89 @@ func (p *UpdateUserRequest) BLength() int { l += p.field4Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateUserRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "user_id", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.UserId) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.UserId) return offset } -func (p *UpdateUserRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "name", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Name) return offset } -func (p *UpdateUserRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "gender", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Gender)) return offset } -func (p *UpdateUserRequest) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField4(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "age", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Age) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 4) + offset += thrift.Binary.WriteI64(buf[offset:], p.Age) return offset } -func (p *UpdateUserRequest) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserRequest) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "introduce", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Introduce) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 5) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Introduce) return offset } func (p *UpdateUserRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("user_id", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.UserId) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateUserRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("name", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Name) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Name) return l } func (p *UpdateUserRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("gender", thrift.I32, 3) - l += bthrift.Binary.I32Length(int32(p.Gender)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *UpdateUserRequest) field4Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("age", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Age) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *UpdateUserRequest) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("introduce", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.Introduce) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Introduce) return l } func (p *UpdateUserResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1983,7 +1661,7 @@ func (p *UpdateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -1997,154 +1675,120 @@ func (p *UpdateUserResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UpdateUserResponse[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 *UpdateUserResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field Code + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - p.Code = Code(v) - + _field = Code(v) } + p.Code = _field return offset, nil } func (p *UpdateUserResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Msg = v - + _field = v } + p.Msg = _field return offset, nil } -// for compatibility func (p *UpdateUserResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UpdateUserResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUserResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UpdateUserResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUserResponse") if p != nil { l += p.field1Length() l += p.field2Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UpdateUserResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Code)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], int32(p.Code)) return offset } -func (p *UpdateUserResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UpdateUserResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Msg) return offset } func (p *UpdateUserResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(int32(p.Code)) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *UpdateUserResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Msg) return l } func (p *UserServiceUpdateUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2161,117 +1805,87 @@ func (p *UserServiceUpdateUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceUpdateUserArgs[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 *UserServiceUpdateUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewUpdateUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewUpdateUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceUpdateUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceUpdateUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceUpdateUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceUpdateUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceUpdateUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceUpdateUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2288,93 +1902,69 @@ func (p *UserServiceUpdateUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceUpdateUserResult[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 *UserServiceUpdateUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewUpdateUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewUpdateUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceUpdateUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceUpdateUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "UpdateUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceUpdateUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("UpdateUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2382,27 +1972,21 @@ func (p *UserServiceUpdateUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceUpdateUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceDeleteUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2419,117 +2003,87 @@ func (p *UserServiceDeleteUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceDeleteUserArgs[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 *UserServiceDeleteUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewDeleteUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewDeleteUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceDeleteUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceDeleteUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceDeleteUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceDeleteUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceDeleteUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceDeleteUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2546,93 +2100,69 @@ func (p *UserServiceDeleteUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceDeleteUserResult[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 *UserServiceDeleteUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewDeleteUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewDeleteUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceDeleteUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceDeleteUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeleteUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceDeleteUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("DeleteUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2640,27 +2170,21 @@ func (p *UserServiceDeleteUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceDeleteUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceQueryUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2677,117 +2201,87 @@ func (p *UserServiceQueryUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceQueryUserArgs[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 *UserServiceQueryUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewQueryUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewQueryUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceQueryUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceQueryUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceQueryUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceQueryUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceQueryUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceQueryUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2804,93 +2298,69 @@ func (p *UserServiceQueryUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceQueryUserResult[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 *UserServiceQueryUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewQueryUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewQueryUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceQueryUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceQueryUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "QueryUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceQueryUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("QueryUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -2898,27 +2368,21 @@ func (p *UserServiceQueryUserResult) fastWriteField0(buf []byte, binaryWriter bt func (p *UserServiceQueryUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *UserServiceCreateUserArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -2935,117 +2399,87 @@ func (p *UserServiceCreateUserArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceCreateUserArgs[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 *UserServiceCreateUserArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewCreateUserRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewCreateUserRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *UserServiceCreateUserArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceCreateUserArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUser_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceCreateUserArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUser_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceCreateUserArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *UserServiceCreateUserArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *UserServiceCreateUserResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -3062,93 +2496,69 @@ func (p *UserServiceCreateUserResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_UserServiceCreateUserResult[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 *UserServiceCreateUserResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewCreateUserResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewCreateUserResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *UserServiceCreateUserResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *UserServiceCreateUserResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "CreateUser_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *UserServiceCreateUserResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("CreateUser_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -3156,9 +2566,8 @@ func (p *UserServiceCreateUserResult) fastWriteField0(buf []byte, binaryWriter b func (p *UserServiceCreateUserResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/bizdemo/kitex_zorm/kitex_gen/user/user.go b/bizdemo/kitex_zorm/kitex_gen/user/user.go index b18a5d72..ef643911 100644 --- a/bizdemo/kitex_zorm/kitex_gen/user/user.go +++ b/bizdemo/kitex_zorm/kitex_gen/user/user.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.2.12). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package user @@ -7,7 +7,7 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" ) @@ -118,7 +118,6 @@ func NewUser() *User { } func (p *User) InitDefault() { - *p = User{} } func (p *User) GetUserId() (v int64) { @@ -188,57 +187,46 @@ func (p *User) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -264,51 +252,63 @@ ReadStructEndError: } func (p *User) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *User) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *User) ReadField3(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *User) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *User) ReadField5(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *User) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("User"); err != nil { goto WriteStructBeginError @@ -334,7 +334,6 @@ func (p *User) Write(oprot thrift.TProtocol) (err error) { fieldId = 5 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -443,6 +442,7 @@ func (p *User) String() string { return "" } return fmt.Sprintf("User(%+v)", *p) + } func (p *User) DeepEqual(ano *User) bool { @@ -517,7 +517,6 @@ func NewCreateUserRequest() *CreateUserRequest { } func (p *CreateUserRequest) InitDefault() { - *p = CreateUserRequest{} } func (p *CreateUserRequest) GetName() (v string) { @@ -579,47 +578,38 @@ func (p *CreateUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -645,42 +635,52 @@ ReadStructEndError: } func (p *CreateUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *CreateUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *CreateUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *CreateUserRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUserRequest"); err != nil { goto WriteStructBeginError @@ -702,7 +702,6 @@ func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -794,6 +793,7 @@ func (p *CreateUserRequest) String() string { return "" } return fmt.Sprintf("CreateUserRequest(%+v)", *p) + } func (p *CreateUserRequest) DeepEqual(ano *CreateUserRequest) bool { @@ -856,7 +856,6 @@ func NewCreateUserResponse() *CreateUserResponse { } func (p *CreateUserResponse) InitDefault() { - *p = CreateUserResponse{} } func (p *CreateUserResponse) GetCode() (v Code) { @@ -902,27 +901,22 @@ func (p *CreateUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -948,24 +942,30 @@ ReadStructEndError: } func (p *CreateUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *CreateUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *CreateUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUserResponse"); err != nil { goto WriteStructBeginError @@ -979,7 +979,6 @@ func (p *CreateUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1037,6 +1036,7 @@ func (p *CreateUserResponse) String() string { return "" } return fmt.Sprintf("CreateUserResponse(%+v)", *p) + } func (p *CreateUserResponse) DeepEqual(ano *CreateUserResponse) bool { @@ -1080,7 +1080,6 @@ func NewQueryUserRequest() *QueryUserRequest { } func (p *QueryUserRequest) InitDefault() { - *p = QueryUserRequest{} } var QueryUserRequest_Keyword_DEFAULT string @@ -1143,37 +1142,30 @@ func (p *QueryUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1199,33 +1191,41 @@ ReadStructEndError: } func (p *QueryUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field *string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Keyword = &v + _field = &v } + p.Keyword = _field return nil } - func (p *QueryUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Page = v + _field = v } + p.Page = _field return nil } - func (p *QueryUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.PageSize = v + _field = v } + p.PageSize = _field return nil } func (p *QueryUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUserRequest"); err != nil { goto WriteStructBeginError @@ -1243,7 +1243,6 @@ func (p *QueryUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 3 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1320,6 +1319,7 @@ func (p *QueryUserRequest) String() string { return "" } return fmt.Sprintf("QueryUserRequest(%+v)", *p) + } func (p *QueryUserRequest) DeepEqual(ano *QueryUserRequest) bool { @@ -1379,7 +1379,6 @@ func NewQueryUserResponse() *QueryUserResponse { } func (p *QueryUserResponse) InitDefault() { - *p = QueryUserResponse{} } func (p *QueryUserResponse) GetCode() (v Code) { @@ -1441,47 +1440,38 @@ func (p *QueryUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -1507,53 +1497,64 @@ ReadStructEndError: } func (p *QueryUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *QueryUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } - func (p *QueryUserResponse) ReadField3(iprot thrift.TProtocol) error { _, size, err := iprot.ReadListBegin() if err != nil { return err } - p.Users = make([]*User, 0, size) + _field := make([]*User, 0, size) + values := make([]User, size) for i := 0; i < size; i++ { - _elem := NewUser() + _elem := &values[i] + _elem.InitDefault() + if err := _elem.Read(iprot); err != nil { return err } - p.Users = append(p.Users, _elem) + _field = append(_field, _elem) } if err := iprot.ReadListEnd(); err != nil { return err } + p.Users = _field return nil } - func (p *QueryUserResponse) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Totoal = v + _field = v } + p.Totoal = _field return nil } func (p *QueryUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUserResponse"); err != nil { goto WriteStructBeginError @@ -1575,7 +1576,6 @@ func (p *QueryUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 4 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1675,6 +1675,7 @@ func (p *QueryUserResponse) String() string { return "" } return fmt.Sprintf("QueryUserResponse(%+v)", *p) + } func (p *QueryUserResponse) DeepEqual(ano *QueryUserResponse) bool { @@ -1742,7 +1743,6 @@ func NewDeleteUserRequest() *DeleteUserRequest { } func (p *DeleteUserRequest) InitDefault() { - *p = DeleteUserRequest{} } func (p *DeleteUserRequest) GetUserId() (v int64) { @@ -1780,17 +1780,14 @@ func (p *DeleteUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1816,15 +1813,19 @@ ReadStructEndError: } func (p *DeleteUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } func (p *DeleteUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUserRequest"); err != nil { goto WriteStructBeginError @@ -1834,7 +1835,6 @@ func (p *DeleteUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1875,6 +1875,7 @@ func (p *DeleteUserRequest) String() string { return "" } return fmt.Sprintf("DeleteUserRequest(%+v)", *p) + } func (p *DeleteUserRequest) DeepEqual(ano *DeleteUserRequest) bool { @@ -1907,7 +1908,6 @@ func NewDeleteUserResponse() *DeleteUserResponse { } func (p *DeleteUserResponse) InitDefault() { - *p = DeleteUserResponse{} } func (p *DeleteUserResponse) GetCode() (v Code) { @@ -1953,27 +1953,22 @@ func (p *DeleteUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -1999,24 +1994,30 @@ ReadStructEndError: } func (p *DeleteUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *DeleteUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *DeleteUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUserResponse"); err != nil { goto WriteStructBeginError @@ -2030,7 +2031,6 @@ func (p *DeleteUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2088,6 +2088,7 @@ func (p *DeleteUserResponse) String() string { return "" } return fmt.Sprintf("DeleteUserResponse(%+v)", *p) + } func (p *DeleteUserResponse) DeepEqual(ano *DeleteUserResponse) bool { @@ -2133,7 +2134,6 @@ func NewUpdateUserRequest() *UpdateUserRequest { } func (p *UpdateUserRequest) InitDefault() { - *p = UpdateUserRequest{} } func (p *UpdateUserRequest) GetUserId() (v int64) { @@ -2203,57 +2203,46 @@ func (p *UpdateUserRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 - } + } 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 - } + } 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 } @@ -2279,51 +2268,63 @@ ReadStructEndError: } func (p *UpdateUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.UserId = v + _field = v } + p.UserId = _field return nil } - func (p *UpdateUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Name = v + _field = v } + p.Name = _field return nil } - func (p *UpdateUserRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field Gender if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Gender = Gender(v) + _field = Gender(v) } + p.Gender = _field return nil } - func (p *UpdateUserRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Age = v + _field = v } + p.Age = _field return nil } - func (p *UpdateUserRequest) ReadField5(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Introduce = v + _field = v } + p.Introduce = _field return nil } func (p *UpdateUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUserRequest"); err != nil { goto WriteStructBeginError @@ -2349,7 +2350,6 @@ func (p *UpdateUserRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 5 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2458,6 +2458,7 @@ func (p *UpdateUserRequest) String() string { return "" } return fmt.Sprintf("UpdateUserRequest(%+v)", *p) + } func (p *UpdateUserRequest) DeepEqual(ano *UpdateUserRequest) bool { @@ -2530,7 +2531,6 @@ func NewUpdateUserResponse() *UpdateUserResponse { } func (p *UpdateUserResponse) InitDefault() { - *p = UpdateUserResponse{} } func (p *UpdateUserResponse) GetCode() (v Code) { @@ -2576,27 +2576,22 @@ func (p *UpdateUserResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 } @@ -2622,24 +2617,30 @@ ReadStructEndError: } func (p *UpdateUserResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field Code if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Code = Code(v) + _field = Code(v) } + p.Code = _field return nil } - func (p *UpdateUserResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Msg = v + _field = v } + p.Msg = _field return nil } func (p *UpdateUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUserResponse"); err != nil { goto WriteStructBeginError @@ -2653,7 +2654,6 @@ func (p *UpdateUserResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -2711,6 +2711,7 @@ func (p *UpdateUserResponse) String() string { return "" } return fmt.Sprintf("UpdateUserResponse(%+v)", *p) + } func (p *UpdateUserResponse) DeepEqual(ano *UpdateUserResponse) bool { @@ -2753,305 +2754,6 @@ type UserService interface { CreateUser(ctx context.Context, req *CreateUserRequest) (r *CreateUserResponse, err error) } -type UserServiceClient struct { - c thrift.TClient -} - -func NewUserServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *UserServiceClient { - return &UserServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewUserServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *UserServiceClient { - return &UserServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewUserServiceClient(c thrift.TClient) *UserServiceClient { - return &UserServiceClient{ - c: c, - } -} - -func (p *UserServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *UserServiceClient) UpdateUser(ctx context.Context, req *UpdateUserRequest) (r *UpdateUserResponse, err error) { - var _args UserServiceUpdateUserArgs - _args.Req = req - var _result UserServiceUpdateUserResult - if err = p.Client_().Call(ctx, "UpdateUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) DeleteUser(ctx context.Context, req *DeleteUserRequest) (r *DeleteUserResponse, err error) { - var _args UserServiceDeleteUserArgs - _args.Req = req - var _result UserServiceDeleteUserResult - if err = p.Client_().Call(ctx, "DeleteUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) QueryUser(ctx context.Context, req *QueryUserRequest) (r *QueryUserResponse, err error) { - var _args UserServiceQueryUserArgs - _args.Req = req - var _result UserServiceQueryUserResult - if err = p.Client_().Call(ctx, "QueryUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *UserServiceClient) CreateUser(ctx context.Context, req *CreateUserRequest) (r *CreateUserResponse, err error) { - var _args UserServiceCreateUserArgs - _args.Req = req - var _result UserServiceCreateUserResult - if err = p.Client_().Call(ctx, "CreateUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type UserServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler UserService -} - -func (p *UserServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *UserServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *UserServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewUserServiceProcessor(handler UserService) *UserServiceProcessor { - self := &UserServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("UpdateUser", &userServiceProcessorUpdateUser{handler: handler}) - self.AddToProcessorMap("DeleteUser", &userServiceProcessorDeleteUser{handler: handler}) - self.AddToProcessorMap("QueryUser", &userServiceProcessorQueryUser{handler: handler}) - self.AddToProcessorMap("CreateUser", &userServiceProcessorCreateUser{handler: handler}) - return self -} -func (p *UserServiceProcessor) 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 userServiceProcessorUpdateUser struct { - handler UserService -} - -func (p *userServiceProcessorUpdateUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceUpdateUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("UpdateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceUpdateUserResult{} - var retval *UpdateUserResponse - if retval, err2 = p.handler.UpdateUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing UpdateUser: "+err2.Error()) - oprot.WriteMessageBegin("UpdateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("UpdateUser", 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 userServiceProcessorDeleteUser struct { - handler UserService -} - -func (p *userServiceProcessorDeleteUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceDeleteUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("DeleteUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceDeleteUserResult{} - var retval *DeleteUserResponse - if retval, err2 = p.handler.DeleteUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing DeleteUser: "+err2.Error()) - oprot.WriteMessageBegin("DeleteUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("DeleteUser", 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 userServiceProcessorQueryUser struct { - handler UserService -} - -func (p *userServiceProcessorQueryUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceQueryUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("QueryUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceQueryUserResult{} - var retval *QueryUserResponse - if retval, err2 = p.handler.QueryUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing QueryUser: "+err2.Error()) - oprot.WriteMessageBegin("QueryUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("QueryUser", 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 userServiceProcessorCreateUser struct { - handler UserService -} - -func (p *userServiceProcessorCreateUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := UserServiceCreateUserArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("CreateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := UserServiceCreateUserResult{} - var retval *CreateUserResponse - if retval, err2 = p.handler.CreateUser(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing CreateUser: "+err2.Error()) - oprot.WriteMessageBegin("CreateUser", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("CreateUser", 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 UserServiceUpdateUserArgs struct { Req *UpdateUserRequest `thrift:"req,1" frugal:"1,default,UpdateUserRequest" json:"req"` } @@ -3061,7 +2763,6 @@ func NewUserServiceUpdateUserArgs() *UserServiceUpdateUserArgs { } func (p *UserServiceUpdateUserArgs) InitDefault() { - *p = UserServiceUpdateUserArgs{} } var UserServiceUpdateUserArgs_Req_DEFAULT *UpdateUserRequest @@ -3108,17 +2809,14 @@ func (p *UserServiceUpdateUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3144,14 +2842,16 @@ ReadStructEndError: } func (p *UserServiceUpdateUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewUpdateUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewUpdateUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceUpdateUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUser_args"); err != nil { goto WriteStructBeginError @@ -3161,7 +2861,6 @@ func (p *UserServiceUpdateUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3202,6 +2901,7 @@ func (p *UserServiceUpdateUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceUpdateUserArgs(%+v)", *p) + } func (p *UserServiceUpdateUserArgs) DeepEqual(ano *UserServiceUpdateUserArgs) bool { @@ -3233,7 +2933,6 @@ func NewUserServiceUpdateUserResult() *UserServiceUpdateUserResult { } func (p *UserServiceUpdateUserResult) InitDefault() { - *p = UserServiceUpdateUserResult{} } var UserServiceUpdateUserResult_Success_DEFAULT *UpdateUserResponse @@ -3280,17 +2979,14 @@ func (p *UserServiceUpdateUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3316,14 +3012,16 @@ ReadStructEndError: } func (p *UserServiceUpdateUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewUpdateUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewUpdateUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceUpdateUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("UpdateUser_result"); err != nil { goto WriteStructBeginError @@ -3333,7 +3031,6 @@ func (p *UserServiceUpdateUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3376,6 +3073,7 @@ func (p *UserServiceUpdateUserResult) String() string { return "" } return fmt.Sprintf("UserServiceUpdateUserResult(%+v)", *p) + } func (p *UserServiceUpdateUserResult) DeepEqual(ano *UserServiceUpdateUserResult) bool { @@ -3407,7 +3105,6 @@ func NewUserServiceDeleteUserArgs() *UserServiceDeleteUserArgs { } func (p *UserServiceDeleteUserArgs) InitDefault() { - *p = UserServiceDeleteUserArgs{} } var UserServiceDeleteUserArgs_Req_DEFAULT *DeleteUserRequest @@ -3454,17 +3151,14 @@ func (p *UserServiceDeleteUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3490,14 +3184,16 @@ ReadStructEndError: } func (p *UserServiceDeleteUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewDeleteUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewDeleteUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceDeleteUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUser_args"); err != nil { goto WriteStructBeginError @@ -3507,7 +3203,6 @@ func (p *UserServiceDeleteUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3548,6 +3243,7 @@ func (p *UserServiceDeleteUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceDeleteUserArgs(%+v)", *p) + } func (p *UserServiceDeleteUserArgs) DeepEqual(ano *UserServiceDeleteUserArgs) bool { @@ -3579,7 +3275,6 @@ func NewUserServiceDeleteUserResult() *UserServiceDeleteUserResult { } func (p *UserServiceDeleteUserResult) InitDefault() { - *p = UserServiceDeleteUserResult{} } var UserServiceDeleteUserResult_Success_DEFAULT *DeleteUserResponse @@ -3626,17 +3321,14 @@ func (p *UserServiceDeleteUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3662,14 +3354,16 @@ ReadStructEndError: } func (p *UserServiceDeleteUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewDeleteUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewDeleteUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceDeleteUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("DeleteUser_result"); err != nil { goto WriteStructBeginError @@ -3679,7 +3373,6 @@ func (p *UserServiceDeleteUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3722,6 +3415,7 @@ func (p *UserServiceDeleteUserResult) String() string { return "" } return fmt.Sprintf("UserServiceDeleteUserResult(%+v)", *p) + } func (p *UserServiceDeleteUserResult) DeepEqual(ano *UserServiceDeleteUserResult) bool { @@ -3753,7 +3447,6 @@ func NewUserServiceQueryUserArgs() *UserServiceQueryUserArgs { } func (p *UserServiceQueryUserArgs) InitDefault() { - *p = UserServiceQueryUserArgs{} } var UserServiceQueryUserArgs_Req_DEFAULT *QueryUserRequest @@ -3800,17 +3493,14 @@ func (p *UserServiceQueryUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -3836,14 +3526,16 @@ ReadStructEndError: } func (p *UserServiceQueryUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewQueryUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewQueryUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceQueryUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUser_args"); err != nil { goto WriteStructBeginError @@ -3853,7 +3545,6 @@ func (p *UserServiceQueryUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -3894,6 +3585,7 @@ func (p *UserServiceQueryUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceQueryUserArgs(%+v)", *p) + } func (p *UserServiceQueryUserArgs) DeepEqual(ano *UserServiceQueryUserArgs) bool { @@ -3925,7 +3617,6 @@ func NewUserServiceQueryUserResult() *UserServiceQueryUserResult { } func (p *UserServiceQueryUserResult) InitDefault() { - *p = UserServiceQueryUserResult{} } var UserServiceQueryUserResult_Success_DEFAULT *QueryUserResponse @@ -3972,17 +3663,14 @@ func (p *UserServiceQueryUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4008,14 +3696,16 @@ ReadStructEndError: } func (p *UserServiceQueryUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewQueryUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewQueryUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceQueryUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("QueryUser_result"); err != nil { goto WriteStructBeginError @@ -4025,7 +3715,6 @@ func (p *UserServiceQueryUserResult) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4068,6 +3757,7 @@ func (p *UserServiceQueryUserResult) String() string { return "" } return fmt.Sprintf("UserServiceQueryUserResult(%+v)", *p) + } func (p *UserServiceQueryUserResult) DeepEqual(ano *UserServiceQueryUserResult) bool { @@ -4099,7 +3789,6 @@ func NewUserServiceCreateUserArgs() *UserServiceCreateUserArgs { } func (p *UserServiceCreateUserArgs) InitDefault() { - *p = UserServiceCreateUserArgs{} } var UserServiceCreateUserArgs_Req_DEFAULT *CreateUserRequest @@ -4146,17 +3835,14 @@ func (p *UserServiceCreateUserArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4182,14 +3868,16 @@ ReadStructEndError: } func (p *UserServiceCreateUserArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewCreateUserRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewCreateUserRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *UserServiceCreateUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUser_args"); err != nil { goto WriteStructBeginError @@ -4199,7 +3887,6 @@ func (p *UserServiceCreateUserArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4240,6 +3927,7 @@ func (p *UserServiceCreateUserArgs) String() string { return "" } return fmt.Sprintf("UserServiceCreateUserArgs(%+v)", *p) + } func (p *UserServiceCreateUserArgs) DeepEqual(ano *UserServiceCreateUserArgs) bool { @@ -4271,7 +3959,6 @@ func NewUserServiceCreateUserResult() *UserServiceCreateUserResult { } func (p *UserServiceCreateUserResult) InitDefault() { - *p = UserServiceCreateUserResult{} } var UserServiceCreateUserResult_Success_DEFAULT *CreateUserResponse @@ -4318,17 +4005,14 @@ func (p *UserServiceCreateUserResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -4354,14 +4038,16 @@ ReadStructEndError: } func (p *UserServiceCreateUserResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewCreateUserResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewCreateUserResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *UserServiceCreateUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("CreateUser_result"); err != nil { goto WriteStructBeginError @@ -4371,7 +4057,6 @@ func (p *UserServiceCreateUserResult) Write(oprot thrift.TProtocol) (err error) fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4414,6 +4099,7 @@ func (p *UserServiceCreateUserResult) String() string { return "" } return fmt.Sprintf("UserServiceCreateUserResult(%+v)", *p) + } func (p *UserServiceCreateUserResult) DeepEqual(ano *UserServiceCreateUserResult) bool { diff --git a/bizdemo/kitex_zorm/kitex_gen/user/userservice/client.go b/bizdemo/kitex_zorm/kitex_gen/user/userservice/client.go index 8fdd6816..70f09713 100644 --- a/bizdemo/kitex_zorm/kitex_gen/user/userservice/client.go +++ b/bizdemo/kitex_zorm/kitex_gen/user/userservice/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice @@ -24,7 +24,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/bizdemo/kitex_zorm/kitex_gen/user/userservice/server.go b/bizdemo/kitex_zorm/kitex_gen/user/userservice/server.go index dfa2a19d..48b59dd1 100644 --- a/bizdemo/kitex_zorm/kitex_gen/user/userservice/server.go +++ b/bizdemo/kitex_zorm/kitex_gen/user/userservice/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( @@ -11,6 +11,7 @@ func NewServer(handler user.UserService, opts ...server.Option) server.Server { var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler user.UserService, opts ...server.Option) server.Server { } return svr } + +func RegisterService(svr server.Server, handler user.UserService, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/bizdemo/kitex_zorm/kitex_gen/user/userservice/userservice.go b/bizdemo/kitex_zorm/kitex_gen/user/userservice/userservice.go index a119f075..9b0c6e50 100644 --- a/bizdemo/kitex_zorm/kitex_gen/user/userservice/userservice.go +++ b/bizdemo/kitex_zorm/kitex_gen/user/userservice/userservice.go @@ -1,39 +1,107 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package userservice import ( "context" + "errors" user "github.com/cloudwego/kitex-examples/bizdemo/kitex_zorm/kitex_gen/user" client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "UpdateUser": kitex.NewMethodInfo( + updateUserHandler, + newUserServiceUpdateUserArgs, + newUserServiceUpdateUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "DeleteUser": kitex.NewMethodInfo( + deleteUserHandler, + newUserServiceDeleteUserArgs, + newUserServiceDeleteUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "QueryUser": kitex.NewMethodInfo( + queryUserHandler, + newUserServiceQueryUserArgs, + newUserServiceQueryUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "CreateUser": kitex.NewMethodInfo( + createUserHandler, + newUserServiceCreateUserArgs, + newUserServiceCreateUserResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + userServiceServiceInfo = NewServiceInfo() + userServiceServiceInfoForClient = NewServiceInfoForClient() + userServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return userServiceServiceInfo } -var userServiceServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return userServiceServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return userServiceServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "UserService" handlerType := (*user.UserService)(nil) - methods := map[string]kitex.MethodInfo{ - "UpdateUser": kitex.NewMethodInfo(updateUserHandler, newUserServiceUpdateUserArgs, newUserServiceUpdateUserResult, false), - "DeleteUser": kitex.NewMethodInfo(deleteUserHandler, newUserServiceDeleteUserArgs, newUserServiceDeleteUserResult, false), - "QueryUser": kitex.NewMethodInfo(queryUserHandler, newUserServiceQueryUserArgs, newUserServiceQueryUserResult, false), - "CreateUser": kitex.NewMethodInfo(createUserHandler, newUserServiceCreateUserArgs, newUserServiceCreateUserResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ - "PackageName": "user", - "ServiceFilePath": `idl/user.thrift`, + "PackageName": "user", + } + if hasStreaming { + extra["streaming"] = hasStreaming } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/codec/json/meta.go b/codec/json/meta.go index 5f1030e8..a3c136ba 100644 --- a/codec/json/meta.go +++ b/codec/json/meta.go @@ -15,7 +15,7 @@ package json -import "github.com/apache/thrift/lib/go/thrift" +import "github.com/cloudwego/gopkg/protocol/thrift" type Meta struct { ServiceName string @@ -34,5 +34,5 @@ func (e Exception) Error() string { if e.Message != "" { return e.Message } - return thrift.NewTApplicationException(e.TypeID, "").Error() + return thrift.NewApplicationException(e.TypeID, "").Error() } diff --git a/frugal/codec/frugal.go b/frugal/codec/frugal.go index d590bc63..21991d14 100644 --- a/frugal/codec/frugal.go +++ b/frugal/codec/frugal.go @@ -19,9 +19,8 @@ import ( "fmt" "reflect" - "github.com/apache/thrift/lib/go/thrift" "github.com/cloudwego/frugal" - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" "github.com/cloudwego/kitex-examples/kitex_gen/api" ) @@ -45,19 +44,18 @@ func FrugalEncode(data interface{}, meta Meta) ([]byte, error) { return nil, fmt.Errorf("frugal tag missing") } // calculate and malloc message buffer - msgBeginLen := bthrift.Binary.MessageBeginLength(meta.MethodName, meta.MessageType, meta.SeqID) - msgEndLen := bthrift.Binary.MessageEndLength() + msgBeginLen := thrift.Binary.MessageBeginLength(meta.MethodName) + msgEndLen := 0 objectLen := frugal.EncodedSize(data) buf := make([]byte, msgBeginLen+objectLen+msgEndLen) // encode message - offset := bthrift.Binary.WriteMessageBegin(buf, meta.MethodName, meta.MessageType, meta.SeqID) + offset := thrift.Binary.WriteMessageBegin(buf, meta.MethodName, meta.MessageType, meta.SeqID) writeLen, err := frugal.EncodeObject(buf[offset:], nil, data) if err != nil { return buf, fmt.Errorf("thrift marshal, frugal.EncodeObject failed: %s", err.Error()) } offset += writeLen - bthrift.Binary.WriteMessageEnd(buf[offset:]) return buf, nil } @@ -65,7 +63,7 @@ func FrugalDecode(buf []byte, data interface{}) (Meta, error) { if !HasFrugalTag(data) { return Meta{}, fmt.Errorf("frugal tag missing") } - methodName, messageType, seqID, length, err := bthrift.Binary.ReadMessageBegin(buf) + methodName, messageType, seqID, length, err := thrift.Binary.ReadMessageBegin(buf) if err != nil { return Meta{}, err } diff --git a/generic/binary/client/main.go b/generic/binary/client/main.go index 6102f729..27b4bab5 100644 --- a/generic/binary/client/main.go +++ b/generic/binary/client/main.go @@ -20,33 +20,34 @@ import ( "log" "time" - "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/kitex/transport" + + "github.com/cloudwego/gopkg/protocol/thrift" "github.com/cloudwego/kitex-examples/kitex_gen/api" "github.com/cloudwego/kitex/client" "github.com/cloudwego/kitex/client/genericclient" "github.com/cloudwego/kitex/pkg/generic" "github.com/cloudwego/kitex/pkg/klog" - "github.com/cloudwego/kitex/pkg/utils" ) func main() { - genericCli, err := genericclient.NewClient("echo", generic.BinaryThriftGeneric(), client.WithHostPorts("0.0.0.0:8888")) + genericCli, err := genericclient.NewClient("echo", generic.BinaryThriftGeneric(), client.WithTransportProtocol(transport.TTHeader), client.WithHostPorts("0.0.0.0:8888")) if err != nil { log.Fatal(err) } - codec := utils.NewThriftMessageCodec() for { ctx := context.Background() - buf, err := codec.Encode("echo", thrift.CALL, 0, &api.EchoEchoArgs{Req: &api.Request{Message: "my request"}}) + buf, err := thrift.MarshalFastMsg("echo", thrift.CALL, 0, &api.EchoEchoArgs{Req: &api.Request{Message: "my request"}}) if err != nil { klog.Fatal(err) } resp, err := genericCli.GenericCall(ctx, "echo", buf) if err != nil { klog.Errorf("call echo failed: %w\n", err) + continue } result := &api.EchoEchoResult{} - _, _, err = codec.Decode(resp.([]byte), result) + _, _, err = thrift.UnmarshalFastMsg(resp.([]byte), result) if err != nil { klog.Fatal(err) } diff --git a/generic/kitex_gen/http/bizservice/bizservice.go b/generic/kitex_gen/http/bizservice/bizservice.go index 3a561fd4..b0bc259e 100644 --- a/generic/kitex_gen/http/bizservice/bizservice.go +++ b/generic/kitex_gen/http/bizservice/bizservice.go @@ -1,37 +1,100 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package bizservice import ( "context" - "github.com/cloudwego/kitex-examples/generic/kitex_gen/http" - "github.com/cloudwego/kitex/client" + "errors" + http "github.com/cloudwego/kitex-examples/generic/kitex_gen/http" + client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "BizMethod1": kitex.NewMethodInfo( + bizMethod1Handler, + newBizServiceBizMethod1Args, + newBizServiceBizMethod1Result, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "BizMethod2": kitex.NewMethodInfo( + bizMethod2Handler, + newBizServiceBizMethod2Args, + newBizServiceBizMethod2Result, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "BizMethod3": kitex.NewMethodInfo( + bizMethod3Handler, + newBizServiceBizMethod3Args, + newBizServiceBizMethod3Result, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + bizServiceServiceInfo = NewServiceInfo() + bizServiceServiceInfoForClient = NewServiceInfoForClient() + bizServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return bizServiceServiceInfo } -var bizServiceServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return bizServiceServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return bizServiceServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "BizService" handlerType := (*http.BizService)(nil) - methods := map[string]kitex.MethodInfo{ - "BizMethod1": kitex.NewMethodInfo(bizMethod1Handler, newBizServiceBizMethod1Args, newBizServiceBizMethod1Result, false), - "BizMethod2": kitex.NewMethodInfo(bizMethod2Handler, newBizServiceBizMethod2Args, newBizServiceBizMethod2Result, false), - "BizMethod3": kitex.NewMethodInfo(bizMethod3Handler, newBizServiceBizMethod3Args, newBizServiceBizMethod3Result, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ "PackageName": "http", } + if hasStreaming { + extra["streaming"] = hasStreaming + } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.1.4", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/generic/kitex_gen/http/bizservice/client.go b/generic/kitex_gen/http/bizservice/client.go index f3580c52..031602bd 100644 --- a/generic/kitex_gen/http/bizservice/client.go +++ b/generic/kitex_gen/http/bizservice/client.go @@ -1,12 +1,12 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package bizservice import ( "context" - "github.com/cloudwego/kitex-examples/generic/kitex_gen/http" - "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt" + http "github.com/cloudwego/kitex-examples/generic/kitex_gen/http" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. @@ -23,7 +23,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/generic/kitex_gen/http/bizservice/server.go b/generic/kitex_gen/http/bizservice/server.go index 6eab5f43..5bd1be87 100644 --- a/generic/kitex_gen/http/bizservice/server.go +++ b/generic/kitex_gen/http/bizservice/server.go @@ -1,9 +1,9 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package bizservice import ( - "github.com/cloudwego/kitex-examples/generic/kitex_gen/http" - "github.com/cloudwego/kitex/server" + http "github.com/cloudwego/kitex-examples/generic/kitex_gen/http" + server "github.com/cloudwego/kitex/server" ) // NewServer creates a server.Server with the given handler and options. @@ -11,6 +11,7 @@ func NewServer(handler http.BizService, opts ...server.Option) server.Server { var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler http.BizService, opts ...server.Option) server.Server { } return svr } + +func RegisterService(svr server.Server, handler http.BizService, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/generic/kitex_gen/http/http.go b/generic/kitex_gen/http/http.go index d2e8e228..b4764b36 100644 --- a/generic/kitex_gen/http/http.go +++ b/generic/kitex_gen/http/http.go @@ -1,43 +1,46 @@ -// Code generated by thriftgo (0.1.2). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package http import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" ) type BizRequest struct { - Vint64 int64 `thrift:"vint64,1" json:"vint64"` - Text string `thrift:"text,2" json:"text"` - Token int32 `thrift:"token,3" json:"token"` - Items []string `thrift:"items,6" json:"items"` - Version int32 `thrift:"version,7" json:"version"` + Vint64 int64 `thrift:"vint64,1" frugal:"1,default,i64" json:"vint64"` + Text string `thrift:"text,2" frugal:"2,default,string" json:"text"` + Token int32 `thrift:"token,3" frugal:"3,default,i32" json:"token"` + Items []string `thrift:"items,6" frugal:"6,default,list" json:"items"` + Version int32 `thrift:"version,7" frugal:"7,default,i32" json:"version"` } func NewBizRequest() *BizRequest { return &BizRequest{} } -func (p *BizRequest) GetVint64() int64 { +func (p *BizRequest) InitDefault() { +} + +func (p *BizRequest) GetVint64() (v int64) { return p.Vint64 } -func (p *BizRequest) GetText() string { +func (p *BizRequest) GetText() (v string) { return p.Text } -func (p *BizRequest) GetToken() int32 { +func (p *BizRequest) GetToken() (v int32) { return p.Token } -func (p *BizRequest) GetItems() []string { +func (p *BizRequest) GetItems() (v []string) { return p.Items } -func (p *BizRequest) GetVersion() int32 { +func (p *BizRequest) GetVersion() (v int32) { return p.Version } func (p *BizRequest) SetVint64(val int64) { @@ -88,57 +91,46 @@ func (p *BizRequest) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError } case 6: if fieldTypeId == thrift.LIST { if err = p.ReadField6(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError } case 7: if fieldTypeId == thrift.I32 { if err = p.ReadField7(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -164,39 +156,46 @@ ReadStructEndError: } func (p *BizRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field int64 if v, err := iprot.ReadI64(); err != nil { return err } else { - p.Vint64 = v + _field = v } + p.Vint64 = _field return nil } - func (p *BizRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Text = v + _field = v } + p.Text = _field return nil } - func (p *BizRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int32 if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Token = v + _field = v } + p.Token = _field return nil } - func (p *BizRequest) ReadField6(iprot thrift.TProtocol) error { _, size, err := iprot.ReadListBegin() if err != nil { return err } - p.Items = make([]string, 0, size) + _field := make([]string, 0, size) for i := 0; i < size; i++ { + var _elem string if v, err := iprot.ReadString(); err != nil { return err @@ -204,24 +203,28 @@ func (p *BizRequest) ReadField6(iprot thrift.TProtocol) error { _elem = v } - p.Items = append(p.Items, _elem) + _field = append(_field, _elem) } if err := iprot.ReadListEnd(); err != nil { return err } + p.Items = _field return nil } - func (p *BizRequest) ReadField7(iprot thrift.TProtocol) error { + + var _field int32 if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Version = v + _field = v } + p.Version = _field return nil } func (p *BizRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("BizRequest"); err != nil { goto WriteStructBeginError @@ -247,7 +250,6 @@ func (p *BizRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 7 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -364,6 +366,7 @@ func (p *BizRequest) String() string { return "" } return fmt.Sprintf("BizRequest(%+v)", *p) + } func (p *BizRequest) DeepEqual(ano *BizRequest) bool { @@ -433,24 +436,27 @@ func (p *BizRequest) Field7DeepEqual(src int32) bool { } type BizResponse struct { - Token int32 `thrift:"token,1" json:"token"` - Text string `thrift:"text,2" json:"text"` - HttpCode int32 `thrift:"http_code,5" json:"http_code"` + Token int32 `thrift:"token,1" frugal:"1,default,i32" json:"token"` + Text string `thrift:"text,2" frugal:"2,default,string" json:"text"` + HttpCode int32 `thrift:"http_code,5" frugal:"5,default,i32" json:"http_code"` } func NewBizResponse() *BizResponse { return &BizResponse{} } -func (p *BizResponse) GetToken() int32 { +func (p *BizResponse) InitDefault() { +} + +func (p *BizResponse) GetToken() (v int32) { return p.Token } -func (p *BizResponse) GetText() string { +func (p *BizResponse) GetText() (v string) { return p.Text } -func (p *BizResponse) GetHttpCode() int32 { +func (p *BizResponse) GetHttpCode() (v int32) { return p.HttpCode } func (p *BizResponse) SetToken(val int32) { @@ -493,37 +499,30 @@ func (p *BizResponse) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 - } + } 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 - } + } 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 } @@ -549,33 +548,41 @@ ReadStructEndError: } func (p *BizResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field int32 if v, err := iprot.ReadI32(); err != nil { return err } else { - p.Token = v + _field = v } + p.Token = _field return nil } - func (p *BizResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Text = v + _field = v } + p.Text = _field return nil } - func (p *BizResponse) ReadField5(iprot thrift.TProtocol) error { + + var _field int32 if v, err := iprot.ReadI32(); err != nil { return err } else { - p.HttpCode = v + _field = v } + p.HttpCode = _field return nil } func (p *BizResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("BizResponse"); err != nil { goto WriteStructBeginError @@ -593,7 +600,6 @@ func (p *BizResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 5 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -668,6 +674,7 @@ func (p *BizResponse) String() string { return "" } return fmt.Sprintf("BizResponse(%+v)", *p) + } func (p *BizResponse) DeepEqual(ano *BizResponse) bool { @@ -718,260 +725,20 @@ type BizService interface { BizMethod3(ctx context.Context, req *BizRequest) (r *BizResponse, err error) } -type BizServiceClient struct { - c thrift.TClient -} - -func NewBizServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BizServiceClient { - return &BizServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewBizServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BizServiceClient { - return &BizServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewBizServiceClient(c thrift.TClient) *BizServiceClient { - return &BizServiceClient{ - c: c, - } -} - -func (p *BizServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *BizServiceClient) BizMethod1(ctx context.Context, req *BizRequest) (r *BizResponse, err error) { - var _args BizServiceBizMethod1Args - _args.Req = req - var _result BizServiceBizMethod1Result - if err = p.Client_().Call(ctx, "BizMethod1", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *BizServiceClient) BizMethod2(ctx context.Context, req *BizRequest) (r *BizResponse, err error) { - var _args BizServiceBizMethod2Args - _args.Req = req - var _result BizServiceBizMethod2Result - if err = p.Client_().Call(ctx, "BizMethod2", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *BizServiceClient) BizMethod3(ctx context.Context, req *BizRequest) (r *BizResponse, err error) { - var _args BizServiceBizMethod3Args - _args.Req = req - var _result BizServiceBizMethod3Result - if err = p.Client_().Call(ctx, "BizMethod3", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type BizServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler BizService -} - -func (p *BizServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *BizServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *BizServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewBizServiceProcessor(handler BizService) *BizServiceProcessor { - self := &BizServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("BizMethod1", &bizServiceProcessorBizMethod1{handler: handler}) - self.AddToProcessorMap("BizMethod2", &bizServiceProcessorBizMethod2{handler: handler}) - self.AddToProcessorMap("BizMethod3", &bizServiceProcessorBizMethod3{handler: handler}) - return self -} -func (p *BizServiceProcessor) 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 bizServiceProcessorBizMethod1 struct { - handler BizService -} - -func (p *bizServiceProcessorBizMethod1) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BizServiceBizMethod1Args{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("BizMethod1", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BizServiceBizMethod1Result{} - var retval *BizResponse - if retval, err2 = p.handler.BizMethod1(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing BizMethod1: "+err2.Error()) - oprot.WriteMessageBegin("BizMethod1", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("BizMethod1", 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 bizServiceProcessorBizMethod2 struct { - handler BizService -} - -func (p *bizServiceProcessorBizMethod2) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BizServiceBizMethod2Args{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("BizMethod2", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BizServiceBizMethod2Result{} - var retval *BizResponse - if retval, err2 = p.handler.BizMethod2(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing BizMethod2: "+err2.Error()) - oprot.WriteMessageBegin("BizMethod2", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("BizMethod2", 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 bizServiceProcessorBizMethod3 struct { - handler BizService -} - -func (p *bizServiceProcessorBizMethod3) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BizServiceBizMethod3Args{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("BizMethod3", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BizServiceBizMethod3Result{} - var retval *BizResponse - if retval, err2 = p.handler.BizMethod3(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing BizMethod3: "+err2.Error()) - oprot.WriteMessageBegin("BizMethod3", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("BizMethod3", 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 BizServiceBizMethod1Args struct { - Req *BizRequest `thrift:"req,1" json:"req"` + Req *BizRequest `thrift:"req,1" frugal:"1,default,BizRequest" json:"req"` } func NewBizServiceBizMethod1Args() *BizServiceBizMethod1Args { return &BizServiceBizMethod1Args{} } +func (p *BizServiceBizMethod1Args) InitDefault() { +} + var BizServiceBizMethod1Args_Req_DEFAULT *BizRequest -func (p *BizServiceBizMethod1Args) GetReq() *BizRequest { +func (p *BizServiceBizMethod1Args) GetReq() (v *BizRequest) { if !p.IsSetReq() { return BizServiceBizMethod1Args_Req_DEFAULT } @@ -1013,17 +780,14 @@ func (p *BizServiceBizMethod1Args) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1049,14 +813,16 @@ ReadStructEndError: } func (p *BizServiceBizMethod1Args) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewBizRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewBizRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *BizServiceBizMethod1Args) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("BizMethod1_args"); err != nil { goto WriteStructBeginError @@ -1066,7 +832,6 @@ func (p *BizServiceBizMethod1Args) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1107,6 +872,7 @@ func (p *BizServiceBizMethod1Args) String() string { return "" } return fmt.Sprintf("BizServiceBizMethod1Args(%+v)", *p) + } func (p *BizServiceBizMethod1Args) DeepEqual(ano *BizServiceBizMethod1Args) bool { @@ -1130,16 +896,19 @@ func (p *BizServiceBizMethod1Args) Field1DeepEqual(src *BizRequest) bool { } type BizServiceBizMethod1Result struct { - Success *BizResponse `thrift:"success,0" json:"success,omitempty"` + Success *BizResponse `thrift:"success,0,optional" frugal:"0,optional,BizResponse" json:"success,omitempty"` } func NewBizServiceBizMethod1Result() *BizServiceBizMethod1Result { return &BizServiceBizMethod1Result{} } +func (p *BizServiceBizMethod1Result) InitDefault() { +} + var BizServiceBizMethod1Result_Success_DEFAULT *BizResponse -func (p *BizServiceBizMethod1Result) GetSuccess() *BizResponse { +func (p *BizServiceBizMethod1Result) GetSuccess() (v *BizResponse) { if !p.IsSetSuccess() { return BizServiceBizMethod1Result_Success_DEFAULT } @@ -1181,17 +950,14 @@ func (p *BizServiceBizMethod1Result) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1217,14 +983,16 @@ ReadStructEndError: } func (p *BizServiceBizMethod1Result) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewBizResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewBizResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *BizServiceBizMethod1Result) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("BizMethod1_result"); err != nil { goto WriteStructBeginError @@ -1234,7 +1002,6 @@ func (p *BizServiceBizMethod1Result) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1277,6 +1044,7 @@ func (p *BizServiceBizMethod1Result) String() string { return "" } return fmt.Sprintf("BizServiceBizMethod1Result(%+v)", *p) + } func (p *BizServiceBizMethod1Result) DeepEqual(ano *BizServiceBizMethod1Result) bool { @@ -1300,16 +1068,19 @@ func (p *BizServiceBizMethod1Result) Field0DeepEqual(src *BizResponse) bool { } type BizServiceBizMethod2Args struct { - Req *BizRequest `thrift:"req,1" json:"req"` + Req *BizRequest `thrift:"req,1" frugal:"1,default,BizRequest" json:"req"` } func NewBizServiceBizMethod2Args() *BizServiceBizMethod2Args { return &BizServiceBizMethod2Args{} } +func (p *BizServiceBizMethod2Args) InitDefault() { +} + var BizServiceBizMethod2Args_Req_DEFAULT *BizRequest -func (p *BizServiceBizMethod2Args) GetReq() *BizRequest { +func (p *BizServiceBizMethod2Args) GetReq() (v *BizRequest) { if !p.IsSetReq() { return BizServiceBizMethod2Args_Req_DEFAULT } @@ -1351,17 +1122,14 @@ func (p *BizServiceBizMethod2Args) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1387,14 +1155,16 @@ ReadStructEndError: } func (p *BizServiceBizMethod2Args) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewBizRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewBizRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *BizServiceBizMethod2Args) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("BizMethod2_args"); err != nil { goto WriteStructBeginError @@ -1404,7 +1174,6 @@ func (p *BizServiceBizMethod2Args) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1445,6 +1214,7 @@ func (p *BizServiceBizMethod2Args) String() string { return "" } return fmt.Sprintf("BizServiceBizMethod2Args(%+v)", *p) + } func (p *BizServiceBizMethod2Args) DeepEqual(ano *BizServiceBizMethod2Args) bool { @@ -1468,16 +1238,19 @@ func (p *BizServiceBizMethod2Args) Field1DeepEqual(src *BizRequest) bool { } type BizServiceBizMethod2Result struct { - Success *BizResponse `thrift:"success,0" json:"success,omitempty"` + Success *BizResponse `thrift:"success,0,optional" frugal:"0,optional,BizResponse" json:"success,omitempty"` } func NewBizServiceBizMethod2Result() *BizServiceBizMethod2Result { return &BizServiceBizMethod2Result{} } +func (p *BizServiceBizMethod2Result) InitDefault() { +} + var BizServiceBizMethod2Result_Success_DEFAULT *BizResponse -func (p *BizServiceBizMethod2Result) GetSuccess() *BizResponse { +func (p *BizServiceBizMethod2Result) GetSuccess() (v *BizResponse) { if !p.IsSetSuccess() { return BizServiceBizMethod2Result_Success_DEFAULT } @@ -1519,17 +1292,14 @@ func (p *BizServiceBizMethod2Result) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1555,14 +1325,16 @@ ReadStructEndError: } func (p *BizServiceBizMethod2Result) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewBizResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewBizResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *BizServiceBizMethod2Result) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("BizMethod2_result"); err != nil { goto WriteStructBeginError @@ -1572,7 +1344,6 @@ func (p *BizServiceBizMethod2Result) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1615,6 +1386,7 @@ func (p *BizServiceBizMethod2Result) String() string { return "" } return fmt.Sprintf("BizServiceBizMethod2Result(%+v)", *p) + } func (p *BizServiceBizMethod2Result) DeepEqual(ano *BizServiceBizMethod2Result) bool { @@ -1638,16 +1410,19 @@ func (p *BizServiceBizMethod2Result) Field0DeepEqual(src *BizResponse) bool { } type BizServiceBizMethod3Args struct { - Req *BizRequest `thrift:"req,1" json:"req"` + Req *BizRequest `thrift:"req,1" frugal:"1,default,BizRequest" json:"req"` } func NewBizServiceBizMethod3Args() *BizServiceBizMethod3Args { return &BizServiceBizMethod3Args{} } +func (p *BizServiceBizMethod3Args) InitDefault() { +} + var BizServiceBizMethod3Args_Req_DEFAULT *BizRequest -func (p *BizServiceBizMethod3Args) GetReq() *BizRequest { +func (p *BizServiceBizMethod3Args) GetReq() (v *BizRequest) { if !p.IsSetReq() { return BizServiceBizMethod3Args_Req_DEFAULT } @@ -1689,17 +1464,14 @@ func (p *BizServiceBizMethod3Args) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1725,14 +1497,16 @@ ReadStructEndError: } func (p *BizServiceBizMethod3Args) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewBizRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewBizRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *BizServiceBizMethod3Args) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("BizMethod3_args"); err != nil { goto WriteStructBeginError @@ -1742,7 +1516,6 @@ func (p *BizServiceBizMethod3Args) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1783,6 +1556,7 @@ func (p *BizServiceBizMethod3Args) String() string { return "" } return fmt.Sprintf("BizServiceBizMethod3Args(%+v)", *p) + } func (p *BizServiceBizMethod3Args) DeepEqual(ano *BizServiceBizMethod3Args) bool { @@ -1806,16 +1580,19 @@ func (p *BizServiceBizMethod3Args) Field1DeepEqual(src *BizRequest) bool { } type BizServiceBizMethod3Result struct { - Success *BizResponse `thrift:"success,0" json:"success,omitempty"` + Success *BizResponse `thrift:"success,0,optional" frugal:"0,optional,BizResponse" json:"success,omitempty"` } func NewBizServiceBizMethod3Result() *BizServiceBizMethod3Result { return &BizServiceBizMethod3Result{} } +func (p *BizServiceBizMethod3Result) InitDefault() { +} + var BizServiceBizMethod3Result_Success_DEFAULT *BizResponse -func (p *BizServiceBizMethod3Result) GetSuccess() *BizResponse { +func (p *BizServiceBizMethod3Result) GetSuccess() (v *BizResponse) { if !p.IsSetSuccess() { return BizServiceBizMethod3Result_Success_DEFAULT } @@ -1857,17 +1634,14 @@ func (p *BizServiceBizMethod3Result) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -1893,14 +1667,16 @@ ReadStructEndError: } func (p *BizServiceBizMethod3Result) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewBizResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewBizResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *BizServiceBizMethod3Result) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("BizMethod3_result"); err != nil { goto WriteStructBeginError @@ -1910,7 +1686,6 @@ func (p *BizServiceBizMethod3Result) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1953,6 +1728,7 @@ func (p *BizServiceBizMethod3Result) String() string { return "" } return fmt.Sprintf("BizServiceBizMethod3Result(%+v)", *p) + } func (p *BizServiceBizMethod3Result) DeepEqual(ano *BizServiceBizMethod3Result) bool { diff --git a/generic/kitex_gen/http/k-http.go b/generic/kitex_gen/http/k-http.go index 4a65667b..b1be1f58 100644 --- a/generic/kitex_gen/http/k-http.go +++ b/generic/kitex_gen/http/k-http.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package http @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,24 +17,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *BizRequest) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -53,7 +45,7 @@ func (p *BizRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -67,7 +59,7 @@ func (p *BizRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -81,7 +73,7 @@ func (p *BizRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -95,7 +87,7 @@ func (p *BizRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -109,156 +101,129 @@ func (p *BizRequest) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_BizRequest[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 *BizRequest) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + var _field int64 + if v, l, err := thrift.Binary.ReadI64(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Vint64 = v - + _field = v } + p.Vint64 = _field return offset, nil } func (p *BizRequest) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Text = v - + _field = v } + p.Text = _field return offset, nil } func (p *BizRequest) FastReadField3(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field int32 + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Token = v - + _field = v } + p.Token = _field return offset, nil } func (p *BizRequest) FastReadField6(buf []byte) (int, error) { offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + _, size, l, err := thrift.Binary.ReadListBegin(buf[offset:]) offset += l if err != nil { return offset, err } - p.Items = make([]string, 0, size) + _field := make([]string, 0, size) for i := 0; i < size; i++ { var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - _elem = v - } - p.Items = append(p.Items, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + _field = append(_field, _elem) } + p.Items = _field return offset, nil } func (p *BizRequest) FastReadField7(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field int32 + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Version = v - + _field = v } + p.Version = _field return offset, nil } -// for compatibility func (p *BizRequest) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *BizRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizRequest) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BizRequest") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField3(buf[offset:], w) + offset += p.fastWriteField7(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) + offset += p.fastWriteField6(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *BizRequest) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("BizRequest") if p != nil { l += p.field1Length() l += p.field2Length() @@ -266,127 +231,100 @@ func (p *BizRequest) BLength() int { l += p.field6Length() l += p.field7Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *BizRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizRequest) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "vint64", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Vint64) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I64, 1) + offset += thrift.Binary.WriteI64(buf[offset:], p.Vint64) return offset } -func (p *BizRequest) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizRequest) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "text", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Text) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Text) return offset } -func (p *BizRequest) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizRequest) fastWriteField3(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "token", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Token) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 3) + offset += thrift.Binary.WriteI32(buf[offset:], p.Token) return offset } -func (p *BizRequest) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizRequest) fastWriteField6(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "items", thrift.LIST, 6) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.LIST, 6) listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRING, 0) + offset += thrift.Binary.ListBeginLength() var length int for _, v := range p.Items { length++ - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, v) } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + thrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) return offset } -func (p *BizRequest) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizRequest) fastWriteField7(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "version", thrift.I32, 7) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Version) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 7) + offset += thrift.Binary.WriteI32(buf[offset:], p.Version) return offset } func (p *BizRequest) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("vint64", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.Vint64) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I64Length() return l } func (p *BizRequest) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("text", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Text) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Text) return l } func (p *BizRequest) field3Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("token", thrift.I32, 3) - l += bthrift.Binary.I32Length(p.Token) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *BizRequest) field6Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("items", thrift.LIST, 6) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.Items)) + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.ListBeginLength() for _, v := range p.Items { - l += bthrift.Binary.StringLengthNocopy(v) - + _ = v + l += thrift.Binary.StringLengthNocopy(v) } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *BizRequest) field7Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("version", thrift.I32, 7) - l += bthrift.Binary.I32Length(p.Version) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *BizResponse) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -403,7 +341,7 @@ func (p *BizResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -417,7 +355,7 @@ func (p *BizResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError @@ -431,188 +369,149 @@ func (p *BizResponse) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_BizResponse[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 *BizResponse) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field int32 + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Token = v - + _field = v } + p.Token = _field return offset, nil } func (p *BizResponse) FastReadField2(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Text = v - + _field = v } + p.Text = _field return offset, nil } func (p *BizResponse) FastReadField5(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + var _field int32 + if v, l, err := thrift.Binary.ReadI32(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.HttpCode = v - + _field = v } + p.HttpCode = _field return offset, nil } -// for compatibility func (p *BizResponse) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *BizResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizResponse) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BizResponse") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) + offset += p.fastWriteField5(buf[offset:], w) + offset += p.fastWriteField2(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *BizResponse) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("BizResponse") if p != nil { l += p.field1Length() l += p.field2Length() l += p.field5Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *BizResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizResponse) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "token", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Token) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 1) + offset += thrift.Binary.WriteI32(buf[offset:], p.Token) return offset } -func (p *BizResponse) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizResponse) fastWriteField2(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "text", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Text) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 2) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Text) return offset } -func (p *BizResponse) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizResponse) fastWriteField5(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "http_code", thrift.I32, 5) - offset += bthrift.Binary.WriteI32(buf[offset:], p.HttpCode) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.I32, 5) + offset += thrift.Binary.WriteI32(buf[offset:], p.HttpCode) return offset } func (p *BizResponse) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("token", thrift.I32, 1) - l += bthrift.Binary.I32Length(p.Token) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *BizResponse) field2Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("text", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Text) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Text) return l } func (p *BizResponse) field5Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("http_code", thrift.I32, 5) - l += bthrift.Binary.I32Length(p.HttpCode) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.I32Length() return l } func (p *BizServiceBizMethod1Args) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -629,115 +528,87 @@ func (p *BizServiceBizMethod1Args) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_BizServiceBizMethod1Args[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 *BizServiceBizMethod1Args) FastReadField1(buf []byte) (int, error) { offset := 0 - p.Req = NewBizRequest() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { + _field := NewBizRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Req = _field return offset, nil } -// for compatibility func (p *BizServiceBizMethod1Args) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *BizServiceBizMethod1Args) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod1Args) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BizMethod1_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *BizServiceBizMethod1Args) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("BizMethod1_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *BizServiceBizMethod1Args) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod1Args) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *BizServiceBizMethod1Args) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *BizServiceBizMethod1Result) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -754,91 +625,69 @@ func (p *BizServiceBizMethod1Result) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_BizServiceBizMethod1Result[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 *BizServiceBizMethod1Result) FastReadField0(buf []byte) (int, error) { offset := 0 - p.Success = NewBizResponse() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { + _field := NewBizResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Success = _field return offset, nil } -// for compatibility func (p *BizServiceBizMethod1Result) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *BizServiceBizMethod1Result) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod1Result) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BizMethod1_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *BizServiceBizMethod1Result) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("BizMethod1_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *BizServiceBizMethod1Result) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod1Result) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -846,27 +695,21 @@ func (p *BizServiceBizMethod1Result) fastWriteField0(buf []byte, binaryWriter bt func (p *BizServiceBizMethod1Result) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *BizServiceBizMethod2Args) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -883,115 +726,87 @@ func (p *BizServiceBizMethod2Args) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_BizServiceBizMethod2Args[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 *BizServiceBizMethod2Args) FastReadField1(buf []byte) (int, error) { offset := 0 - p.Req = NewBizRequest() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { + _field := NewBizRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Req = _field return offset, nil } -// for compatibility func (p *BizServiceBizMethod2Args) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *BizServiceBizMethod2Args) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod2Args) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BizMethod2_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *BizServiceBizMethod2Args) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("BizMethod2_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *BizServiceBizMethod2Args) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod2Args) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *BizServiceBizMethod2Args) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *BizServiceBizMethod2Result) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1008,91 +823,69 @@ func (p *BizServiceBizMethod2Result) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_BizServiceBizMethod2Result[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 *BizServiceBizMethod2Result) FastReadField0(buf []byte) (int, error) { offset := 0 - p.Success = NewBizResponse() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { + _field := NewBizResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Success = _field return offset, nil } -// for compatibility func (p *BizServiceBizMethod2Result) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *BizServiceBizMethod2Result) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod2Result) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BizMethod2_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *BizServiceBizMethod2Result) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("BizMethod2_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *BizServiceBizMethod2Result) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod2Result) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -1100,27 +893,21 @@ func (p *BizServiceBizMethod2Result) fastWriteField0(buf []byte, binaryWriter bt func (p *BizServiceBizMethod2Result) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *BizServiceBizMethod3Args) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1137,115 +924,87 @@ func (p *BizServiceBizMethod3Args) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_BizServiceBizMethod3Args[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 *BizServiceBizMethod3Args) FastReadField1(buf []byte) (int, error) { offset := 0 - p.Req = NewBizRequest() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { + _field := NewBizRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Req = _field return offset, nil } -// for compatibility func (p *BizServiceBizMethod3Args) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *BizServiceBizMethod3Args) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod3Args) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BizMethod3_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *BizServiceBizMethod3Args) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("BizMethod3_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *BizServiceBizMethod3Args) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod3Args) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *BizServiceBizMethod3Args) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *BizServiceBizMethod3Result) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1262,91 +1021,69 @@ func (p *BizServiceBizMethod3Result) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_BizServiceBizMethod3Result[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 *BizServiceBizMethod3Result) FastReadField0(buf []byte) (int, error) { offset := 0 - p.Success = NewBizResponse() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { + _field := NewBizResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Success = _field return offset, nil } -// for compatibility func (p *BizServiceBizMethod3Result) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *BizServiceBizMethod3Result) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod3Result) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BizMethod3_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *BizServiceBizMethod3Result) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("BizMethod3_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *BizServiceBizMethod3Result) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *BizServiceBizMethod3Result) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -1354,9 +1091,8 @@ func (p *BizServiceBizMethod3Result) fastWriteField0(buf []byte, binaryWriter bt func (p *BizServiceBizMethod3Result) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/go.mod b/go.mod index b80cfc6c..c5fc7516 100755 --- a/go.mod +++ b/go.mod @@ -4,15 +4,14 @@ go 1.21 toolchain go1.21.1 -replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 - require ( - github.com/apache/thrift v0.20.0 github.com/bytedance/gopkg v0.1.1 github.com/cloudwego/fastpb v0.0.5 - github.com/cloudwego/frugal v0.2.0 - github.com/cloudwego/kitex v0.11.3 - github.com/cloudwego/localsession v0.0.2 + github.com/cloudwego/frugal v0.2.3 + github.com/cloudwego/gopkg v0.1.3 + github.com/cloudwego/kitex v0.12.0 + github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 + github.com/cloudwego/localsession v0.1.1 github.com/kitex-contrib/monitor-prometheus v0.2.0 github.com/kitex-contrib/obs-opentelemetry v0.2.7 github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20240205032422-93b4c82b7dcd @@ -23,29 +22,29 @@ require ( go.opentelemetry.io/otel v1.19.0 go.uber.org/zap v1.26.0 golang.org/x/sync v0.8.0 - google.golang.org/protobuf v1.31.0 + google.golang.org/protobuf v1.33.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 ) require ( + github.com/apache/thrift v0.16.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bytedance/sonic v1.12.2 // indirect + github.com/bytedance/sonic v1.12.5 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/configmanager v0.2.2 // indirect - github.com/cloudwego/dynamicgo v0.4.0 // indirect - github.com/cloudwego/gopkg v0.1.2 // indirect + github.com/cloudwego/dynamicgo v0.4.6 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cloudwego/netpoll v0.6.4 // indirect + github.com/cloudwego/netpoll v0.6.5 // indirect github.com/cloudwego/runtimex v0.1.0 // indirect - github.com/cloudwego/thriftgo v0.3.17 // indirect + github.com/cloudwego/thriftgo v0.3.18 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/go-logr/logr v1.3.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect github.com/iancoleman/strcase v0.2.0 // indirect @@ -88,3 +87,5 @@ require ( google.golang.org/grpc v1.59.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 diff --git a/go.sum b/go.sum index e6d6da67..59370c33 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/bytedance/gopkg v0.1.0/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvD github.com/bytedance/gopkg v0.1.1 h1:3azzgSkiaw79u24a+w9arfH8OfnQQ4MHUt9lJFREEaE= github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic v1.12.2 h1:oaMFuRTpMHYLpCntGca65YWt5ny+wAceDERTkT2L9lg= -github.com/bytedance/sonic v1.12.2/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= +github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= @@ -80,34 +80,36 @@ 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/configmanager v0.2.2 h1:sVrJB8gWYTlPV2OS3wcgJSO9F2/9Zbkmcm1Z7jempOU= github.com/cloudwego/configmanager v0.2.2/go.mod h1:ppiyU+5TPLonE8qMVi/pFQk2eL3Q4P7d4hbiNJn6jwI= -github.com/cloudwego/dynamicgo v0.4.0 h1:wQqNRNiSQaLkbcn3sfpEJGZsz3xf8Il4P/3DcENsrFI= -github.com/cloudwego/dynamicgo v0.4.0/go.mod h1:zgWk2oz56EyH790LJSxrTz1j01GJBO964jJQ/y7qjJc= +github.com/cloudwego/dynamicgo v0.4.6 h1:raRdvLN1WsGl5WsNd2Ul86s8PFQPu8soF4ALSJ9MdC4= +github.com/cloudwego/dynamicgo v0.4.6/go.mod h1:DknfxjIMuGvXow409bS/AWycXONdc02HECBL0qpNqTY= github.com/cloudwego/fastpb v0.0.3/go.mod h1:/V13XFTq2TUkxj2qWReV8MwfPC4NnPcy6FsrojnsSG0= github.com/cloudwego/fastpb v0.0.5 h1:vYnBPsfbAtU5TVz5+f9UTlmSCixG9F9vRwaqE0mZPZU= github.com/cloudwego/fastpb v0.0.5/go.mod h1:Bho7aAKBUtT9RPD2cNVkTdx4yQumfSv3If7wYnm1izk= github.com/cloudwego/frugal v0.1.3/go.mod h1:b981ViPYdhI56aFYsoMjl9kv6yeqYSO+iEz2jrhkCgI= -github.com/cloudwego/frugal v0.2.0 h1:0ETSzQYoYqVvdl7EKjqJ9aJnDoG6TzvNKV3PMQiQTS8= -github.com/cloudwego/frugal v0.2.0/go.mod h1:cpnV6kdRMjN3ylxRo63RNbZ9rBK6oxs70Zk6QZ4Enj4= -github.com/cloudwego/gopkg v0.1.2 h1:650t+RiZGht8qX+y0hl49JXJCuO44GhbGZuxDzr2PyI= -github.com/cloudwego/gopkg v0.1.2/go.mod h1:WoNTdXDPdvL97cBmRUWXVGkh2l2UFmpd9BUvbW2r0Aw= +github.com/cloudwego/frugal v0.2.3 h1:t1hhhAi8lXcx7Ncs4PR1pSZ90vlDU1cy5K2btDMFpoA= +github.com/cloudwego/frugal v0.2.3/go.mod h1:nC1U47gswLRiaxv6dybrhZvsDGCfQP9RGiiWC73CnoI= +github.com/cloudwego/gopkg v0.1.3 h1:y9VA5Zn5yqd1+QBV9aB0Zxy56JlAS7x4ZUoED/vJdxA= +github.com/cloudwego/gopkg v0.1.3/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= 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.3.2/go.mod h1:/XD07VpUD9VQWmmoepASgZ6iw//vgWikVA9MpzLC5i0= github.com/cloudwego/kitex v0.4.4/go.mod h1:3FcH5h9Qw+dhRljSzuGSpWuThttA8DvK0BsL7HUYydo= -github.com/cloudwego/kitex v0.11.3 h1:Qy1GtyuNbygMpwnMw+Aj1iS7fSd0IO7CzxtpZrRJ+Jc= -github.com/cloudwego/kitex v0.11.3/go.mod h1:RHT9ERKFVppJjBfGvwJAPxCIzf4oN1yASW5S4pPZNu4= -github.com/cloudwego/localsession v0.0.2 h1:N9/IDtCPj1fCL9bCTP+DbXx3f40YjVYWcwkJG0YhQkY= -github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= +github.com/cloudwego/kitex v0.12.0 h1:TeNlAAkWc3MOIGnBQj+FcSUBan+3TBpzitnrviH0AXM= +github.com/cloudwego/kitex v0.12.0/go.mod h1:k2wQJ+3LPjQJHbBs0xE2k6z8SVRcUpB3/eRO34oM0nQ= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2 h1:jU6gpAkJ3HZLZeSpxrL1xaCd/auvAbLs0SN/ylXn9TA= +github.com/cloudwego/kitex/pkg/protocol/bthrift v0.0.0-20241219022956-e15b7a1a61d2/go.mod h1:OP63V8YwwSlPVFqHZblV3mJXLPIjcIdwkT6ZYjEggcI= +github.com/cloudwego/localsession v0.1.1 h1:tbK7laDVrYfFDXoBXo4uCGMAxU4qmz2dDm8d4BGBnDo= +github.com/cloudwego/localsession v0.1.1/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= github.com/cloudwego/netpoll v0.2.4/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= github.com/cloudwego/netpoll v0.3.1/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= -github.com/cloudwego/netpoll v0.6.4 h1:z/dA4sOTUQof6zZIO4QNnLBXsDFFFEos9OOGloR6kno= -github.com/cloudwego/netpoll v0.6.4/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= +github.com/cloudwego/netpoll v0.6.5 h1:6E/BWhSzQoyLg9Kx/4xiMdIIpovzwBtXvuqSqaTUzDQ= +github.com/cloudwego/netpoll v0.6.5/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= 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.1.2/go.mod h1:LzeafuLSiHA9JTiWC8TIMIq64iadeObgRUhmVG1OC/w= github.com/cloudwego/thriftgo v0.2.4/go.mod h1:8i9AF5uDdWHGqzUhXDlubCjx4MEfKvWXGQlMWyR0tM4= -github.com/cloudwego/thriftgo v0.3.17 h1:k0iQe2jEAN1WhPsXWvatwHzoxObUSX2Nw5NqdnywS8k= -github.com/cloudwego/thriftgo v0.3.17/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= +github.com/cloudwego/thriftgo v0.3.18 h1:gnr1vz7G3RbwwCK9AMKHZf63VYGa7ene6WbI9VrBJSw= +github.com/cloudwego/thriftgo v0.3.18/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= 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= @@ -172,8 +174,8 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -698,8 +700,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 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/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/hello/kitex_gen/api/hello.go b/hello/kitex_gen/api/hello.go index 2367cda2..0eb7e0fc 100644 --- a/hello/kitex_gen/api/hello.go +++ b/hello/kitex_gen/api/hello.go @@ -1,23 +1,26 @@ -// Code generated by thriftgo (0.1.2). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package api import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" ) type Request struct { - Message string `thrift:"message,1" json:"message"` + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` } func NewRequest() *Request { return &Request{} } -func (p *Request) GetMessage() string { +func (p *Request) InitDefault() { +} + +func (p *Request) GetMessage() (v string) { return p.Message } func (p *Request) SetMessage(val string) { @@ -52,17 +55,14 @@ func (p *Request) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -88,15 +88,19 @@ ReadStructEndError: } func (p *Request) ReadField1(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Message = v + _field = v } + p.Message = _field return nil } func (p *Request) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Request"); err != nil { goto WriteStructBeginError @@ -106,7 +110,6 @@ func (p *Request) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -147,6 +150,7 @@ func (p *Request) String() string { return "" } return fmt.Sprintf("Request(%+v)", *p) + } func (p *Request) DeepEqual(ano *Request) bool { @@ -170,14 +174,17 @@ func (p *Request) Field1DeepEqual(src string) bool { } type Response struct { - Message string `thrift:"message,1" json:"message"` + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` } func NewResponse() *Response { return &Response{} } -func (p *Response) GetMessage() string { +func (p *Response) InitDefault() { +} + +func (p *Response) GetMessage() (v string) { return p.Message } func (p *Response) SetMessage(val string) { @@ -212,17 +219,14 @@ func (p *Response) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -248,15 +252,19 @@ ReadStructEndError: } func (p *Response) ReadField1(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Message = v + _field = v } + p.Message = _field return nil } func (p *Response) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Response"); err != nil { goto WriteStructBeginError @@ -266,7 +274,6 @@ func (p *Response) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -307,6 +314,7 @@ func (p *Response) String() string { return "" } return fmt.Sprintf("Response(%+v)", *p) + } func (p *Response) DeepEqual(ano *Response) bool { @@ -333,142 +341,20 @@ type Hello interface { Echo(ctx context.Context, req *Request) (r *Response, err error) } -type HelloClient struct { - c thrift.TClient -} - -func NewHelloClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *HelloClient { - return &HelloClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewHelloClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *HelloClient { - return &HelloClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewHelloClient(c thrift.TClient) *HelloClient { - return &HelloClient{ - c: c, - } -} - -func (p *HelloClient) Client_() thrift.TClient { - return p.c -} - -func (p *HelloClient) Echo(ctx context.Context, req *Request) (r *Response, err error) { - var _args HelloEchoArgs - _args.Req = req - var _result HelloEchoResult - if err = p.Client_().Call(ctx, "echo", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type HelloProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler Hello -} - -func (p *HelloProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *HelloProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *HelloProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewHelloProcessor(handler Hello) *HelloProcessor { - self := &HelloProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("echo", &helloProcessorEcho{handler: handler}) - return self -} -func (p *HelloProcessor) 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 helloProcessorEcho struct { - handler Hello -} - -func (p *helloProcessorEcho) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := HelloEchoArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("echo", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := HelloEchoResult{} - var retval *Response - if retval, err2 = p.handler.Echo(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing echo: "+err2.Error()) - oprot.WriteMessageBegin("echo", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("echo", 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 HelloEchoArgs struct { - Req *Request `thrift:"req,1" json:"req"` + Req *Request `thrift:"req,1" frugal:"1,default,Request" json:"req"` } func NewHelloEchoArgs() *HelloEchoArgs { return &HelloEchoArgs{} } +func (p *HelloEchoArgs) InitDefault() { +} + var HelloEchoArgs_Req_DEFAULT *Request -func (p *HelloEchoArgs) GetReq() *Request { +func (p *HelloEchoArgs) GetReq() (v *Request) { if !p.IsSetReq() { return HelloEchoArgs_Req_DEFAULT } @@ -510,17 +396,14 @@ func (p *HelloEchoArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -546,14 +429,16 @@ ReadStructEndError: } func (p *HelloEchoArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *HelloEchoArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("echo_args"); err != nil { goto WriteStructBeginError @@ -563,7 +448,6 @@ func (p *HelloEchoArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -604,6 +488,7 @@ func (p *HelloEchoArgs) String() string { return "" } return fmt.Sprintf("HelloEchoArgs(%+v)", *p) + } func (p *HelloEchoArgs) DeepEqual(ano *HelloEchoArgs) bool { @@ -627,16 +512,19 @@ func (p *HelloEchoArgs) Field1DeepEqual(src *Request) bool { } type HelloEchoResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` + Success *Response `thrift:"success,0,optional" frugal:"0,optional,Response" json:"success,omitempty"` } func NewHelloEchoResult() *HelloEchoResult { return &HelloEchoResult{} } +func (p *HelloEchoResult) InitDefault() { +} + var HelloEchoResult_Success_DEFAULT *Response -func (p *HelloEchoResult) GetSuccess() *Response { +func (p *HelloEchoResult) GetSuccess() (v *Response) { if !p.IsSetSuccess() { return HelloEchoResult_Success_DEFAULT } @@ -678,17 +566,14 @@ func (p *HelloEchoResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -714,14 +599,16 @@ ReadStructEndError: } func (p *HelloEchoResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *HelloEchoResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("echo_result"); err != nil { goto WriteStructBeginError @@ -731,7 +618,6 @@ func (p *HelloEchoResult) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -774,6 +660,7 @@ func (p *HelloEchoResult) String() string { return "" } return fmt.Sprintf("HelloEchoResult(%+v)", *p) + } func (p *HelloEchoResult) DeepEqual(ano *HelloEchoResult) bool { diff --git a/hello/kitex_gen/api/hello/client.go b/hello/kitex_gen/api/hello/client.go index 0c8b973b..24a7c36d 100644 --- a/hello/kitex_gen/api/hello/client.go +++ b/hello/kitex_gen/api/hello/client.go @@ -1,12 +1,12 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package hello import ( "context" - "github.com/cloudwego/kitex-examples/hello/kitex_gen/api" - "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt" + api "github.com/cloudwego/kitex-examples/hello/kitex_gen/api" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. @@ -21,7 +21,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/hello/kitex_gen/api/hello/hello.go b/hello/kitex_gen/api/hello/hello.go index cc928b65..ee7d435f 100644 --- a/hello/kitex_gen/api/hello/hello.go +++ b/hello/kitex_gen/api/hello/hello.go @@ -1,35 +1,86 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package hello import ( "context" - "github.com/cloudwego/kitex-examples/hello/kitex_gen/api" - "github.com/cloudwego/kitex/client" + "errors" + api "github.com/cloudwego/kitex-examples/hello/kitex_gen/api" + client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "echo": kitex.NewMethodInfo( + echoHandler, + newHelloEchoArgs, + newHelloEchoResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + helloServiceInfo = NewServiceInfo() + helloServiceInfoForClient = NewServiceInfoForClient() + helloServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return helloServiceInfo } -var helloServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return helloServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return helloServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "Hello" handlerType := (*api.Hello)(nil) - methods := map[string]kitex.MethodInfo{ - "echo": kitex.NewMethodInfo(echoHandler, newHelloEchoArgs, newHelloEchoResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ "PackageName": "api", } + if hasStreaming { + extra["streaming"] = hasStreaming + } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.1.4", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/hello/kitex_gen/api/hello/server.go b/hello/kitex_gen/api/hello/server.go index b47eb063..6a2b58c2 100644 --- a/hello/kitex_gen/api/hello/server.go +++ b/hello/kitex_gen/api/hello/server.go @@ -1,9 +1,9 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package hello import ( - "github.com/cloudwego/kitex-examples/hello/kitex_gen/api" - "github.com/cloudwego/kitex/server" + api "github.com/cloudwego/kitex-examples/hello/kitex_gen/api" + server "github.com/cloudwego/kitex/server" ) // NewServer creates a server.Server with the given handler and options. @@ -11,6 +11,7 @@ func NewServer(handler api.Hello, opts ...server.Option) server.Server { var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler api.Hello, opts ...server.Option) server.Server { } return svr } + +func RegisterService(svr server.Server, handler api.Hello, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/hello/kitex_gen/api/k-hello.go b/hello/kitex_gen/api/k-hello.go index 4e38e9d5..8062f54c 100644 --- a/hello/kitex_gen/api/k-hello.go +++ b/hello/kitex_gen/api/k-hello.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.1.4. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package api @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,24 +17,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *Request) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -53,120 +45,89 @@ func (p *Request) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Request[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 *Request) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Message = v - + _field = v } + p.Message = _field return offset, nil } -// for compatibility func (p *Request) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Request) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Request) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Request") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Request) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Request") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Request) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Request) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Message) return offset } func (p *Request) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Message) return l } func (p *Response) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -183,120 +144,89 @@ func (p *Response) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Response[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 *Response) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Message = v - + _field = v } + p.Message = _field return offset, nil } -// for compatibility func (p *Response) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Response) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Response") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Response) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Response") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Response) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Message) return offset } func (p *Response) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Message) return l } func (p *HelloEchoArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -313,115 +243,87 @@ func (p *HelloEchoArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_HelloEchoArgs[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 *HelloEchoArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - p.Req = NewRequest() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { + _field := NewRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Req = _field return offset, nil } -// for compatibility func (p *HelloEchoArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *HelloEchoArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *HelloEchoArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "echo_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *HelloEchoArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("echo_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *HelloEchoArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *HelloEchoArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *HelloEchoArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *HelloEchoResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -438,91 +340,69 @@ func (p *HelloEchoResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_HelloEchoResult[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 *HelloEchoResult) FastReadField0(buf []byte) (int, error) { offset := 0 - p.Success = NewResponse() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { + _field := NewResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } + p.Success = _field return offset, nil } -// for compatibility func (p *HelloEchoResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *HelloEchoResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *HelloEchoResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "echo_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *HelloEchoResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("echo_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *HelloEchoResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *HelloEchoResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -530,9 +410,8 @@ func (p *HelloEchoResult) fastWriteField0(buf []byte, binaryWriter bthrift.Binar func (p *HelloEchoResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/kitex_gen/api/echo.go b/kitex_gen/api/echo.go index f6700317..85e6050b 100644 --- a/kitex_gen/api/echo.go +++ b/kitex_gen/api/echo.go @@ -1,11 +1,11 @@ -// Code generated by thriftgo (0.3.1). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package api import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" ) @@ -18,7 +18,6 @@ func NewRequest() *Request { } func (p *Request) InitDefault() { - *p = Request{} } func (p *Request) GetMessage() (v string) { @@ -56,17 +55,14 @@ func (p *Request) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -92,15 +88,19 @@ ReadStructEndError: } func (p *Request) ReadField1(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Message = v + _field = v } + p.Message = _field return nil } func (p *Request) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Request"); err != nil { goto WriteStructBeginError @@ -110,7 +110,6 @@ func (p *Request) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -151,6 +150,7 @@ func (p *Request) String() string { return "" } return fmt.Sprintf("Request(%+v)", *p) + } func (p *Request) DeepEqual(ano *Request) bool { @@ -182,7 +182,6 @@ func NewResponse() *Response { } func (p *Response) InitDefault() { - *p = Response{} } func (p *Response) GetMessage() (v string) { @@ -220,17 +219,14 @@ func (p *Response) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -256,15 +252,19 @@ ReadStructEndError: } func (p *Response) ReadField1(iprot thrift.TProtocol) error { + + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Message = v + _field = v } + p.Message = _field return nil } func (p *Response) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Response"); err != nil { goto WriteStructBeginError @@ -274,7 +274,6 @@ func (p *Response) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -315,6 +314,7 @@ func (p *Response) String() string { return "" } return fmt.Sprintf("Response(%+v)", *p) + } func (p *Response) DeepEqual(ano *Response) bool { @@ -341,131 +341,6 @@ type Echo interface { Echo(ctx context.Context, req *Request) (r *Response, err error) } -type EchoClient struct { - c thrift.TClient -} - -func NewEchoClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *EchoClient { - return &EchoClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewEchoClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *EchoClient { - return &EchoClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewEchoClient(c thrift.TClient) *EchoClient { - return &EchoClient{ - c: c, - } -} - -func (p *EchoClient) Client_() thrift.TClient { - return p.c -} - -func (p *EchoClient) Echo(ctx context.Context, req *Request) (r *Response, err error) { - var _args EchoEchoArgs - _args.Req = req - var _result EchoEchoResult - if err = p.Client_().Call(ctx, "echo", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type EchoProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler Echo -} - -func (p *EchoProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *EchoProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *EchoProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewEchoProcessor(handler Echo) *EchoProcessor { - self := &EchoProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("echo", &echoProcessorEcho{handler: handler}) - return self -} -func (p *EchoProcessor) 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 echoProcessorEcho struct { - handler Echo -} - -func (p *echoProcessorEcho) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := EchoEchoArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("echo", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := EchoEchoResult{} - var retval *Response - if retval, err2 = p.handler.Echo(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing echo: "+err2.Error()) - oprot.WriteMessageBegin("echo", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("echo", 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 EchoEchoArgs struct { Req *Request `thrift:"req,1" frugal:"1,default,Request" json:"req"` } @@ -475,7 +350,6 @@ func NewEchoEchoArgs() *EchoEchoArgs { } func (p *EchoEchoArgs) InitDefault() { - *p = EchoEchoArgs{} } var EchoEchoArgs_Req_DEFAULT *Request @@ -522,17 +396,14 @@ func (p *EchoEchoArgs) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -558,14 +429,16 @@ ReadStructEndError: } func (p *EchoEchoArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *EchoEchoArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("echo_args"); err != nil { goto WriteStructBeginError @@ -575,7 +448,6 @@ func (p *EchoEchoArgs) Write(oprot thrift.TProtocol) (err error) { fieldId = 1 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -616,6 +488,7 @@ func (p *EchoEchoArgs) String() string { return "" } return fmt.Sprintf("EchoEchoArgs(%+v)", *p) + } func (p *EchoEchoArgs) DeepEqual(ano *EchoEchoArgs) bool { @@ -647,7 +520,6 @@ func NewEchoEchoResult() *EchoEchoResult { } func (p *EchoEchoResult) InitDefault() { - *p = EchoEchoResult{} } var EchoEchoResult_Success_DEFAULT *Response @@ -694,17 +566,14 @@ func (p *EchoEchoResult) Read(iprot thrift.TProtocol) (err error) { if err = p.ReadField0(iprot); err != nil { goto ReadFieldError } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } + } 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 } @@ -730,14 +599,16 @@ ReadStructEndError: } func (p *EchoEchoResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *EchoEchoResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("echo_result"); err != nil { goto WriteStructBeginError @@ -747,7 +618,6 @@ func (p *EchoEchoResult) Write(oprot thrift.TProtocol) (err error) { fieldId = 0 goto WriteFieldError } - } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -790,6 +660,7 @@ func (p *EchoEchoResult) String() string { return "" } return fmt.Sprintf("EchoEchoResult(%+v)", *p) + } func (p *EchoEchoResult) DeepEqual(ano *EchoEchoResult) bool { diff --git a/kitex_gen/api/echo/client.go b/kitex_gen/api/echo/client.go index f2c5e894..84ec83a9 100644 --- a/kitex_gen/api/echo/client.go +++ b/kitex_gen/api/echo/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo @@ -21,7 +21,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/kitex_gen/api/echo/echo.go b/kitex_gen/api/echo/echo.go index aa12cba7..433e82ce 100644 --- a/kitex_gen/api/echo/echo.go +++ b/kitex_gen/api/echo/echo.go @@ -1,36 +1,86 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo import ( "context" + "errors" api "github.com/cloudwego/kitex-examples/kitex_gen/api" client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "echo": kitex.NewMethodInfo( + echoHandler, + newEchoEchoArgs, + newEchoEchoResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + echoServiceInfo = NewServiceInfo() + echoServiceInfoForClient = NewServiceInfoForClient() + echoServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return echoServiceInfo } -var echoServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return echoServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return echoServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "Echo" handlerType := (*api.Echo)(nil) - methods := map[string]kitex.MethodInfo{ - "echo": kitex.NewMethodInfo(echoHandler, newEchoEchoArgs, newEchoEchoResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ - "PackageName": "api", - "ServiceFilePath": "echo.thrift", + "PackageName": "api", + } + if hasStreaming { + extra["streaming"] = hasStreaming } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.7.1", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/kitex_gen/api/echo/invoker.go b/kitex_gen/api/echo/invoker.go index 2961dcc4..c9dc3be1 100644 --- a/kitex_gen/api/echo/invoker.go +++ b/kitex_gen/api/echo/invoker.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo diff --git a/kitex_gen/api/echo/server.go b/kitex_gen/api/echo/server.go index 214d49f2..02c2b68a 100644 --- a/kitex_gen/api/echo/server.go +++ b/kitex_gen/api/echo/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo import ( @@ -11,6 +11,7 @@ func NewServer(handler api.Echo, opts ...server.Option) server.Server { var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler api.Echo, opts ...server.Option) server.Server { } return svr } + +func RegisterService(svr server.Server, handler api.Echo, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/kitex_gen/api/k-echo.go b/kitex_gen/api/k-echo.go index 7c064ccf..7f314c30 100644 --- a/kitex_gen/api/k-echo.go +++ b/kitex_gen/api/k-echo.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package api @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,24 +17,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *Request) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -53,120 +45,89 @@ func (p *Request) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Request[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 *Request) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Message = v - + _field = v } + p.Message = _field return offset, nil } -// for compatibility func (p *Request) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Request) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Request) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Request") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Request) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Request") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Request) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Request) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Message) return offset } func (p *Request) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Message) return l } func (p *Response) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -183,120 +144,89 @@ func (p *Response) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Response[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 *Response) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Message = v - + _field = v } + p.Message = _field return offset, nil } -// for compatibility func (p *Response) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Response) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Response") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Response) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Response") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Response) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Message) return offset } func (p *Response) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Message) return l } func (p *EchoEchoArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -313,117 +243,87 @@ func (p *EchoEchoArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_EchoEchoArgs[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 *EchoEchoArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *EchoEchoArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *EchoEchoArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *EchoEchoArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "echo_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *EchoEchoArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("echo_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *EchoEchoArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *EchoEchoArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *EchoEchoArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *EchoEchoResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -440,93 +340,69 @@ func (p *EchoEchoResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_EchoEchoResult[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 *EchoEchoResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *EchoEchoResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *EchoEchoResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *EchoEchoResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "echo_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *EchoEchoResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("echo_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *EchoEchoResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *EchoEchoResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -534,9 +410,8 @@ func (p *EchoEchoResult) fastWriteField0(buf []byte, binaryWriter bthrift.Binary func (p *EchoEchoResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/kitex_gen/pbapi/echo.pb.go b/kitex_gen/pbapi/echo.pb.go index 1d950584..b2fada12 100644 --- a/kitex_gen/pbapi/echo.pb.go +++ b/kitex_gen/pbapi/echo.pb.go @@ -15,8 +15,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.33.0 +// protoc v3.19.4 // source: echo.proto package pbapi @@ -228,7 +228,7 @@ func file_echo_proto_init() { var _ context.Context -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. type Echo interface { Echo(ctx context.Context, req *Request) (res *Response, err error) diff --git a/kitex_gen/pbapi/echo/client.go b/kitex_gen/pbapi/echo/client.go index 4192e98b..8161b23b 100644 --- a/kitex_gen/pbapi/echo/client.go +++ b/kitex_gen/pbapi/echo/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo diff --git a/kitex_gen/pbapi/echo/echo.go b/kitex_gen/pbapi/echo/echo.go index 3f5417cf..af79796c 100644 --- a/kitex_gen/pbapi/echo/echo.go +++ b/kitex_gen/pbapi/echo/echo.go @@ -1,9 +1,10 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo import ( "context" + "errors" pbapi "github.com/cloudwego/kitex-examples/kitex_gen/pbapi" client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" @@ -11,28 +12,77 @@ import ( proto "google.golang.org/protobuf/proto" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Echo": kitex.NewMethodInfo( + echoHandler, + newEchoArgs, + newEchoResult, + false, + kitex.WithStreamingMode(kitex.StreamingUnary), + ), +} + +var ( + echoServiceInfo = NewServiceInfo() + echoServiceInfoForClient = NewServiceInfoForClient() + echoServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return echoServiceInfo } -var echoServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return echoServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return echoServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "Echo" handlerType := (*pbapi.Echo)(nil) - methods := map[string]kitex.MethodInfo{ - "Echo": kitex.NewMethodInfo(echoHandler, newEchoArgs, newEchoResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ - "PackageName": "pbapi", - "ServiceFilePath": "", + "PackageName": "pbapi", + } + if hasStreaming { + extra["streaming"] = hasStreaming } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.7.1", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo @@ -50,9 +100,7 @@ func echoHandler(ctx context.Context, handler interface{}, arg, result interface if err != nil { return err } - if err := st.SendMsg(resp); err != nil { - return err - } + return st.SendMsg(resp) case *EchoArgs: success, err := handler.(pbapi.Echo).Echo(ctx, s.Req) if err != nil { @@ -60,8 +108,10 @@ func echoHandler(ctx context.Context, handler interface{}, arg, result interface } realResult := result.(*EchoResult) realResult.Success = success + return nil + default: + return errInvalidMessageType } - return nil } func newEchoArgs() interface{} { return &EchoArgs{} diff --git a/kitex_gen/pbapi/echo/server.go b/kitex_gen/pbapi/echo/server.go index cfa0adbc..1b46b3c0 100644 --- a/kitex_gen/pbapi/echo/server.go +++ b/kitex_gen/pbapi/echo/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo import ( @@ -18,3 +18,7 @@ func NewServer(handler pbapi.Echo, opts ...server.Option) server.Server { } return svr } + +func RegisterService(svr server.Server, handler pbapi.Echo, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/kitex_gen/slim/api/echo.go b/kitex_gen/slim/api/echo.go index f13003a4..c8173f76 100644 --- a/kitex_gen/slim/api/echo.go +++ b/kitex_gen/slim/api/echo.go @@ -1,10 +1,11 @@ -// Code generated by thriftgo (0.3.1). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package api import ( "context" "fmt" + "strings" ) type Request struct { @@ -16,7 +17,6 @@ func NewRequest() *Request { } func (p *Request) InitDefault() { - *p = Request{} } func (p *Request) GetMessage() (v string) { @@ -33,6 +33,26 @@ func (p *Request) String() string { return fmt.Sprintf("Request(%+v)", *p) } +func (p *Request) DeepEqual(ano *Request) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Request) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + type Response struct { Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` } @@ -42,7 +62,6 @@ func NewResponse() *Response { } func (p *Response) InitDefault() { - *p = Response{} } func (p *Response) GetMessage() (v string) { @@ -59,6 +78,26 @@ func (p *Response) String() string { return fmt.Sprintf("Response(%+v)", *p) } +func (p *Response) DeepEqual(ano *Response) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Response) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + type Echo interface { Echo(ctx context.Context, req *Request) (r *Response, err error) } diff --git a/kitex_gen/slim/api/echo/client.go b/kitex_gen/slim/api/echo/client.go index cb9c711e..5d236737 100644 --- a/kitex_gen/slim/api/echo/client.go +++ b/kitex_gen/slim/api/echo/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo @@ -21,7 +21,7 @@ func NewClient(destService string, opts ...client.Option) (Client, error) { options = append(options, opts...) - kc, err := client.NewClient(serviceInfo(), options...) + kc, err := client.NewClient(serviceInfoForClient(), options...) if err != nil { return nil, err } diff --git a/kitex_gen/slim/api/echo/echo.go b/kitex_gen/slim/api/echo/echo.go index 23529376..053f986e 100644 --- a/kitex_gen/slim/api/echo/echo.go +++ b/kitex_gen/slim/api/echo/echo.go @@ -1,36 +1,86 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo import ( "context" + "errors" api "github.com/cloudwego/kitex-examples/kitex_gen/slim/api" client "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" ) +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "echo": kitex.NewMethodInfo( + echoHandler, + newEchoEchoArgs, + newEchoEchoResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + echoServiceInfo = NewServiceInfo() + echoServiceInfoForClient = NewServiceInfoForClient() + echoServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server func serviceInfo() *kitex.ServiceInfo { return echoServiceInfo } -var echoServiceInfo = NewServiceInfo() +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return echoServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return echoServiceInfoForClient +} +// NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { serviceName := "Echo" handlerType := (*api.Echo)(nil) - methods := map[string]kitex.MethodInfo{ - "echo": kitex.NewMethodInfo(echoHandler, newEchoEchoArgs, newEchoEchoResult, false), + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m } extra := map[string]interface{}{ - "PackageName": "api", - "ServiceFilePath": "echo.thrift", + "PackageName": "api", + } + if hasStreaming { + extra["streaming"] = hasStreaming } svcInfo := &kitex.ServiceInfo{ ServiceName: serviceName, HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.7.1", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/kitex_gen/slim/api/echo/server.go b/kitex_gen/slim/api/echo/server.go index e55cb54b..72141b27 100644 --- a/kitex_gen/slim/api/echo/server.go +++ b/kitex_gen/slim/api/echo/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo import ( @@ -11,6 +11,7 @@ func NewServer(handler api.Echo, opts ...server.Option) server.Server { var options []server.Option options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) svr := server.NewServer(options...) if err := svr.RegisterService(serviceInfo(), handler); err != nil { @@ -18,3 +19,7 @@ func NewServer(handler api.Echo, opts ...server.Option) server.Server { } return svr } + +func RegisterService(svr server.Server, handler api.Echo, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/kitex_gen/slim/api/k-echo.go b/kitex_gen/slim/api/k-echo.go index 771f5d92..cf0e1e21 100644 --- a/kitex_gen/slim/api/k-echo.go +++ b/kitex_gen/slim/api/k-echo.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.7.1. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package api @@ -8,7 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -17,7 +17,7 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) + _ = thrift.STOP ) type EchoEchoArgs struct { @@ -29,7 +29,6 @@ func NewEchoEchoArgs() *EchoEchoArgs { } func (p *EchoEchoArgs) InitDefault() { - *p = EchoEchoArgs{} } var EchoEchoArgs_Req_DEFAULT *Request @@ -54,6 +53,7 @@ func (p *EchoEchoArgs) String() string { } return fmt.Sprintf("EchoEchoArgs(%+v)", *p) } + func (p *EchoEchoArgs) GetFirstArgument() interface{} { return p.Req } @@ -67,7 +67,6 @@ func NewEchoEchoResult() *EchoEchoResult { } func (p *EchoEchoResult) InitDefault() { - *p = EchoEchoResult{} } var EchoEchoResult_Success_DEFAULT *Response @@ -92,6 +91,7 @@ func (p *EchoEchoResult) String() string { } return fmt.Sprintf("EchoEchoResult(%+v)", *p) } + func (p *EchoEchoResult) GetResult() interface{} { return p.Success } diff --git a/metainfo/backward/client/main.go b/metainfo/backward/client/main.go index 80dcabe0..9e59bd40 100644 --- a/metainfo/backward/client/main.go +++ b/metainfo/backward/client/main.go @@ -21,6 +21,7 @@ import ( "time" "github.com/bytedance/gopkg/cloud/metainfo" + "github.com/cloudwego/kitex-examples/kitex_gen/api" "github.com/cloudwego/kitex-examples/kitex_gen/api/echo" "github.com/cloudwego/kitex/client" diff --git a/regenerate-idl.sh b/regenerate-idl.sh index e25652d8..122e2528 100755 --- a/regenerate-idl.sh +++ b/regenerate-idl.sh @@ -1,5 +1,8 @@ #!/bin/bash +# for kitex version higher than v0.12.0, thriftgo is no need to install manually. +go install github.com/cloudwego/kitex/tool/cmd/kitex@latest + kitex=${1:-kitex} function gen_thrift() { @@ -8,7 +11,7 @@ function gen_thrift() { module='-module github.com/cloudwego/kitex-examples' idl=echo.thrift - $kitex $frugal_tag $module $idl + $kitex $frugal_tag $module -invoker $idl } function gen_thrift_slim() { @@ -29,6 +32,36 @@ function gen_protobuf() { $kitex $module $idl } +function regenerate_submod() { + original_dir=$(pwd) + local path=$1 + local module=$2 + local thrift_file=$3 + cd $path + + echo "Executing kitex command in $path with module: $module and thrift file: $thrift_file" + + # Execute the kitex command + kitex -module $module $thrift_file + go get github.com/cloudwego/kitex@latest + go mod tidy + + cd $original_dir +} + gen_thrift gen_thrift_slim gen_protobuf + +regenerate_submod "basic/example_shop" "example_shop" "idl/item.thrift" +regenerate_submod "basic/example_shop" "example_shop" "idl/stock.thrift" +regenerate_submod "bizdemo/easy_note" "github.com/cloudwego/kitex-examples/bizdemo/easy_note" "idl/note.thrift" +regenerate_submod "bizdemo/kitex_ent" "github.com/cloudwego/kitex-examples/bizdemo/kitex_ent" "idl/user.thrift" +regenerate_submod "bizdemo/kitex_gorm" "github.com/cloudwego/kitex-examples/bizdemo/kitex_gorm" "idl/user.thrift" +regenerate_submod "bizdemo/kitex_gorm_gen" "github.com/cloudwego/kitex-examples/bizdemo/kitex_gorm_gen" "idl/user.thrift" +regenerate_submod "bizdemo/kitex_swagger_gen" "github.com/cloudwego/kitex-examples/bizdemo/kitex_swagger_gen" "idl/user.thrift" +regenerate_submod "bizdemo/kitex_zorm" "github.com/cloudwego/kitex-examples/bizdemo/kitex_zorm" "idl/user.thrift" +regenerate_submod "generic" " github.com/cloudwego/kitex-examples" "http/http.thrift" +regenerate_submod "hello" " github.com/cloudwego/kitex-examples" "hello.thrift" +regenerate_submod "thrift_multi_service" " github.com/cloudwego/kitex-examples" "idl/demo.thrift" + diff --git a/server_sdk/thrift/main.go b/server_sdk/thrift/main.go index 4f01a896..19b2015d 100644 --- a/server_sdk/thrift/main.go +++ b/server_sdk/thrift/main.go @@ -22,7 +22,7 @@ import ( "github.com/cloudwego/kitex-examples/kitex_gen/api" "github.com/cloudwego/kitex-examples/kitex_gen/api/echo" - "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/gopkg/protocol/thrift" "github.com/cloudwego/kitex/pkg/klog" "github.com/cloudwego/kitex/pkg/utils" "github.com/cloudwego/kitex/server/invoke" @@ -48,12 +48,11 @@ func main() { msg := invoke.NewMessage(local, remote) // setup request payload - codec := utils.NewThriftMessageCodec() args := api.NewEchoEchoArgs() args.SetReq(&api.Request{ Message: "hello", }) - reqPayload, err := codec.Encode("echo", thrift.CALL, 0, args) + reqPayload, err := thrift.MarshalFastMsg("echo", thrift.CALL, 0, args) if err != nil { klog.Fatal(err) } @@ -74,7 +73,7 @@ func main() { } res := api.NewEchoEchoResult() - method, _, err := codec.Decode(respPayload, res) + method, _, err := thrift.UnmarshalFastMsg(respPayload, res) if err != nil { klog.Fatal(err) } diff --git a/thrift_multi_service/kitex_gen/api/demo.go b/thrift_multi_service/kitex_gen/api/demo.go index b87c8083..192b66a0 100644 --- a/thrift_multi_service/kitex_gen/api/demo.go +++ b/thrift_multi_service/kitex_gen/api/demo.go @@ -1,11 +1,11 @@ -// Code generated by thriftgo (0.3.6). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package api import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" "strings" ) @@ -18,7 +18,6 @@ func NewRequest() *Request { } func (p *Request) InitDefault() { - *p = Request{} } func (p *Request) GetMessage() (v string) { @@ -90,15 +89,18 @@ ReadStructEndError: func (p *Request) ReadField1(iprot thrift.TProtocol) error { + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Message = v + _field = v } + p.Message = _field return nil } func (p *Request) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Request"); err != nil { goto WriteStructBeginError @@ -180,7 +182,6 @@ func NewResponse() *Response { } func (p *Response) InitDefault() { - *p = Response{} } func (p *Response) GetMessage() (v string) { @@ -252,15 +253,18 @@ ReadStructEndError: func (p *Response) ReadField1(iprot thrift.TProtocol) error { + var _field string if v, err := iprot.ReadString(); err != nil { return err } else { - p.Message = v + _field = v } + p.Message = _field return nil } func (p *Response) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("Response"); err != nil { goto WriteStructBeginError @@ -337,171 +341,10 @@ type ServiceA interface { EchoA(ctx context.Context, req *Request) (r *Response, err error) } -type ServiceAClient struct { - c thrift.TClient -} - -func NewServiceAClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ServiceAClient { - return &ServiceAClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewServiceAClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ServiceAClient { - return &ServiceAClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewServiceAClient(c thrift.TClient) *ServiceAClient { - return &ServiceAClient{ - c: c, - } -} - -func (p *ServiceAClient) Client_() thrift.TClient { - return p.c -} - -func (p *ServiceAClient) EchoA(ctx context.Context, req *Request) (r *Response, err error) { - var _args ServiceAEchoAArgs - _args.Req = req - var _result ServiceAEchoAResult - if err = p.Client_().Call(ctx, "echoA", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - type ServiceB interface { EchoB(ctx context.Context, req *Request) (r *Response, err error) } -type ServiceBClient struct { - c thrift.TClient -} - -func NewServiceBClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ServiceBClient { - return &ServiceBClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewServiceBClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ServiceBClient { - return &ServiceBClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewServiceBClient(c thrift.TClient) *ServiceBClient { - return &ServiceBClient{ - c: c, - } -} - -func (p *ServiceBClient) Client_() thrift.TClient { - return p.c -} - -func (p *ServiceBClient) EchoB(ctx context.Context, req *Request) (r *Response, err error) { - var _args ServiceBEchoBArgs - _args.Req = req - var _result ServiceBEchoBResult - if err = p.Client_().Call(ctx, "echoB", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type ServiceAProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler ServiceA -} - -func (p *ServiceAProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *ServiceAProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *ServiceAProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewServiceAProcessor(handler ServiceA) *ServiceAProcessor { - self := &ServiceAProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("echoA", &serviceAProcessorEchoA{handler: handler}) - return self -} -func (p *ServiceAProcessor) 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 serviceAProcessorEchoA struct { - handler ServiceA -} - -func (p *serviceAProcessorEchoA) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ServiceAEchoAArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("echoA", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := ServiceAEchoAResult{} - var retval *Response - if retval, err2 = p.handler.EchoA(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing echoA: "+err2.Error()) - oprot.WriteMessageBegin("echoA", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("echoA", 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 ServiceAEchoAArgs struct { Req *Request `thrift:"req,1" frugal:"1,default,Request" json:"req"` } @@ -511,7 +354,6 @@ func NewServiceAEchoAArgs() *ServiceAEchoAArgs { } func (p *ServiceAEchoAArgs) InitDefault() { - *p = ServiceAEchoAArgs{} } var ServiceAEchoAArgs_Req_DEFAULT *Request @@ -591,14 +433,16 @@ ReadStructEndError: } func (p *ServiceAEchoAArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *ServiceAEchoAArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("echoA_args"); err != nil { goto WriteStructBeginError @@ -680,7 +524,6 @@ func NewServiceAEchoAResult() *ServiceAEchoAResult { } func (p *ServiceAEchoAResult) InitDefault() { - *p = ServiceAEchoAResult{} } var ServiceAEchoAResult_Success_DEFAULT *Response @@ -760,14 +603,16 @@ ReadStructEndError: } func (p *ServiceAEchoAResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *ServiceAEchoAResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("echoA_result"); err != nil { goto WriteStructBeginError @@ -842,95 +687,6 @@ func (p *ServiceAEchoAResult) Field0DeepEqual(src *Response) bool { return true } -type ServiceBProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler ServiceB -} - -func (p *ServiceBProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *ServiceBProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *ServiceBProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewServiceBProcessor(handler ServiceB) *ServiceBProcessor { - self := &ServiceBProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("echoB", &serviceBProcessorEchoB{handler: handler}) - return self -} -func (p *ServiceBProcessor) 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 serviceBProcessorEchoB struct { - handler ServiceB -} - -func (p *serviceBProcessorEchoB) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ServiceBEchoBArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("echoB", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := ServiceBEchoBResult{} - var retval *Response - if retval, err2 = p.handler.EchoB(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing echoB: "+err2.Error()) - oprot.WriteMessageBegin("echoB", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("echoB", 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 ServiceBEchoBArgs struct { Req *Request `thrift:"req,1" frugal:"1,default,Request" json:"req"` } @@ -940,7 +696,6 @@ func NewServiceBEchoBArgs() *ServiceBEchoBArgs { } func (p *ServiceBEchoBArgs) InitDefault() { - *p = ServiceBEchoBArgs{} } var ServiceBEchoBArgs_Req_DEFAULT *Request @@ -1020,14 +775,16 @@ ReadStructEndError: } func (p *ServiceBEchoBArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewRequest() - if err := p.Req.Read(iprot); err != nil { + _field := NewRequest() + if err := _field.Read(iprot); err != nil { return err } + p.Req = _field return nil } func (p *ServiceBEchoBArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("echoB_args"); err != nil { goto WriteStructBeginError @@ -1109,7 +866,6 @@ func NewServiceBEchoBResult() *ServiceBEchoBResult { } func (p *ServiceBEchoBResult) InitDefault() { - *p = ServiceBEchoBResult{} } var ServiceBEchoBResult_Success_DEFAULT *Response @@ -1189,14 +945,16 @@ ReadStructEndError: } func (p *ServiceBEchoBResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewResponse() - if err := p.Success.Read(iprot); err != nil { + _field := NewResponse() + if err := _field.Read(iprot); err != nil { return err } + p.Success = _field return nil } func (p *ServiceBEchoBResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 if err = oprot.WriteStructBegin("echoB_result"); err != nil { goto WriteStructBeginError diff --git a/thrift_multi_service/kitex_gen/api/k-demo.go b/thrift_multi_service/kitex_gen/api/k-demo.go index b7117ff5..8700925b 100644 --- a/thrift_multi_service/kitex_gen/api/k-demo.go +++ b/thrift_multi_service/kitex_gen/api/k-demo.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package api @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,24 +17,18 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *Request) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -53,120 +45,89 @@ func (p *Request) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Request[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 *Request) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Message = v - + _field = v } + p.Message = _field return offset, nil } -// for compatibility func (p *Request) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Request) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Request) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Request") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Request) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Request") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Request) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Request) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Message) return offset } func (p *Request) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Message) return l } func (p *Response) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -183,120 +144,89 @@ func (p *Response) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_Response[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 *Response) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Message = v - + _field = v } + p.Message = _field return offset, nil } -// for compatibility func (p *Response) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Response) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Response") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Response) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Response") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Response) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Message) return offset } func (p *Response) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Message) return l } func (p *ServiceAEchoAArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -313,117 +243,87 @@ func (p *ServiceAEchoAArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ServiceAEchoAArgs[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 *ServiceAEchoAArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *ServiceAEchoAArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ServiceAEchoAArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServiceAEchoAArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "echoA_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ServiceAEchoAArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("echoA_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ServiceAEchoAArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServiceAEchoAArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *ServiceAEchoAArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ServiceAEchoAResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -440,93 +340,69 @@ func (p *ServiceAEchoAResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ServiceAEchoAResult[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 *ServiceAEchoAResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *ServiceAEchoAResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ServiceAEchoAResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServiceAEchoAResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "echoA_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ServiceAEchoAResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("echoA_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ServiceAEchoAResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServiceAEchoAResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -534,27 +410,21 @@ func (p *ServiceAEchoAResult) fastWriteField0(buf []byte, binaryWriter bthrift.B func (p *ServiceAEchoAResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *ServiceBEchoBArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -571,117 +441,87 @@ func (p *ServiceBEchoBArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ServiceBEchoBArgs[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 *ServiceBEchoBArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *ServiceBEchoBArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ServiceBEchoBArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServiceBEchoBArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "echoB_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ServiceBEchoBArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("echoB_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ServiceBEchoBArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServiceBEchoBArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *ServiceBEchoBArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *ServiceBEchoBResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -698,93 +538,69 @@ func (p *ServiceBEchoBResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_ServiceBEchoBResult[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 *ServiceBEchoBResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *ServiceBEchoBResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *ServiceBEchoBResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServiceBEchoBResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "echoB_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *ServiceBEchoBResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("echoB_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *ServiceBEchoBResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *ServiceBEchoBResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -792,9 +608,8 @@ func (p *ServiceBEchoBResult) fastWriteField0(buf []byte, binaryWriter bthrift.B func (p *ServiceBEchoBResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/thrift_multi_service/kitex_gen/api/servicea/client.go b/thrift_multi_service/kitex_gen/api/servicea/client.go index fcbf576f..721a41c4 100644 --- a/thrift_multi_service/kitex_gen/api/servicea/client.go +++ b/thrift_multi_service/kitex_gen/api/servicea/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package servicea diff --git a/thrift_multi_service/kitex_gen/api/servicea/server.go b/thrift_multi_service/kitex_gen/api/servicea/server.go index 8071be53..d9cacd4e 100644 --- a/thrift_multi_service/kitex_gen/api/servicea/server.go +++ b/thrift_multi_service/kitex_gen/api/servicea/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package servicea import ( diff --git a/thrift_multi_service/kitex_gen/api/servicea/servicea.go b/thrift_multi_service/kitex_gen/api/servicea/servicea.go index 87af7daf..e72a461b 100644 --- a/thrift_multi_service/kitex_gen/api/servicea/servicea.go +++ b/thrift_multi_service/kitex_gen/api/servicea/servicea.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package servicea @@ -33,12 +33,12 @@ func serviceInfo() *kitex.ServiceInfo { return serviceAServiceInfo } -// for client +// for stream client func serviceInfoForStreamClient() *kitex.ServiceInfo { return serviceAServiceInfoForStreamClient } -// for stream client +// for client func serviceInfoForClient() *kitex.ServiceInfo { return serviceAServiceInfoForClient } @@ -80,7 +80,7 @@ func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreami HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.9.0", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/thrift_multi_service/kitex_gen/api/serviceb/client.go b/thrift_multi_service/kitex_gen/api/serviceb/client.go index 6619714d..9c05e602 100644 --- a/thrift_multi_service/kitex_gen/api/serviceb/client.go +++ b/thrift_multi_service/kitex_gen/api/serviceb/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package serviceb diff --git a/thrift_multi_service/kitex_gen/api/serviceb/server.go b/thrift_multi_service/kitex_gen/api/serviceb/server.go index 44676a3a..5793bd5f 100644 --- a/thrift_multi_service/kitex_gen/api/serviceb/server.go +++ b/thrift_multi_service/kitex_gen/api/serviceb/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package serviceb import ( diff --git a/thrift_multi_service/kitex_gen/api/serviceb/serviceb.go b/thrift_multi_service/kitex_gen/api/serviceb/serviceb.go index 2e31031e..55788c5c 100644 --- a/thrift_multi_service/kitex_gen/api/serviceb/serviceb.go +++ b/thrift_multi_service/kitex_gen/api/serviceb/serviceb.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package serviceb @@ -33,12 +33,12 @@ func serviceInfo() *kitex.ServiceInfo { return serviceBServiceInfo } -// for client +// for stream client func serviceInfoForStreamClient() *kitex.ServiceInfo { return serviceBServiceInfoForStreamClient } -// for stream client +// for client func serviceInfoForClient() *kitex.ServiceInfo { return serviceBServiceInfoForClient } @@ -80,7 +80,7 @@ func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreami HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.9.0", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo diff --git a/thrift_streaming/kitex_gen/echo/api.go b/thrift_streaming/kitex_gen/echo/api.go index b3b1694c..d4fd5cf8 100644 --- a/thrift_streaming/kitex_gen/echo/api.go +++ b/thrift_streaming/kitex_gen/echo/api.go @@ -1,11 +1,10 @@ -// Code generated by thriftgo (0.3.6). DO NOT EDIT. +// Code generated by thriftgo (0.3.18). DO NOT EDIT. package echo import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" "github.com/cloudwego/kitex/pkg/streaming" "strings" ) @@ -19,7 +18,6 @@ func NewRequest() *Request { } func (p *Request) InitDefault() { - *p = Request{} } func (p *Request) GetMessage() (v string) { @@ -29,135 +27,11 @@ func (p *Request) SetMessage(val string) { p.Message = val } -var fieldIDToName_Request = map[int16]string{ - 1: "message", -} - -func (p *Request) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetMessage 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 - } - issetMessage = 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 !issetMessage { - 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_Request[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_Request[fieldId])) -} - -func (p *Request) ReadField1(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Message = v - } - return nil -} - -func (p *Request) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Request"); 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 *Request) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Message); 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 *Request) String() string { if p == nil { return "" } return fmt.Sprintf("Request(%+v)", *p) - } func (p *Request) DeepEqual(ano *Request) bool { @@ -180,6 +54,10 @@ func (p *Request) Field1DeepEqual(src string) bool { return true } +var fieldIDToName_Request = map[int16]string{ + 1: "message", +} + type Response struct { Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` } @@ -189,7 +67,6 @@ func NewResponse() *Response { } func (p *Response) InitDefault() { - *p = Response{} } func (p *Response) GetMessage() (v string) { @@ -199,135 +76,11 @@ func (p *Response) SetMessage(val string) { p.Message = val } -var fieldIDToName_Response = map[int16]string{ - 1: "message", -} - -func (p *Response) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetMessage 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 - } - issetMessage = 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 !issetMessage { - 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_Response[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_Response[fieldId])) -} - -func (p *Response) ReadField1(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Message = v - } - return nil -} - -func (p *Response) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Response"); 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 *Response) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Message); 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 *Response) String() string { if p == nil { return "" } return fmt.Sprintf("Response(%+v)", *p) - } func (p *Response) DeepEqual(ano *Response) bool { @@ -350,6 +103,10 @@ func (p *Response) Field1DeepEqual(src string) bool { return true } +var fieldIDToName_Response = map[int16]string{ + 1: "message", +} + type TestService interface { Echo(stream TestService_EchoServer) (err error) @@ -362,204 +119,6 @@ type TestService interface { EchoPingPong(ctx context.Context, req *Request) (r *Response, err error) } -type TestServiceClient struct { - c thrift.TClient -} - -func NewTestServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *TestServiceClient { - return &TestServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewTestServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *TestServiceClient { - return &TestServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewTestServiceClient(c thrift.TClient) *TestServiceClient { - return &TestServiceClient{ - c: c, - } -} - -func (p *TestServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *TestServiceClient) Echo(stream TestService_EchoServer) (err error) { - panic("streaming method TestService.Echo(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") -} - -type TestService_EchoServer interface { - streaming.Stream - - Recv() (*Request, error) - - Send(*Response) error -} - -func (p *TestServiceClient) EchoClient(stream TestService_EchoClientServer) (err error) { - panic("streaming method TestService.EchoClient(mode = client) not available, please use Kitex Thrift Streaming Client.") -} - -type TestService_EchoClientServer interface { - streaming.Stream - - Recv() (*Request, error) - - SendAndClose(*Response) error -} - -func (p *TestServiceClient) EchoServer(req *Request, stream TestService_EchoServerServer) (err error) { - panic("streaming method TestService.EchoServer(mode = server) not available, please use Kitex Thrift Streaming Client.") -} - -type TestService_EchoServerServer interface { - streaming.Stream - - Send(*Response) error -} - -func (p *TestServiceClient) EchoUnary(ctx context.Context, req *Request) (r *Response, err error) { - panic("streaming method TestService.EchoUnary(mode = unary) not available, please use Kitex Thrift Streaming Client.") -} -func (p *TestServiceClient) EchoPingPong(ctx context.Context, req *Request) (r *Response, err error) { - var _args TestServiceEchoPingPongArgs - _args.Req = req - var _result TestServiceEchoPingPongResult - if err = p.Client_().Call(ctx, "EchoPingPong", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type TestServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler TestService -} - -func (p *TestServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *TestServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *TestServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewTestServiceProcessor(handler TestService) *TestServiceProcessor { - self := &TestServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("Echo", &testServiceProcessorEcho{handler: handler}) - self.AddToProcessorMap("EchoClient", &testServiceProcessorEchoClient{handler: handler}) - self.AddToProcessorMap("EchoServer", &testServiceProcessorEchoServer{handler: handler}) - self.AddToProcessorMap("EchoUnary", &testServiceProcessorEchoUnary{handler: handler}) - self.AddToProcessorMap("EchoPingPong", &testServiceProcessorEchoPingPong{handler: handler}) - return self -} -func (p *TestServiceProcessor) 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 testServiceProcessorEcho struct { - handler TestService -} - -func (p *testServiceProcessorEcho) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method TestService.Echo(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") -} - -type testServiceProcessorEchoClient struct { - handler TestService -} - -func (p *testServiceProcessorEchoClient) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method TestService.EchoClient(mode = client) not available, please use Kitex Thrift Streaming Client.") -} - -type testServiceProcessorEchoServer struct { - handler TestService -} - -func (p *testServiceProcessorEchoServer) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method TestService.EchoServer(mode = server) not available, please use Kitex Thrift Streaming Client.") -} - -type testServiceProcessorEchoUnary struct { - handler TestService -} - -func (p *testServiceProcessorEchoUnary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method TestService.EchoUnary(mode = unary) not available, please use Kitex Thrift Streaming Client.") -} - -type testServiceProcessorEchoPingPong struct { - handler TestService -} - -func (p *testServiceProcessorEchoPingPong) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := TestServiceEchoPingPongArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := TestServiceEchoPingPongResult{} - var retval *Response - if retval, err2 = p.handler.EchoPingPong(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPong: "+err2.Error()) - oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("EchoPingPong", 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 TestServiceEchoArgs struct { Req *Request `thrift:"req,1" frugal:"1,default,Request" json:"req"` } @@ -569,7 +128,6 @@ func NewTestServiceEchoArgs() *TestServiceEchoArgs { } func (p *TestServiceEchoArgs) InitDefault() { - *p = TestServiceEchoArgs{} } var TestServiceEchoArgs_Req_DEFAULT *Request @@ -584,129 +142,15 @@ func (p *TestServiceEchoArgs) SetReq(val *Request) { p.Req = val } -var fieldIDToName_TestServiceEchoArgs = map[int16]string{ - 1: "req", -} - func (p *TestServiceEchoArgs) IsSetReq() bool { return p.Req != nil } -func (p *TestServiceEchoArgs) 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_TestServiceEchoArgs[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 *TestServiceEchoArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewRequest() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *TestServiceEchoArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Echo_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 *TestServiceEchoArgs) 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 *TestServiceEchoArgs) String() string { if p == nil { return "" } return fmt.Sprintf("TestServiceEchoArgs(%+v)", *p) - } func (p *TestServiceEchoArgs) DeepEqual(ano *TestServiceEchoArgs) bool { @@ -729,6 +173,10 @@ func (p *TestServiceEchoArgs) Field1DeepEqual(src *Request) bool { return true } +var fieldIDToName_TestServiceEchoArgs = map[int16]string{ + 1: "req", +} + type TestServiceEchoResult struct { Success *Response `thrift:"success,0,optional" frugal:"0,optional,Response" json:"success,omitempty"` } @@ -738,7 +186,6 @@ func NewTestServiceEchoResult() *TestServiceEchoResult { } func (p *TestServiceEchoResult) InitDefault() { - *p = TestServiceEchoResult{} } var TestServiceEchoResult_Success_DEFAULT *Response @@ -753,131 +200,15 @@ func (p *TestServiceEchoResult) SetSuccess(x interface{}) { p.Success = x.(*Response) } -var fieldIDToName_TestServiceEchoResult = map[int16]string{ - 0: "success", -} - func (p *TestServiceEchoResult) IsSetSuccess() bool { return p.Success != nil } -func (p *TestServiceEchoResult) 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_TestServiceEchoResult[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 *TestServiceEchoResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *TestServiceEchoResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Echo_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 *TestServiceEchoResult) 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 *TestServiceEchoResult) String() string { if p == nil { return "" } return fmt.Sprintf("TestServiceEchoResult(%+v)", *p) - } func (p *TestServiceEchoResult) DeepEqual(ano *TestServiceEchoResult) bool { @@ -900,6 +231,18 @@ func (p *TestServiceEchoResult) Field0DeepEqual(src *Response) bool { return true } +var fieldIDToName_TestServiceEchoResult = map[int16]string{ + 0: "success", +} + +type TestService_EchoServer interface { + streaming.Stream + + Recv() (*Request, error) + + Send(*Response) error +} + type TestServiceEchoClientArgs struct { Req *Request `thrift:"req,1" frugal:"1,default,Request" json:"req"` } @@ -909,7 +252,6 @@ func NewTestServiceEchoClientArgs() *TestServiceEchoClientArgs { } func (p *TestServiceEchoClientArgs) InitDefault() { - *p = TestServiceEchoClientArgs{} } var TestServiceEchoClientArgs_Req_DEFAULT *Request @@ -924,129 +266,15 @@ func (p *TestServiceEchoClientArgs) SetReq(val *Request) { p.Req = val } -var fieldIDToName_TestServiceEchoClientArgs = map[int16]string{ - 1: "req", -} - func (p *TestServiceEchoClientArgs) IsSetReq() bool { return p.Req != nil } -func (p *TestServiceEchoClientArgs) 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_TestServiceEchoClientArgs[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 *TestServiceEchoClientArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewRequest() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *TestServiceEchoClientArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoClient_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 *TestServiceEchoClientArgs) 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 *TestServiceEchoClientArgs) String() string { if p == nil { return "" } return fmt.Sprintf("TestServiceEchoClientArgs(%+v)", *p) - } func (p *TestServiceEchoClientArgs) DeepEqual(ano *TestServiceEchoClientArgs) bool { @@ -1069,6 +297,10 @@ func (p *TestServiceEchoClientArgs) Field1DeepEqual(src *Request) bool { return true } +var fieldIDToName_TestServiceEchoClientArgs = map[int16]string{ + 1: "req", +} + type TestServiceEchoClientResult struct { Success *Response `thrift:"success,0,optional" frugal:"0,optional,Response" json:"success,omitempty"` } @@ -1078,7 +310,6 @@ func NewTestServiceEchoClientResult() *TestServiceEchoClientResult { } func (p *TestServiceEchoClientResult) InitDefault() { - *p = TestServiceEchoClientResult{} } var TestServiceEchoClientResult_Success_DEFAULT *Response @@ -1093,131 +324,15 @@ func (p *TestServiceEchoClientResult) SetSuccess(x interface{}) { p.Success = x.(*Response) } -var fieldIDToName_TestServiceEchoClientResult = map[int16]string{ - 0: "success", -} - func (p *TestServiceEchoClientResult) IsSetSuccess() bool { return p.Success != nil } -func (p *TestServiceEchoClientResult) 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_TestServiceEchoClientResult[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 *TestServiceEchoClientResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *TestServiceEchoClientResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoClient_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 *TestServiceEchoClientResult) 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 *TestServiceEchoClientResult) String() string { if p == nil { return "" } return fmt.Sprintf("TestServiceEchoClientResult(%+v)", *p) - } func (p *TestServiceEchoClientResult) DeepEqual(ano *TestServiceEchoClientResult) bool { @@ -1240,6 +355,18 @@ func (p *TestServiceEchoClientResult) Field0DeepEqual(src *Response) bool { return true } +var fieldIDToName_TestServiceEchoClientResult = map[int16]string{ + 0: "success", +} + +type TestService_EchoClientServer interface { + streaming.Stream + + Recv() (*Request, error) + + SendAndClose(*Response) error +} + type TestServiceEchoServerArgs struct { Req *Request `thrift:"req,1" frugal:"1,default,Request" json:"req"` } @@ -1249,7 +376,6 @@ func NewTestServiceEchoServerArgs() *TestServiceEchoServerArgs { } func (p *TestServiceEchoServerArgs) InitDefault() { - *p = TestServiceEchoServerArgs{} } var TestServiceEchoServerArgs_Req_DEFAULT *Request @@ -1264,129 +390,15 @@ func (p *TestServiceEchoServerArgs) SetReq(val *Request) { p.Req = val } -var fieldIDToName_TestServiceEchoServerArgs = map[int16]string{ - 1: "req", -} - func (p *TestServiceEchoServerArgs) IsSetReq() bool { return p.Req != nil } -func (p *TestServiceEchoServerArgs) 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_TestServiceEchoServerArgs[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 *TestServiceEchoServerArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewRequest() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *TestServiceEchoServerArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoServer_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 *TestServiceEchoServerArgs) 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 *TestServiceEchoServerArgs) String() string { if p == nil { return "" } return fmt.Sprintf("TestServiceEchoServerArgs(%+v)", *p) - } func (p *TestServiceEchoServerArgs) DeepEqual(ano *TestServiceEchoServerArgs) bool { @@ -1409,6 +421,10 @@ func (p *TestServiceEchoServerArgs) Field1DeepEqual(src *Request) bool { return true } +var fieldIDToName_TestServiceEchoServerArgs = map[int16]string{ + 1: "req", +} + type TestServiceEchoServerResult struct { Success *Response `thrift:"success,0,optional" frugal:"0,optional,Response" json:"success,omitempty"` } @@ -1418,7 +434,6 @@ func NewTestServiceEchoServerResult() *TestServiceEchoServerResult { } func (p *TestServiceEchoServerResult) InitDefault() { - *p = TestServiceEchoServerResult{} } var TestServiceEchoServerResult_Success_DEFAULT *Response @@ -1433,131 +448,15 @@ func (p *TestServiceEchoServerResult) SetSuccess(x interface{}) { p.Success = x.(*Response) } -var fieldIDToName_TestServiceEchoServerResult = map[int16]string{ - 0: "success", -} - func (p *TestServiceEchoServerResult) IsSetSuccess() bool { return p.Success != nil } -func (p *TestServiceEchoServerResult) 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_TestServiceEchoServerResult[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 *TestServiceEchoServerResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *TestServiceEchoServerResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoServer_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 *TestServiceEchoServerResult) 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 *TestServiceEchoServerResult) String() string { if p == nil { return "" } return fmt.Sprintf("TestServiceEchoServerResult(%+v)", *p) - } func (p *TestServiceEchoServerResult) DeepEqual(ano *TestServiceEchoServerResult) bool { @@ -1580,6 +479,16 @@ func (p *TestServiceEchoServerResult) Field0DeepEqual(src *Response) bool { return true } +var fieldIDToName_TestServiceEchoServerResult = map[int16]string{ + 0: "success", +} + +type TestService_EchoServerServer interface { + streaming.Stream + + Send(*Response) error +} + type TestServiceEchoUnaryArgs struct { Req *Request `thrift:"req,1" frugal:"1,default,Request" json:"req"` } @@ -1589,7 +498,6 @@ func NewTestServiceEchoUnaryArgs() *TestServiceEchoUnaryArgs { } func (p *TestServiceEchoUnaryArgs) InitDefault() { - *p = TestServiceEchoUnaryArgs{} } var TestServiceEchoUnaryArgs_Req_DEFAULT *Request @@ -1604,129 +512,15 @@ func (p *TestServiceEchoUnaryArgs) SetReq(val *Request) { p.Req = val } -var fieldIDToName_TestServiceEchoUnaryArgs = map[int16]string{ - 1: "req", -} - func (p *TestServiceEchoUnaryArgs) IsSetReq() bool { return p.Req != nil } -func (p *TestServiceEchoUnaryArgs) 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_TestServiceEchoUnaryArgs[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 *TestServiceEchoUnaryArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewRequest() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *TestServiceEchoUnaryArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoUnary_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 *TestServiceEchoUnaryArgs) 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 *TestServiceEchoUnaryArgs) String() string { if p == nil { return "" } return fmt.Sprintf("TestServiceEchoUnaryArgs(%+v)", *p) - } func (p *TestServiceEchoUnaryArgs) DeepEqual(ano *TestServiceEchoUnaryArgs) bool { @@ -1749,6 +543,10 @@ func (p *TestServiceEchoUnaryArgs) Field1DeepEqual(src *Request) bool { return true } +var fieldIDToName_TestServiceEchoUnaryArgs = map[int16]string{ + 1: "req", +} + type TestServiceEchoUnaryResult struct { Success *Response `thrift:"success,0,optional" frugal:"0,optional,Response" json:"success,omitempty"` } @@ -1758,7 +556,6 @@ func NewTestServiceEchoUnaryResult() *TestServiceEchoUnaryResult { } func (p *TestServiceEchoUnaryResult) InitDefault() { - *p = TestServiceEchoUnaryResult{} } var TestServiceEchoUnaryResult_Success_DEFAULT *Response @@ -1773,131 +570,15 @@ func (p *TestServiceEchoUnaryResult) SetSuccess(x interface{}) { p.Success = x.(*Response) } -var fieldIDToName_TestServiceEchoUnaryResult = map[int16]string{ - 0: "success", -} - func (p *TestServiceEchoUnaryResult) IsSetSuccess() bool { return p.Success != nil } -func (p *TestServiceEchoUnaryResult) 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_TestServiceEchoUnaryResult[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 *TestServiceEchoUnaryResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *TestServiceEchoUnaryResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoUnary_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 *TestServiceEchoUnaryResult) 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 *TestServiceEchoUnaryResult) String() string { if p == nil { return "" } return fmt.Sprintf("TestServiceEchoUnaryResult(%+v)", *p) - } func (p *TestServiceEchoUnaryResult) DeepEqual(ano *TestServiceEchoUnaryResult) bool { @@ -1920,6 +601,10 @@ func (p *TestServiceEchoUnaryResult) Field0DeepEqual(src *Response) bool { return true } +var fieldIDToName_TestServiceEchoUnaryResult = map[int16]string{ + 0: "success", +} + type TestServiceEchoPingPongArgs struct { Req *Request `thrift:"req,1" frugal:"1,default,Request" json:"req"` } @@ -1929,7 +614,6 @@ func NewTestServiceEchoPingPongArgs() *TestServiceEchoPingPongArgs { } func (p *TestServiceEchoPingPongArgs) InitDefault() { - *p = TestServiceEchoPingPongArgs{} } var TestServiceEchoPingPongArgs_Req_DEFAULT *Request @@ -1944,129 +628,15 @@ func (p *TestServiceEchoPingPongArgs) SetReq(val *Request) { p.Req = val } -var fieldIDToName_TestServiceEchoPingPongArgs = map[int16]string{ - 1: "req", -} - func (p *TestServiceEchoPingPongArgs) IsSetReq() bool { return p.Req != nil } -func (p *TestServiceEchoPingPongArgs) 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_TestServiceEchoPingPongArgs[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 *TestServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewRequest() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *TestServiceEchoPingPongArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPong_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 *TestServiceEchoPingPongArgs) 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 *TestServiceEchoPingPongArgs) String() string { if p == nil { return "" } return fmt.Sprintf("TestServiceEchoPingPongArgs(%+v)", *p) - } func (p *TestServiceEchoPingPongArgs) DeepEqual(ano *TestServiceEchoPingPongArgs) bool { @@ -2089,6 +659,10 @@ func (p *TestServiceEchoPingPongArgs) Field1DeepEqual(src *Request) bool { return true } +var fieldIDToName_TestServiceEchoPingPongArgs = map[int16]string{ + 1: "req", +} + type TestServiceEchoPingPongResult struct { Success *Response `thrift:"success,0,optional" frugal:"0,optional,Response" json:"success,omitempty"` } @@ -2098,7 +672,6 @@ func NewTestServiceEchoPingPongResult() *TestServiceEchoPingPongResult { } func (p *TestServiceEchoPingPongResult) InitDefault() { - *p = TestServiceEchoPingPongResult{} } var TestServiceEchoPingPongResult_Success_DEFAULT *Response @@ -2113,131 +686,15 @@ func (p *TestServiceEchoPingPongResult) SetSuccess(x interface{}) { p.Success = x.(*Response) } -var fieldIDToName_TestServiceEchoPingPongResult = map[int16]string{ - 0: "success", -} - func (p *TestServiceEchoPingPongResult) IsSetSuccess() bool { return p.Success != nil } -func (p *TestServiceEchoPingPongResult) 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_TestServiceEchoPingPongResult[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 *TestServiceEchoPingPongResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *TestServiceEchoPingPongResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPong_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 *TestServiceEchoPingPongResult) 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 *TestServiceEchoPingPongResult) String() string { if p == nil { return "" } return fmt.Sprintf("TestServiceEchoPingPongResult(%+v)", *p) - } func (p *TestServiceEchoPingPongResult) DeepEqual(ano *TestServiceEchoPingPongResult) bool { @@ -2259,3 +716,7 @@ func (p *TestServiceEchoPingPongResult) Field0DeepEqual(src *Response) bool { } return true } + +var fieldIDToName_TestServiceEchoPingPongResult = map[int16]string{ + 0: "success", +} diff --git a/thrift_streaming/kitex_gen/echo/k-api.go b/thrift_streaming/kitex_gen/echo/k-api.go index 96382f02..102e3fa1 100644 --- a/thrift_streaming/kitex_gen/echo/k-api.go +++ b/thrift_streaming/kitex_gen/echo/k-api.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package echo @@ -8,9 +8,7 @@ import ( "reflect" "strings" - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) // unused protection @@ -19,25 +17,19 @@ var ( _ = (*bytes.Buffer)(nil) _ = (*strings.Builder)(nil) _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + _ = thrift.STOP ) func (p *Request) FastRead(buf []byte) (int, error) { + var err error var offset int var l int var fieldTypeId thrift.TType var fieldId int16 var issetMessage 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -55,30 +47,19 @@ func (p *Request) FastRead(buf []byte) (int, error) { } issetMessage = true } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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 !issetMessage { @@ -86,96 +67,76 @@ func (p *Request) FastRead(buf []byte) (int, error) { 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_Request[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_Request[fieldId])) + return offset, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_Request[fieldId])) } func (p *Request) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Message = v - + _field = v } + p.Message = _field return offset, nil } -// for compatibility func (p *Request) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Request) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Request) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Request") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Request) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Request") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Request) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Request) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Message) return offset } func (p *Request) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Message) return l } func (p *Response) FastRead(buf []byte) (int, error) { + var err error var offset int var l int var fieldTypeId thrift.TType var fieldId int16 var issetMessage 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -193,30 +154,19 @@ func (p *Response) FastRead(buf []byte) (int, error) { } issetMessage = true } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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 !issetMessage { @@ -224,95 +174,75 @@ func (p *Response) FastRead(buf []byte) (int, error) { 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_Response[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_Response[fieldId])) + return offset, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_Response[fieldId])) } func (p *Response) FastReadField1(buf []byte) (int, error) { offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + var _field string + if v, l, err := thrift.Binary.ReadString(buf[offset:]); err != nil { return offset, err } else { offset += l - - p.Message = v - + _field = v } + p.Message = _field return offset, nil } -// for compatibility func (p *Response) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *Response) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Response") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *Response) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Response") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *Response) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *Response) fastWriteField1(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRING, 1) + offset += thrift.Binary.WriteStringNocopy(buf[offset:], w, p.Message) return offset } func (p *Response) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() + l += thrift.Binary.FieldBeginLength() + l += thrift.Binary.StringLengthNocopy(p.Message) return l } func (p *TestServiceEchoArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -329,117 +259,87 @@ func (p *TestServiceEchoArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_TestServiceEchoArgs[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 *TestServiceEchoArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *TestServiceEchoArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *TestServiceEchoArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Echo_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *TestServiceEchoArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Echo_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *TestServiceEchoArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *TestServiceEchoArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *TestServiceEchoResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -456,93 +356,69 @@ func (p *TestServiceEchoResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_TestServiceEchoResult[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 *TestServiceEchoResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *TestServiceEchoResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *TestServiceEchoResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Echo_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *TestServiceEchoResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("Echo_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *TestServiceEchoResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -550,27 +426,21 @@ func (p *TestServiceEchoResult) fastWriteField0(buf []byte, binaryWriter bthrift func (p *TestServiceEchoResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *TestServiceEchoClientArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -587,117 +457,87 @@ func (p *TestServiceEchoClientArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_TestServiceEchoClientArgs[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 *TestServiceEchoClientArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *TestServiceEchoClientArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *TestServiceEchoClientArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoClientArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoClient_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *TestServiceEchoClientArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoClient_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *TestServiceEchoClientArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoClientArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *TestServiceEchoClientArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *TestServiceEchoClientResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -714,93 +554,69 @@ func (p *TestServiceEchoClientResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_TestServiceEchoClientResult[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 *TestServiceEchoClientResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *TestServiceEchoClientResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *TestServiceEchoClientResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoClientResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoClient_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *TestServiceEchoClientResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoClient_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *TestServiceEchoClientResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoClientResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -808,27 +624,21 @@ func (p *TestServiceEchoClientResult) fastWriteField0(buf []byte, binaryWriter b func (p *TestServiceEchoClientResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *TestServiceEchoServerArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -845,117 +655,87 @@ func (p *TestServiceEchoServerArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_TestServiceEchoServerArgs[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 *TestServiceEchoServerArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *TestServiceEchoServerArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *TestServiceEchoServerArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoServerArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoServer_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *TestServiceEchoServerArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoServer_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *TestServiceEchoServerArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoServerArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *TestServiceEchoServerArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *TestServiceEchoServerResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -972,93 +752,69 @@ func (p *TestServiceEchoServerResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_TestServiceEchoServerResult[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 *TestServiceEchoServerResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *TestServiceEchoServerResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *TestServiceEchoServerResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoServerResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoServer_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *TestServiceEchoServerResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoServer_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *TestServiceEchoServerResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoServerResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -1066,27 +822,21 @@ func (p *TestServiceEchoServerResult) fastWriteField0(buf []byte, binaryWriter b func (p *TestServiceEchoServerResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *TestServiceEchoUnaryArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1103,117 +853,87 @@ func (p *TestServiceEchoUnaryArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_TestServiceEchoUnaryArgs[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 *TestServiceEchoUnaryArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *TestServiceEchoUnaryArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *TestServiceEchoUnaryArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoUnaryArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoUnary_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *TestServiceEchoUnaryArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoUnary_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *TestServiceEchoUnaryArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoUnaryArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *TestServiceEchoUnaryArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *TestServiceEchoUnaryResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1230,93 +950,69 @@ func (p *TestServiceEchoUnaryResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_TestServiceEchoUnaryResult[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 *TestServiceEchoUnaryResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *TestServiceEchoUnaryResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *TestServiceEchoUnaryResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoUnaryResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoUnary_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *TestServiceEchoUnaryResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoUnary_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *TestServiceEchoUnaryResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoUnaryResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -1324,27 +1020,21 @@ func (p *TestServiceEchoUnaryResult) fastWriteField0(buf []byte, binaryWriter bt func (p *TestServiceEchoUnaryResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } func (p *TestServiceEchoPingPongArgs) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1361,117 +1051,87 @@ func (p *TestServiceEchoPingPongArgs) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_TestServiceEchoPingPongArgs[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 *TestServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, error) { offset := 0 - - tmp := NewRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewRequest() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Req = tmp + p.Req = _field return offset, nil } -// for compatibility func (p *TestServiceEchoPingPongArgs) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *TestServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_args") if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *TestServiceEchoPingPongArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPong_args") if p != nil { l += p.field1Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *TestServiceEchoPingPongArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoPingPongArgs) fastWriteField1(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], w) return offset } func (p *TestServiceEchoPingPongArgs) field1Length() int { l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += thrift.Binary.FieldBeginLength() l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() return l } func (p *TestServiceEchoPingPongResult) 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:]) + fieldTypeId, fieldId, l, err = thrift.Binary.ReadFieldBegin(buf[offset:]) offset += l if err != nil { goto ReadFieldBeginError @@ -1488,93 +1148,69 @@ func (p *TestServiceEchoPingPongResult) FastRead(buf []byte) (int, error) { goto ReadFieldError } } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.Binary.Skip(buf[offset:], fieldTypeId) offset += l if err != nil { goto SkipFieldError } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + l, err = thrift.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_TestServiceEchoPingPongResult[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 *TestServiceEchoPingPongResult) FastReadField0(buf []byte) (int, error) { offset := 0 - - tmp := NewResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { + _field := NewResponse() + if l, err := _field.FastRead(buf[offset:]); err != nil { return offset, err } else { offset += l } - p.Success = tmp + p.Success = _field return offset, nil } -// for compatibility func (p *TestServiceEchoPingPongResult) FastWrite(buf []byte) int { - return 0 + return p.FastWriteNocopy(buf, nil) } -func (p *TestServiceEchoPingPongResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoPingPongResult) FastWriteNocopy(buf []byte, w thrift.NocopyWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_result") if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField0(buf[offset:], w) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + offset += thrift.Binary.WriteFieldStop(buf[offset:]) return offset } func (p *TestServiceEchoPingPongResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPong_result") if p != nil { l += p.field0Length() } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() + l += thrift.Binary.FieldStopLength() return l } -func (p *TestServiceEchoPingPongResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *TestServiceEchoPingPongResult) fastWriteField0(buf []byte, w thrift.NocopyWriter) 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:]) + offset += thrift.Binary.WriteFieldBegin(buf[offset:], thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], w) } return offset } @@ -1582,9 +1218,8 @@ func (p *TestServiceEchoPingPongResult) fastWriteField0(buf []byte, binaryWriter func (p *TestServiceEchoPingPongResult) field0Length() int { l := 0 if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += thrift.Binary.FieldBeginLength() l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() } return l } diff --git a/thrift_streaming/kitex_gen/echo/testservice/client.go b/thrift_streaming/kitex_gen/echo/testservice/client.go index 16efe64d..2e0b59a3 100644 --- a/thrift_streaming/kitex_gen/echo/testservice/client.go +++ b/thrift_streaming/kitex_gen/echo/testservice/client.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package testservice diff --git a/thrift_streaming/kitex_gen/echo/testservice/server.go b/thrift_streaming/kitex_gen/echo/testservice/server.go index 655c186a..58fef3c7 100644 --- a/thrift_streaming/kitex_gen/echo/testservice/server.go +++ b/thrift_streaming/kitex_gen/echo/testservice/server.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package testservice import ( diff --git a/thrift_streaming/kitex_gen/echo/testservice/testservice.go b/thrift_streaming/kitex_gen/echo/testservice/testservice.go index df7891d7..623a90e6 100644 --- a/thrift_streaming/kitex_gen/echo/testservice/testservice.go +++ b/thrift_streaming/kitex_gen/echo/testservice/testservice.go @@ -1,4 +1,4 @@ -// Code generated by Kitex v0.9.0. DO NOT EDIT. +// Code generated by Kitex v0.12.0. DO NOT EDIT. package testservice @@ -63,12 +63,12 @@ func serviceInfo() *kitex.ServiceInfo { return testServiceServiceInfo } -// for client +// for stream client func serviceInfoForStreamClient() *kitex.ServiceInfo { return testServiceServiceInfoForStreamClient } -// for stream client +// for client func serviceInfoForClient() *kitex.ServiceInfo { return testServiceServiceInfoForClient } @@ -110,7 +110,7 @@ func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreami HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.9.0", + KiteXGenVersion: "v0.12.0", Extra: extra, } return svcInfo @@ -129,6 +129,13 @@ type testServiceEchoClient struct { streaming.Stream } +func (x *testServiceEchoClient) DoFinish(err error) { + if finisher, ok := x.Stream.(streaming.WithDoFinish); ok { + finisher.DoFinish(err) + } else { + panic(fmt.Sprintf("streaming.WithDoFinish is not implemented by %T", x.Stream)) + } +} func (x *testServiceEchoClient) Send(m *echo.Request) error { return x.Stream.SendMsg(m) } @@ -171,6 +178,13 @@ type testServiceEchoClientClient struct { streaming.Stream } +func (x *testServiceEchoClientClient) DoFinish(err error) { + if finisher, ok := x.Stream.(streaming.WithDoFinish); ok { + finisher.DoFinish(err) + } else { + panic(fmt.Sprintf("streaming.WithDoFinish is not implemented by %T", x.Stream)) + } +} func (x *testServiceEchoClientClient) Send(m *echo.Request) error { return x.Stream.SendMsg(m) } @@ -220,6 +234,13 @@ type testServiceEchoServerClient struct { streaming.Stream } +func (x *testServiceEchoServerClient) DoFinish(err error) { + if finisher, ok := x.Stream.(streaming.WithDoFinish); ok { + finisher.DoFinish(err) + } else { + panic(fmt.Sprintf("streaming.WithDoFinish is not implemented by %T", x.Stream)) + } +} func (x *testServiceEchoServerClient) Recv() (*echo.Response, error) { m := new(echo.Response) return m, x.Stream.RecvMsg(m)