submitImageInferTask
This commit is contained in:
parent
8518eb54ff
commit
210da65173
|
@ -46,7 +46,6 @@ ParastorQuotaUrl : "/hpc/openapi/v2/parastor/quota/usernames/{username}" #查询
|
|||
# 曙光Ai 相关配置
|
||||
BaseUrlAi : "https://ac.sugon.com"
|
||||
GetImageListAi : "/sothisai/api/tasks/training/images"
|
||||
GetInstanceAi : "/sothisai/api/instance-service"
|
||||
GetTaskAi : "/sothisai/api/{taskGroup}/training/tasks/{taskId}"
|
||||
SubmitTaskAi : "/sothisai/api/{taskGroup}/training/tasks"
|
||||
DeleteTaskAi : "/sothisai/api/tasks"
|
||||
|
@ -62,6 +61,7 @@ GetFile: "/openapi/v2/file/download"
|
|||
UploadFile : "/openapi/v2/file/upload"
|
||||
|
||||
# 容器
|
||||
GetInstanceAi : "/sothisai/api/instance-service"
|
||||
GetNodeResources: "/ai/openapi/v2/instance-service/resources"
|
||||
|
||||
# 用户资源
|
||||
|
|
14
go.mod
14
go.mod
|
@ -17,9 +17,9 @@ require (
|
|||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/zeromicro/go-zero v1.6.2
|
||||
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240301032931-d8d63c116dda
|
||||
golang.org/x/crypto v0.18.0
|
||||
golang.org/x/crypto v0.21.0
|
||||
google.golang.org/grpc v1.61.0
|
||||
google.golang.org/protobuf v1.32.0
|
||||
google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002
|
||||
k8s.io/apimachinery v0.29.1
|
||||
k8s.io/client-go v0.29.1
|
||||
sigs.k8s.io/yaml v1.4.0
|
||||
|
@ -44,7 +44,7 @@ require (
|
|||
github.com/go-sql-driver/mysql v1.7.1 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
|
@ -70,6 +70,7 @@ require (
|
|||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
github.com/redis/go-redis/v9 v9.4.0 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/stretchr/testify v1.9.0 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.12 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.12 // indirect
|
||||
|
@ -87,10 +88,11 @@ require (
|
|||
go.uber.org/automaxprocs v1.5.3 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.26.0 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/net v0.22.0 // indirect
|
||||
golang.org/x/oauth2 v0.15.0 // indirect
|
||||
golang.org/x/sys v0.16.0 // indirect
|
||||
golang.org/x/term v0.16.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/term v0.18.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
|
|
34
go.sum
34
go.sum
|
@ -71,8 +71,8 @@ github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
|||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.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/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 h1:0VpGH+cDhbDtdcweoyCVsF3fhN8kejK6rFe/2FFX2nU=
|
||||
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49/go.mod h1:BkkQ4L1KS1xMt2aWSPStnn55ChGC0DPOn2FQYj+f25M=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
|
@ -182,15 +182,17 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
|||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
|
@ -242,8 +244,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
|||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
|
||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
|
@ -259,8 +261,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
|
|||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
|
||||
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ=
|
||||
golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -269,8 +271,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
|
|||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
|
||||
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -286,15 +288,15 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
|
||||
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
|
||||
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
|
||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
|
@ -332,8 +334,8 @@ google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0=
|
|||
google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
|
||||
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.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
||||
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002 h1:V7Da7qt0MkY3noVANIMVBk28nOnijADeOR3i5Hcvpj4=
|
||||
google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002/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-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
|
1817
hpcAC/hpcAC.pb.go
1817
hpcAC/hpcAC.pb.go
File diff suppressed because it is too large
Load Diff
|
@ -31,6 +31,7 @@ type (
|
|||
DeleteJobResp = hpcAC.DeleteJobResp
|
||||
DeleteTaskAiReq = hpcAC.DeleteTaskAiReq
|
||||
DeleteTaskAiResp = hpcAC.DeleteTaskAiResp
|
||||
FileChunk = hpcAC.FileChunk
|
||||
FileContentResp = hpcAC.FileContentResp
|
||||
FileDataReq = hpcAC.FileDataReq
|
||||
FileDataResp = hpcAC.FileDataResp
|
||||
|
|
|
@ -34,7 +34,6 @@ type CPConf struct {
|
|||
type AiConf struct {
|
||||
BaseUrlAi string
|
||||
GetImageListAi string
|
||||
GetInstanceAi string
|
||||
GetTaskAi string
|
||||
SubmitTaskAi string
|
||||
DeleteTaskAi string
|
||||
|
@ -63,5 +62,6 @@ type UserConf struct {
|
|||
|
||||
// 曙光容器
|
||||
type ContainerConf struct {
|
||||
GetInstanceAi string
|
||||
GetNodeResources string
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ func NewGetInstanceListAiLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
|
||||
func (l *GetInstanceListAiLogic) GetInstanceListAi(in *hpcAC.GetInstanceListReq) (*hpcAC.GetInstanceListResp, error) {
|
||||
resp := &hpcAC.GetInstanceListResp{}
|
||||
var reqUrl = common.AiCenterUrlPrefix() + l.svcCtx.Config.AiConf.GetInstanceAi + "/task"
|
||||
var reqUrl = common.AiCenterUrlPrefix() + l.svcCtx.Config.ContainerConf.GetInstanceAi + "/task"
|
||||
|
||||
token := common.GetToken()
|
||||
if token == "" {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/internal/common"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/internal/svc"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -27,9 +28,14 @@ func NewSubmitImageInferTaskLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
|||
}
|
||||
|
||||
func (l *SubmitImageInferTaskLogic) SubmitImageInferTask(in *hpcAC.SubmitImageInferTaskReq) (*hpcAC.SubmitImageInferTaskResp, error) {
|
||||
type imageInferResult struct {
|
||||
Result string `json:"result"`
|
||||
}
|
||||
|
||||
result := &imageInferResult{}
|
||||
resp := &hpcAC.SubmitImageInferTaskResp{}
|
||||
detailResp := &hpcAC.GetInstanceDetailResp{}
|
||||
var detailUrl = common.AiCenterUrlPrefix() + l.svcCtx.Config.AiConf.GetInstanceAi + "/" + in.Id + "/detail"
|
||||
var detailUrl = common.AiCenterUrlPrefix() + l.svcCtx.Config.ContainerConf.GetInstanceAi + "/" + in.Id + "/detail"
|
||||
token := common.GetToken()
|
||||
if token == "" {
|
||||
log.Println("获取token失败")
|
||||
|
@ -37,24 +43,28 @@ func (l *SubmitImageInferTaskLogic) SubmitImageInferTask(in *hpcAC.SubmitImageIn
|
|||
}
|
||||
//调用详情接口获取accessUrl
|
||||
reqDetail := common.GetRestyRequest(3)
|
||||
_, err := reqDetail.SetHeader("token", token).
|
||||
_, _ = reqDetail.SetHeader("token", token).
|
||||
SetResult(detailResp).
|
||||
Get(detailUrl)
|
||||
|
||||
req := common.GetRestyRequest(3)
|
||||
_, err = req.
|
||||
SetFileReader("file", "train.py", bytes.NewReader([]byte(in.File))).
|
||||
SetFormData(map[string]string{
|
||||
"path": in.Path,
|
||||
"cover": in.Cover,
|
||||
}).
|
||||
SetResult(resp).
|
||||
Post(detailResp.Data.ContainerPortInfoList[0].AccessUrl + "/image")
|
||||
|
||||
// 读取文件数据
|
||||
file, err := os.Open(in.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println("Error opening file:", err)
|
||||
return nil, nil
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
reqInfer := common.GetRestyRequest(3)
|
||||
resultTest, _ := reqInfer.
|
||||
SetHeader("Content-Type", "application/octet-stream").
|
||||
SetFileReader("file", "dog.jpg", file).
|
||||
SetResult(result).
|
||||
Post(detailResp.Data.ContainerPortInfoList[0].AccessUrl + "/image")
|
||||
fmt.Printf("", resultTest)
|
||||
resp.Code = "200"
|
||||
resp.Result = result.Result
|
||||
resp.Message = "success"
|
||||
|
||||
return resp, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -798,9 +798,12 @@ message GetInstanceListParams {
|
|||
|
||||
message SubmitImageInferTaskReq{
|
||||
string id = 1;
|
||||
string path = 2;
|
||||
string cover = 3;
|
||||
string file = 4;
|
||||
FileChunk file = 2;
|
||||
string path =3;
|
||||
}
|
||||
|
||||
message FileChunk {
|
||||
bytes data = 1;
|
||||
}
|
||||
|
||||
message SubmitImageInferTaskResp{
|
||||
|
|
|
@ -56,6 +56,7 @@ type Unmarshaler struct {
|
|||
// implement JSONPBMarshaler so that the custom format can be produced.
|
||||
//
|
||||
// The JSON unmarshaling must follow the JSON to proto specification:
|
||||
//
|
||||
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
||||
//
|
||||
// Deprecated: Custom types should implement protobuf reflection instead.
|
||||
|
|
|
@ -55,6 +55,7 @@ type Marshaler struct {
|
|||
// implement JSONPBUnmarshaler so that the custom format can be parsed.
|
||||
//
|
||||
// The JSON marshaling must follow the proto to JSON specification:
|
||||
//
|
||||
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
||||
//
|
||||
// Deprecated: Custom types should implement protobuf reflection instead.
|
||||
|
|
|
@ -127,9 +127,10 @@ func Is(any *anypb.Any, m proto.Message) bool {
|
|||
// The allocated message is stored in the embedded proto.Message.
|
||||
//
|
||||
// Example:
|
||||
// var x ptypes.DynamicAny
|
||||
// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... }
|
||||
// fmt.Printf("unmarshaled message: %v", x.Message)
|
||||
//
|
||||
// var x ptypes.DynamicAny
|
||||
// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... }
|
||||
// fmt.Printf("unmarshaled message: %v", x.Message)
|
||||
//
|
||||
// Deprecated: Use the any.UnmarshalNew method instead to unmarshal
|
||||
// the any message contents into a new instance of the underlying message.
|
||||
|
|
|
@ -19,15 +19,14 @@
|
|||
|
||||
#define POLY1305_MUL(h0, h1, h2, r0, r1, t0, t1, t2, t3, t4, t5) \
|
||||
MULLD r0, h0, t0; \
|
||||
MULLD r0, h1, t4; \
|
||||
MULHDU r0, h0, t1; \
|
||||
MULLD r0, h1, t4; \
|
||||
MULHDU r0, h1, t5; \
|
||||
ADDC t4, t1, t1; \
|
||||
MULLD r0, h2, t2; \
|
||||
ADDZE t5; \
|
||||
MULHDU r1, h0, t4; \
|
||||
MULLD r1, h0, h0; \
|
||||
ADD t5, t2, t2; \
|
||||
ADDE t5, t2, t2; \
|
||||
ADDC h0, t1, t1; \
|
||||
MULLD h2, r1, t3; \
|
||||
ADDZE t4, h0; \
|
||||
|
@ -37,13 +36,11 @@
|
|||
ADDE t5, t3, t3; \
|
||||
ADDC h0, t2, t2; \
|
||||
MOVD $-4, t4; \
|
||||
MOVD t0, h0; \
|
||||
MOVD t1, h1; \
|
||||
ADDZE t3; \
|
||||
ANDCC $3, t2, h2; \
|
||||
AND t2, t4, t0; \
|
||||
RLDICL $0, t2, $62, h2; \
|
||||
AND t2, t4, h0; \
|
||||
ADDC t0, h0, h0; \
|
||||
ADDE t3, h1, h1; \
|
||||
ADDE t3, t1, h1; \
|
||||
SLD $62, t3, t4; \
|
||||
SRD $2, t2; \
|
||||
ADDZE h2; \
|
||||
|
@ -75,6 +72,7 @@ TEXT ·update(SB), $0-32
|
|||
loop:
|
||||
POLY1305_ADD(R4, R8, R9, R10, R20, R21, R22)
|
||||
|
||||
PCALIGN $16
|
||||
multiply:
|
||||
POLY1305_MUL(R8, R9, R10, R11, R12, R16, R17, R18, R14, R20, R21)
|
||||
ADD $-16, R5
|
||||
|
|
|
@ -910,9 +910,6 @@ func (z *Tokenizer) readTagAttrKey() {
|
|||
return
|
||||
}
|
||||
switch c {
|
||||
case ' ', '\n', '\r', '\t', '\f', '/':
|
||||
z.pendingAttr[0].end = z.raw.end - 1
|
||||
return
|
||||
case '=':
|
||||
if z.pendingAttr[0].start+1 == z.raw.end {
|
||||
// WHATWG 13.2.5.32, if we see an equals sign before the attribute name
|
||||
|
@ -920,7 +917,9 @@ func (z *Tokenizer) readTagAttrKey() {
|
|||
continue
|
||||
}
|
||||
fallthrough
|
||||
case '>':
|
||||
case ' ', '\n', '\r', '\t', '\f', '/', '>':
|
||||
// WHATWG 13.2.5.33 Attribute name state
|
||||
// We need to reconsume the char in the after attribute name state to support the / character
|
||||
z.raw.end--
|
||||
z.pendingAttr[0].end = z.raw.end
|
||||
return
|
||||
|
@ -939,6 +938,11 @@ func (z *Tokenizer) readTagAttrVal() {
|
|||
if z.err != nil {
|
||||
return
|
||||
}
|
||||
if c == '/' {
|
||||
// WHATWG 13.2.5.34 After attribute name state
|
||||
// U+002F SOLIDUS (/) - Switch to the self-closing start tag state.
|
||||
return
|
||||
}
|
||||
if c != '=' {
|
||||
z.raw.end--
|
||||
return
|
||||
|
|
|
@ -1510,13 +1510,12 @@ func (mh *MetaHeadersFrame) checkPseudos() error {
|
|||
}
|
||||
|
||||
func (fr *Framer) maxHeaderStringLen() int {
|
||||
v := fr.maxHeaderListSize()
|
||||
if uint32(int(v)) == v {
|
||||
return int(v)
|
||||
v := int(fr.maxHeaderListSize())
|
||||
if v < 0 {
|
||||
// If maxHeaderListSize overflows an int, use no limit (0).
|
||||
return 0
|
||||
}
|
||||
// They had a crazy big number for MaxHeaderBytes anyway,
|
||||
// so give them unlimited header lengths:
|
||||
return 0
|
||||
return v
|
||||
}
|
||||
|
||||
// readMetaFrame returns 0 or more CONTINUATION frames from fr and
|
||||
|
|
|
@ -2911,6 +2911,15 @@ func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error {
|
|||
fl = &cs.flow
|
||||
}
|
||||
if !fl.add(int32(f.Increment)) {
|
||||
// For stream, the sender sends RST_STREAM with an error code of FLOW_CONTROL_ERROR
|
||||
if cs != nil {
|
||||
rl.endStreamError(cs, StreamError{
|
||||
StreamID: f.StreamID,
|
||||
Code: ErrCodeFlowControl,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
return ConnectionError(ErrCodeFlowControl)
|
||||
}
|
||||
cc.cond.Broadcast()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) && go1.9
|
||||
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
|
||||
|
||||
package unix
|
||||
|
||||
|
|
|
@ -584,7 +584,7 @@ ccflags="$@"
|
|||
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
||||
$2 ~ /^KEYCTL_/ ||
|
||||
$2 ~ /^PERF_/ ||
|
||||
$2 ~ /^SECCOMP_MODE_/ ||
|
||||
$2 ~ /^SECCOMP_/ ||
|
||||
$2 ~ /^SEEK_/ ||
|
||||
$2 ~ /^SCHED_/ ||
|
||||
$2 ~ /^SPLICE_/ ||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin && go1.12
|
||||
//go:build darwin
|
||||
|
||||
package unix
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
package unix
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
"unsafe"
|
||||
)
|
||||
|
@ -169,25 +170,26 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
|||
func Uname(uname *Utsname) error {
|
||||
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
|
||||
n := unsafe.Sizeof(uname.Sysname)
|
||||
if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
|
||||
// Suppress ENOMEM errors to be compatible with the C library __xuname() implementation.
|
||||
if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil && !errors.Is(err, ENOMEM) {
|
||||
return err
|
||||
}
|
||||
|
||||
mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
|
||||
n = unsafe.Sizeof(uname.Nodename)
|
||||
if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
|
||||
if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil && !errors.Is(err, ENOMEM) {
|
||||
return err
|
||||
}
|
||||
|
||||
mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
|
||||
n = unsafe.Sizeof(uname.Release)
|
||||
if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
|
||||
if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil && !errors.Is(err, ENOMEM) {
|
||||
return err
|
||||
}
|
||||
|
||||
mib = []_C_int{CTL_KERN, KERN_VERSION}
|
||||
n = unsafe.Sizeof(uname.Version)
|
||||
if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
|
||||
if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil && !errors.Is(err, ENOMEM) {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -205,7 +207,7 @@ func Uname(uname *Utsname) error {
|
|||
|
||||
mib = []_C_int{CTL_HW, HW_MACHINE}
|
||||
n = unsafe.Sizeof(uname.Machine)
|
||||
if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
|
||||
if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil && !errors.Is(err, ENOMEM) {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -1849,6 +1849,105 @@ func Dup2(oldfd, newfd int) error {
|
|||
//sys Fsmount(fd int, flags int, mountAttrs int) (fsfd int, err error)
|
||||
//sys Fsopen(fsName string, flags int) (fd int, err error)
|
||||
//sys Fspick(dirfd int, pathName string, flags int) (fd int, err error)
|
||||
|
||||
//sys fsconfig(fd int, cmd uint, key *byte, value *byte, aux int) (err error)
|
||||
|
||||
func fsconfigCommon(fd int, cmd uint, key string, value *byte, aux int) (err error) {
|
||||
var keyp *byte
|
||||
if keyp, err = BytePtrFromString(key); err != nil {
|
||||
return
|
||||
}
|
||||
return fsconfig(fd, cmd, keyp, value, aux)
|
||||
}
|
||||
|
||||
// FsconfigSetFlag is equivalent to fsconfig(2) called
|
||||
// with cmd == FSCONFIG_SET_FLAG.
|
||||
//
|
||||
// fd is the filesystem context to act upon.
|
||||
// key the parameter key to set.
|
||||
func FsconfigSetFlag(fd int, key string) (err error) {
|
||||
return fsconfigCommon(fd, FSCONFIG_SET_FLAG, key, nil, 0)
|
||||
}
|
||||
|
||||
// FsconfigSetString is equivalent to fsconfig(2) called
|
||||
// with cmd == FSCONFIG_SET_STRING.
|
||||
//
|
||||
// fd is the filesystem context to act upon.
|
||||
// key the parameter key to set.
|
||||
// value is the parameter value to set.
|
||||
func FsconfigSetString(fd int, key string, value string) (err error) {
|
||||
var valuep *byte
|
||||
if valuep, err = BytePtrFromString(value); err != nil {
|
||||
return
|
||||
}
|
||||
return fsconfigCommon(fd, FSCONFIG_SET_STRING, key, valuep, 0)
|
||||
}
|
||||
|
||||
// FsconfigSetBinary is equivalent to fsconfig(2) called
|
||||
// with cmd == FSCONFIG_SET_BINARY.
|
||||
//
|
||||
// fd is the filesystem context to act upon.
|
||||
// key the parameter key to set.
|
||||
// value is the parameter value to set.
|
||||
func FsconfigSetBinary(fd int, key string, value []byte) (err error) {
|
||||
if len(value) == 0 {
|
||||
return EINVAL
|
||||
}
|
||||
return fsconfigCommon(fd, FSCONFIG_SET_BINARY, key, &value[0], len(value))
|
||||
}
|
||||
|
||||
// FsconfigSetPath is equivalent to fsconfig(2) called
|
||||
// with cmd == FSCONFIG_SET_PATH.
|
||||
//
|
||||
// fd is the filesystem context to act upon.
|
||||
// key the parameter key to set.
|
||||
// path is a non-empty path for specified key.
|
||||
// atfd is a file descriptor at which to start lookup from or AT_FDCWD.
|
||||
func FsconfigSetPath(fd int, key string, path string, atfd int) (err error) {
|
||||
var valuep *byte
|
||||
if valuep, err = BytePtrFromString(path); err != nil {
|
||||
return
|
||||
}
|
||||
return fsconfigCommon(fd, FSCONFIG_SET_PATH, key, valuep, atfd)
|
||||
}
|
||||
|
||||
// FsconfigSetPathEmpty is equivalent to fsconfig(2) called
|
||||
// with cmd == FSCONFIG_SET_PATH_EMPTY. The same as
|
||||
// FconfigSetPath but with AT_PATH_EMPTY implied.
|
||||
func FsconfigSetPathEmpty(fd int, key string, path string, atfd int) (err error) {
|
||||
var valuep *byte
|
||||
if valuep, err = BytePtrFromString(path); err != nil {
|
||||
return
|
||||
}
|
||||
return fsconfigCommon(fd, FSCONFIG_SET_PATH_EMPTY, key, valuep, atfd)
|
||||
}
|
||||
|
||||
// FsconfigSetFd is equivalent to fsconfig(2) called
|
||||
// with cmd == FSCONFIG_SET_FD.
|
||||
//
|
||||
// fd is the filesystem context to act upon.
|
||||
// key the parameter key to set.
|
||||
// value is a file descriptor to be assigned to specified key.
|
||||
func FsconfigSetFd(fd int, key string, value int) (err error) {
|
||||
return fsconfigCommon(fd, FSCONFIG_SET_FD, key, nil, value)
|
||||
}
|
||||
|
||||
// FsconfigCreate is equivalent to fsconfig(2) called
|
||||
// with cmd == FSCONFIG_CMD_CREATE.
|
||||
//
|
||||
// fd is the filesystem context to act upon.
|
||||
func FsconfigCreate(fd int) (err error) {
|
||||
return fsconfig(fd, FSCONFIG_CMD_CREATE, nil, nil, 0)
|
||||
}
|
||||
|
||||
// FsconfigReconfigure is equivalent to fsconfig(2) called
|
||||
// with cmd == FSCONFIG_CMD_RECONFIGURE.
|
||||
//
|
||||
// fd is the filesystem context to act upon.
|
||||
func FsconfigReconfigure(fd int) (err error) {
|
||||
return fsconfig(fd, FSCONFIG_CMD_RECONFIGURE, nil, nil, 0)
|
||||
}
|
||||
|
||||
//sys Getdents(fd int, buf []byte) (n int, err error) = SYS_GETDENTS64
|
||||
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||
|
||||
|
|
|
@ -1785,6 +1785,8 @@ const (
|
|||
LANDLOCK_ACCESS_FS_REMOVE_FILE = 0x20
|
||||
LANDLOCK_ACCESS_FS_TRUNCATE = 0x4000
|
||||
LANDLOCK_ACCESS_FS_WRITE_FILE = 0x2
|
||||
LANDLOCK_ACCESS_NET_BIND_TCP = 0x1
|
||||
LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2
|
||||
LANDLOCK_CREATE_RULESET_VERSION = 0x1
|
||||
LINUX_REBOOT_CMD_CAD_OFF = 0x0
|
||||
LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
|
||||
|
@ -2465,6 +2467,7 @@ const (
|
|||
PR_MCE_KILL_GET = 0x22
|
||||
PR_MCE_KILL_LATE = 0x0
|
||||
PR_MCE_KILL_SET = 0x1
|
||||
PR_MDWE_NO_INHERIT = 0x2
|
||||
PR_MDWE_REFUSE_EXEC_GAIN = 0x1
|
||||
PR_MPX_DISABLE_MANAGEMENT = 0x2c
|
||||
PR_MPX_ENABLE_MANAGEMENT = 0x2b
|
||||
|
@ -2669,8 +2672,9 @@ const (
|
|||
RTAX_FEATURES = 0xc
|
||||
RTAX_FEATURE_ALLFRAG = 0x8
|
||||
RTAX_FEATURE_ECN = 0x1
|
||||
RTAX_FEATURE_MASK = 0xf
|
||||
RTAX_FEATURE_MASK = 0x1f
|
||||
RTAX_FEATURE_SACK = 0x2
|
||||
RTAX_FEATURE_TCP_USEC_TS = 0x10
|
||||
RTAX_FEATURE_TIMESTAMP = 0x4
|
||||
RTAX_HOPLIMIT = 0xa
|
||||
RTAX_INITCWND = 0xb
|
||||
|
@ -2913,9 +2917,38 @@ const (
|
|||
SCM_RIGHTS = 0x1
|
||||
SCM_TIMESTAMP = 0x1d
|
||||
SC_LOG_FLUSH = 0x100000
|
||||
SECCOMP_ADDFD_FLAG_SEND = 0x2
|
||||
SECCOMP_ADDFD_FLAG_SETFD = 0x1
|
||||
SECCOMP_FILTER_FLAG_LOG = 0x2
|
||||
SECCOMP_FILTER_FLAG_NEW_LISTENER = 0x8
|
||||
SECCOMP_FILTER_FLAG_SPEC_ALLOW = 0x4
|
||||
SECCOMP_FILTER_FLAG_TSYNC = 0x1
|
||||
SECCOMP_FILTER_FLAG_TSYNC_ESRCH = 0x10
|
||||
SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV = 0x20
|
||||
SECCOMP_GET_ACTION_AVAIL = 0x2
|
||||
SECCOMP_GET_NOTIF_SIZES = 0x3
|
||||
SECCOMP_IOCTL_NOTIF_RECV = 0xc0502100
|
||||
SECCOMP_IOCTL_NOTIF_SEND = 0xc0182101
|
||||
SECCOMP_IOC_MAGIC = '!'
|
||||
SECCOMP_MODE_DISABLED = 0x0
|
||||
SECCOMP_MODE_FILTER = 0x2
|
||||
SECCOMP_MODE_STRICT = 0x1
|
||||
SECCOMP_RET_ACTION = 0x7fff0000
|
||||
SECCOMP_RET_ACTION_FULL = 0xffff0000
|
||||
SECCOMP_RET_ALLOW = 0x7fff0000
|
||||
SECCOMP_RET_DATA = 0xffff
|
||||
SECCOMP_RET_ERRNO = 0x50000
|
||||
SECCOMP_RET_KILL = 0x0
|
||||
SECCOMP_RET_KILL_PROCESS = 0x80000000
|
||||
SECCOMP_RET_KILL_THREAD = 0x0
|
||||
SECCOMP_RET_LOG = 0x7ffc0000
|
||||
SECCOMP_RET_TRACE = 0x7ff00000
|
||||
SECCOMP_RET_TRAP = 0x30000
|
||||
SECCOMP_RET_USER_NOTIF = 0x7fc00000
|
||||
SECCOMP_SET_MODE_FILTER = 0x1
|
||||
SECCOMP_SET_MODE_STRICT = 0x0
|
||||
SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP = 0x1
|
||||
SECCOMP_USER_NOTIF_FLAG_CONTINUE = 0x1
|
||||
SECRETMEM_MAGIC = 0x5345434d
|
||||
SECURITYFS_MAGIC = 0x73636673
|
||||
SEEK_CUR = 0x1
|
||||
|
@ -3075,6 +3108,7 @@ const (
|
|||
SOL_TIPC = 0x10f
|
||||
SOL_TLS = 0x11a
|
||||
SOL_UDP = 0x11
|
||||
SOL_VSOCK = 0x11f
|
||||
SOL_X25 = 0x106
|
||||
SOL_XDP = 0x11b
|
||||
SOMAXCONN = 0x1000
|
||||
|
|
|
@ -281,6 +281,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x40082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x40082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x800
|
||||
SIOCATMARK = 0x8905
|
||||
|
|
|
@ -282,6 +282,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x40082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x40082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x800
|
||||
SIOCATMARK = 0x8905
|
||||
|
|
|
@ -288,6 +288,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x40082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x40082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x800
|
||||
SIOCATMARK = 0x8905
|
||||
|
|
|
@ -278,6 +278,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x40082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x40082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x800
|
||||
SIOCATMARK = 0x8905
|
||||
|
|
|
@ -275,6 +275,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x40082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x40082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x800
|
||||
SIOCATMARK = 0x8905
|
||||
|
|
|
@ -281,6 +281,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x80082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x80082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x80
|
||||
SIOCATMARK = 0x40047307
|
||||
|
|
|
@ -281,6 +281,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x80082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x80082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x80
|
||||
SIOCATMARK = 0x40047307
|
||||
|
|
|
@ -281,6 +281,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x80082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x80082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x80
|
||||
SIOCATMARK = 0x40047307
|
||||
|
|
|
@ -281,6 +281,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x80082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x80082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x80
|
||||
SIOCATMARK = 0x40047307
|
||||
|
|
|
@ -336,6 +336,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x80082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x80082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x800
|
||||
SIOCATMARK = 0x8905
|
||||
|
|
|
@ -340,6 +340,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x80082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x80082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x800
|
||||
SIOCATMARK = 0x8905
|
||||
|
|
|
@ -340,6 +340,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x80082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x80082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x800
|
||||
SIOCATMARK = 0x8905
|
||||
|
|
|
@ -272,6 +272,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x40082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x40082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x800
|
||||
SIOCATMARK = 0x8905
|
||||
|
|
|
@ -344,6 +344,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x40082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x40082104
|
||||
SFD_CLOEXEC = 0x80000
|
||||
SFD_NONBLOCK = 0x800
|
||||
SIOCATMARK = 0x8905
|
||||
|
|
|
@ -335,6 +335,9 @@ const (
|
|||
SCM_TIMESTAMPNS = 0x21
|
||||
SCM_TXTIME = 0x3f
|
||||
SCM_WIFI_STATUS = 0x25
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
SECCOMP_IOCTL_NOTIF_ID_VALID = 0x80082102
|
||||
SECCOMP_IOCTL_NOTIF_SET_FLAGS = 0x80082104
|
||||
SFD_CLOEXEC = 0x400000
|
||||
SFD_NONBLOCK = 0x4000
|
||||
SF_FP = 0x38
|
||||
|
|
|
@ -906,6 +906,16 @@ func Fspick(dirfd int, pathName string, flags int) (fd int, err error) {
|
|||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func fsconfig(fd int, cmd uint, key *byte, value *byte, aux int) (err error) {
|
||||
_, _, e1 := Syscall6(SYS_FSCONFIG, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(value)), uintptr(aux), 0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Getdents(fd int, buf []byte) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(buf) > 0 {
|
||||
|
|
|
@ -448,4 +448,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
||||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -371,4 +371,7 @@ const (
|
|||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -412,4 +412,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
||||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -315,4 +315,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
||||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -309,4 +309,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
||||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -432,4 +432,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 4450
|
||||
SYS_CACHESTAT = 4451
|
||||
SYS_FCHMODAT2 = 4452
|
||||
SYS_MAP_SHADOW_STACK = 4453
|
||||
SYS_FUTEX_WAKE = 4454
|
||||
SYS_FUTEX_WAIT = 4455
|
||||
SYS_FUTEX_REQUEUE = 4456
|
||||
)
|
||||
|
|
|
@ -362,4 +362,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 5450
|
||||
SYS_CACHESTAT = 5451
|
||||
SYS_FCHMODAT2 = 5452
|
||||
SYS_MAP_SHADOW_STACK = 5453
|
||||
SYS_FUTEX_WAKE = 5454
|
||||
SYS_FUTEX_WAIT = 5455
|
||||
SYS_FUTEX_REQUEUE = 5456
|
||||
)
|
||||
|
|
|
@ -362,4 +362,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 5450
|
||||
SYS_CACHESTAT = 5451
|
||||
SYS_FCHMODAT2 = 5452
|
||||
SYS_MAP_SHADOW_STACK = 5453
|
||||
SYS_FUTEX_WAKE = 5454
|
||||
SYS_FUTEX_WAIT = 5455
|
||||
SYS_FUTEX_REQUEUE = 5456
|
||||
)
|
||||
|
|
|
@ -432,4 +432,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 4450
|
||||
SYS_CACHESTAT = 4451
|
||||
SYS_FCHMODAT2 = 4452
|
||||
SYS_MAP_SHADOW_STACK = 4453
|
||||
SYS_FUTEX_WAKE = 4454
|
||||
SYS_FUTEX_WAIT = 4455
|
||||
SYS_FUTEX_REQUEUE = 4456
|
||||
)
|
||||
|
|
|
@ -439,4 +439,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
||||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -411,4 +411,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
||||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -411,4 +411,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
||||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -316,4 +316,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
||||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -377,4 +377,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
||||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -390,4 +390,8 @@ const (
|
|||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
||||
SYS_CACHESTAT = 451
|
||||
SYS_FCHMODAT2 = 452
|
||||
SYS_MAP_SHADOW_STACK = 453
|
||||
SYS_FUTEX_WAKE = 454
|
||||
SYS_FUTEX_WAIT = 455
|
||||
SYS_FUTEX_REQUEUE = 456
|
||||
)
|
||||
|
|
|
@ -174,7 +174,8 @@ type FscryptPolicyV2 struct {
|
|||
Contents_encryption_mode uint8
|
||||
Filenames_encryption_mode uint8
|
||||
Flags uint8
|
||||
_ [4]uint8
|
||||
Log2_data_unit_size uint8
|
||||
_ [3]uint8
|
||||
Master_key_identifier [16]uint8
|
||||
}
|
||||
|
||||
|
@ -455,60 +456,63 @@ type Ucred struct {
|
|||
}
|
||||
|
||||
type TCPInfo struct {
|
||||
State uint8
|
||||
Ca_state uint8
|
||||
Retransmits uint8
|
||||
Probes uint8
|
||||
Backoff uint8
|
||||
Options uint8
|
||||
Rto uint32
|
||||
Ato uint32
|
||||
Snd_mss uint32
|
||||
Rcv_mss uint32
|
||||
Unacked uint32
|
||||
Sacked uint32
|
||||
Lost uint32
|
||||
Retrans uint32
|
||||
Fackets uint32
|
||||
Last_data_sent uint32
|
||||
Last_ack_sent uint32
|
||||
Last_data_recv uint32
|
||||
Last_ack_recv uint32
|
||||
Pmtu uint32
|
||||
Rcv_ssthresh uint32
|
||||
Rtt uint32
|
||||
Rttvar uint32
|
||||
Snd_ssthresh uint32
|
||||
Snd_cwnd uint32
|
||||
Advmss uint32
|
||||
Reordering uint32
|
||||
Rcv_rtt uint32
|
||||
Rcv_space uint32
|
||||
Total_retrans uint32
|
||||
Pacing_rate uint64
|
||||
Max_pacing_rate uint64
|
||||
Bytes_acked uint64
|
||||
Bytes_received uint64
|
||||
Segs_out uint32
|
||||
Segs_in uint32
|
||||
Notsent_bytes uint32
|
||||
Min_rtt uint32
|
||||
Data_segs_in uint32
|
||||
Data_segs_out uint32
|
||||
Delivery_rate uint64
|
||||
Busy_time uint64
|
||||
Rwnd_limited uint64
|
||||
Sndbuf_limited uint64
|
||||
Delivered uint32
|
||||
Delivered_ce uint32
|
||||
Bytes_sent uint64
|
||||
Bytes_retrans uint64
|
||||
Dsack_dups uint32
|
||||
Reord_seen uint32
|
||||
Rcv_ooopack uint32
|
||||
Snd_wnd uint32
|
||||
Rcv_wnd uint32
|
||||
Rehash uint32
|
||||
State uint8
|
||||
Ca_state uint8
|
||||
Retransmits uint8
|
||||
Probes uint8
|
||||
Backoff uint8
|
||||
Options uint8
|
||||
Rto uint32
|
||||
Ato uint32
|
||||
Snd_mss uint32
|
||||
Rcv_mss uint32
|
||||
Unacked uint32
|
||||
Sacked uint32
|
||||
Lost uint32
|
||||
Retrans uint32
|
||||
Fackets uint32
|
||||
Last_data_sent uint32
|
||||
Last_ack_sent uint32
|
||||
Last_data_recv uint32
|
||||
Last_ack_recv uint32
|
||||
Pmtu uint32
|
||||
Rcv_ssthresh uint32
|
||||
Rtt uint32
|
||||
Rttvar uint32
|
||||
Snd_ssthresh uint32
|
||||
Snd_cwnd uint32
|
||||
Advmss uint32
|
||||
Reordering uint32
|
||||
Rcv_rtt uint32
|
||||
Rcv_space uint32
|
||||
Total_retrans uint32
|
||||
Pacing_rate uint64
|
||||
Max_pacing_rate uint64
|
||||
Bytes_acked uint64
|
||||
Bytes_received uint64
|
||||
Segs_out uint32
|
||||
Segs_in uint32
|
||||
Notsent_bytes uint32
|
||||
Min_rtt uint32
|
||||
Data_segs_in uint32
|
||||
Data_segs_out uint32
|
||||
Delivery_rate uint64
|
||||
Busy_time uint64
|
||||
Rwnd_limited uint64
|
||||
Sndbuf_limited uint64
|
||||
Delivered uint32
|
||||
Delivered_ce uint32
|
||||
Bytes_sent uint64
|
||||
Bytes_retrans uint64
|
||||
Dsack_dups uint32
|
||||
Reord_seen uint32
|
||||
Rcv_ooopack uint32
|
||||
Snd_wnd uint32
|
||||
Rcv_wnd uint32
|
||||
Rehash uint32
|
||||
Total_rto uint16
|
||||
Total_rto_recoveries uint16
|
||||
Total_rto_time uint32
|
||||
}
|
||||
|
||||
type CanFilter struct {
|
||||
|
@ -551,7 +555,7 @@ const (
|
|||
SizeofIPv6MTUInfo = 0x20
|
||||
SizeofICMPv6Filter = 0x20
|
||||
SizeofUcred = 0xc
|
||||
SizeofTCPInfo = 0xf0
|
||||
SizeofTCPInfo = 0xf8
|
||||
SizeofCanFilter = 0x8
|
||||
SizeofTCPRepairOpt = 0x8
|
||||
)
|
||||
|
@ -832,6 +836,15 @@ const (
|
|||
FSPICK_EMPTY_PATH = 0x8
|
||||
|
||||
FSMOUNT_CLOEXEC = 0x1
|
||||
|
||||
FSCONFIG_SET_FLAG = 0x0
|
||||
FSCONFIG_SET_STRING = 0x1
|
||||
FSCONFIG_SET_BINARY = 0x2
|
||||
FSCONFIG_SET_PATH = 0x3
|
||||
FSCONFIG_SET_PATH_EMPTY = 0x4
|
||||
FSCONFIG_SET_FD = 0x5
|
||||
FSCONFIG_CMD_CREATE = 0x6
|
||||
FSCONFIG_CMD_RECONFIGURE = 0x7
|
||||
)
|
||||
|
||||
type OpenHow struct {
|
||||
|
@ -1546,6 +1559,7 @@ const (
|
|||
IFLA_DEVLINK_PORT = 0x3e
|
||||
IFLA_GSO_IPV4_MAX_SIZE = 0x3f
|
||||
IFLA_GRO_IPV4_MAX_SIZE = 0x40
|
||||
IFLA_DPLL_PIN = 0x41
|
||||
IFLA_PROTO_DOWN_REASON_UNSPEC = 0x0
|
||||
IFLA_PROTO_DOWN_REASON_MASK = 0x1
|
||||
IFLA_PROTO_DOWN_REASON_VALUE = 0x2
|
||||
|
@ -1561,6 +1575,7 @@ const (
|
|||
IFLA_INET6_ICMP6STATS = 0x6
|
||||
IFLA_INET6_TOKEN = 0x7
|
||||
IFLA_INET6_ADDR_GEN_MODE = 0x8
|
||||
IFLA_INET6_RA_MTU = 0x9
|
||||
IFLA_BR_UNSPEC = 0x0
|
||||
IFLA_BR_FORWARD_DELAY = 0x1
|
||||
IFLA_BR_HELLO_TIME = 0x2
|
||||
|
@ -1608,6 +1623,9 @@ const (
|
|||
IFLA_BR_MCAST_MLD_VERSION = 0x2c
|
||||
IFLA_BR_VLAN_STATS_PER_PORT = 0x2d
|
||||
IFLA_BR_MULTI_BOOLOPT = 0x2e
|
||||
IFLA_BR_MCAST_QUERIER_STATE = 0x2f
|
||||
IFLA_BR_FDB_N_LEARNED = 0x30
|
||||
IFLA_BR_FDB_MAX_LEARNED = 0x31
|
||||
IFLA_BRPORT_UNSPEC = 0x0
|
||||
IFLA_BRPORT_STATE = 0x1
|
||||
IFLA_BRPORT_PRIORITY = 0x2
|
||||
|
@ -1645,6 +1663,14 @@ const (
|
|||
IFLA_BRPORT_BACKUP_PORT = 0x22
|
||||
IFLA_BRPORT_MRP_RING_OPEN = 0x23
|
||||
IFLA_BRPORT_MRP_IN_OPEN = 0x24
|
||||
IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT = 0x25
|
||||
IFLA_BRPORT_MCAST_EHT_HOSTS_CNT = 0x26
|
||||
IFLA_BRPORT_LOCKED = 0x27
|
||||
IFLA_BRPORT_MAB = 0x28
|
||||
IFLA_BRPORT_MCAST_N_GROUPS = 0x29
|
||||
IFLA_BRPORT_MCAST_MAX_GROUPS = 0x2a
|
||||
IFLA_BRPORT_NEIGH_VLAN_SUPPRESS = 0x2b
|
||||
IFLA_BRPORT_BACKUP_NHID = 0x2c
|
||||
IFLA_INFO_UNSPEC = 0x0
|
||||
IFLA_INFO_KIND = 0x1
|
||||
IFLA_INFO_DATA = 0x2
|
||||
|
@ -1666,6 +1692,9 @@ const (
|
|||
IFLA_MACVLAN_MACADDR = 0x4
|
||||
IFLA_MACVLAN_MACADDR_DATA = 0x5
|
||||
IFLA_MACVLAN_MACADDR_COUNT = 0x6
|
||||
IFLA_MACVLAN_BC_QUEUE_LEN = 0x7
|
||||
IFLA_MACVLAN_BC_QUEUE_LEN_USED = 0x8
|
||||
IFLA_MACVLAN_BC_CUTOFF = 0x9
|
||||
IFLA_VRF_UNSPEC = 0x0
|
||||
IFLA_VRF_TABLE = 0x1
|
||||
IFLA_VRF_PORT_UNSPEC = 0x0
|
||||
|
@ -1689,9 +1718,22 @@ const (
|
|||
IFLA_XFRM_UNSPEC = 0x0
|
||||
IFLA_XFRM_LINK = 0x1
|
||||
IFLA_XFRM_IF_ID = 0x2
|
||||
IFLA_XFRM_COLLECT_METADATA = 0x3
|
||||
IFLA_IPVLAN_UNSPEC = 0x0
|
||||
IFLA_IPVLAN_MODE = 0x1
|
||||
IFLA_IPVLAN_FLAGS = 0x2
|
||||
NETKIT_NEXT = -0x1
|
||||
NETKIT_PASS = 0x0
|
||||
NETKIT_DROP = 0x2
|
||||
NETKIT_REDIRECT = 0x7
|
||||
NETKIT_L2 = 0x0
|
||||
NETKIT_L3 = 0x1
|
||||
IFLA_NETKIT_UNSPEC = 0x0
|
||||
IFLA_NETKIT_PEER_INFO = 0x1
|
||||
IFLA_NETKIT_PRIMARY = 0x2
|
||||
IFLA_NETKIT_POLICY = 0x3
|
||||
IFLA_NETKIT_PEER_POLICY = 0x4
|
||||
IFLA_NETKIT_MODE = 0x5
|
||||
IFLA_VXLAN_UNSPEC = 0x0
|
||||
IFLA_VXLAN_ID = 0x1
|
||||
IFLA_VXLAN_GROUP = 0x2
|
||||
|
@ -1722,6 +1764,8 @@ const (
|
|||
IFLA_VXLAN_GPE = 0x1b
|
||||
IFLA_VXLAN_TTL_INHERIT = 0x1c
|
||||
IFLA_VXLAN_DF = 0x1d
|
||||
IFLA_VXLAN_VNIFILTER = 0x1e
|
||||
IFLA_VXLAN_LOCALBYPASS = 0x1f
|
||||
IFLA_GENEVE_UNSPEC = 0x0
|
||||
IFLA_GENEVE_ID = 0x1
|
||||
IFLA_GENEVE_REMOTE = 0x2
|
||||
|
@ -1736,6 +1780,7 @@ const (
|
|||
IFLA_GENEVE_LABEL = 0xb
|
||||
IFLA_GENEVE_TTL_INHERIT = 0xc
|
||||
IFLA_GENEVE_DF = 0xd
|
||||
IFLA_GENEVE_INNER_PROTO_INHERIT = 0xe
|
||||
IFLA_BAREUDP_UNSPEC = 0x0
|
||||
IFLA_BAREUDP_PORT = 0x1
|
||||
IFLA_BAREUDP_ETHERTYPE = 0x2
|
||||
|
@ -1748,6 +1793,8 @@ const (
|
|||
IFLA_GTP_FD1 = 0x2
|
||||
IFLA_GTP_PDP_HASHSIZE = 0x3
|
||||
IFLA_GTP_ROLE = 0x4
|
||||
IFLA_GTP_CREATE_SOCKETS = 0x5
|
||||
IFLA_GTP_RESTART_COUNT = 0x6
|
||||
IFLA_BOND_UNSPEC = 0x0
|
||||
IFLA_BOND_MODE = 0x1
|
||||
IFLA_BOND_ACTIVE_SLAVE = 0x2
|
||||
|
@ -1777,6 +1824,9 @@ const (
|
|||
IFLA_BOND_AD_ACTOR_SYSTEM = 0x1a
|
||||
IFLA_BOND_TLB_DYNAMIC_LB = 0x1b
|
||||
IFLA_BOND_PEER_NOTIF_DELAY = 0x1c
|
||||
IFLA_BOND_AD_LACP_ACTIVE = 0x1d
|
||||
IFLA_BOND_MISSED_MAX = 0x1e
|
||||
IFLA_BOND_NS_IP6_TARGET = 0x1f
|
||||
IFLA_BOND_AD_INFO_UNSPEC = 0x0
|
||||
IFLA_BOND_AD_INFO_AGGREGATOR = 0x1
|
||||
IFLA_BOND_AD_INFO_NUM_PORTS = 0x2
|
||||
|
@ -1792,6 +1842,7 @@ const (
|
|||
IFLA_BOND_SLAVE_AD_AGGREGATOR_ID = 0x6
|
||||
IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE = 0x7
|
||||
IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE = 0x8
|
||||
IFLA_BOND_SLAVE_PRIO = 0x9
|
||||
IFLA_VF_INFO_UNSPEC = 0x0
|
||||
IFLA_VF_INFO = 0x1
|
||||
IFLA_VF_UNSPEC = 0x0
|
||||
|
@ -1850,8 +1901,16 @@ const (
|
|||
IFLA_STATS_LINK_XSTATS_SLAVE = 0x3
|
||||
IFLA_STATS_LINK_OFFLOAD_XSTATS = 0x4
|
||||
IFLA_STATS_AF_SPEC = 0x5
|
||||
IFLA_STATS_GETSET_UNSPEC = 0x0
|
||||
IFLA_STATS_GET_FILTERS = 0x1
|
||||
IFLA_STATS_SET_OFFLOAD_XSTATS_L3_STATS = 0x2
|
||||
IFLA_OFFLOAD_XSTATS_UNSPEC = 0x0
|
||||
IFLA_OFFLOAD_XSTATS_CPU_HIT = 0x1
|
||||
IFLA_OFFLOAD_XSTATS_HW_S_INFO = 0x2
|
||||
IFLA_OFFLOAD_XSTATS_L3_STATS = 0x3
|
||||
IFLA_OFFLOAD_XSTATS_HW_S_INFO_UNSPEC = 0x0
|
||||
IFLA_OFFLOAD_XSTATS_HW_S_INFO_REQUEST = 0x1
|
||||
IFLA_OFFLOAD_XSTATS_HW_S_INFO_USED = 0x2
|
||||
IFLA_XDP_UNSPEC = 0x0
|
||||
IFLA_XDP_FD = 0x1
|
||||
IFLA_XDP_ATTACHED = 0x2
|
||||
|
@ -1881,6 +1940,11 @@ const (
|
|||
IFLA_RMNET_UNSPEC = 0x0
|
||||
IFLA_RMNET_MUX_ID = 0x1
|
||||
IFLA_RMNET_FLAGS = 0x2
|
||||
IFLA_MCTP_UNSPEC = 0x0
|
||||
IFLA_MCTP_NET = 0x1
|
||||
IFLA_DSA_UNSPEC = 0x0
|
||||
IFLA_DSA_CONDUIT = 0x1
|
||||
IFLA_DSA_MASTER = 0x1
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -3399,7 +3463,7 @@ const (
|
|||
DEVLINK_PORT_FN_ATTR_STATE = 0x2
|
||||
DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3
|
||||
DEVLINK_PORT_FN_ATTR_CAPS = 0x4
|
||||
DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x4
|
||||
DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5
|
||||
)
|
||||
|
||||
type FsverityDigest struct {
|
||||
|
@ -4183,7 +4247,8 @@ const (
|
|||
)
|
||||
|
||||
type LandlockRulesetAttr struct {
|
||||
Access_fs uint64
|
||||
Access_fs uint64
|
||||
Access_net uint64
|
||||
}
|
||||
|
||||
type LandlockPathBeneathAttr struct {
|
||||
|
@ -5134,7 +5199,7 @@ const (
|
|||
NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf
|
||||
NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe
|
||||
NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf
|
||||
NL80211_FREQUENCY_ATTR_MAX = 0x1b
|
||||
NL80211_FREQUENCY_ATTR_MAX = 0x1c
|
||||
NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6
|
||||
NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11
|
||||
NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc
|
||||
|
@ -5547,7 +5612,7 @@ const (
|
|||
NL80211_REGDOM_TYPE_CUSTOM_WORLD = 0x2
|
||||
NL80211_REGDOM_TYPE_INTERSECTION = 0x3
|
||||
NL80211_REGDOM_TYPE_WORLD = 0x1
|
||||
NL80211_REG_RULE_ATTR_MAX = 0x7
|
||||
NL80211_REG_RULE_ATTR_MAX = 0x8
|
||||
NL80211_REKEY_DATA_AKM = 0x4
|
||||
NL80211_REKEY_DATA_KCK = 0x2
|
||||
NL80211_REKEY_DATA_KEK = 0x1
|
||||
|
|
|
@ -37,14 +37,17 @@ func (token Token) Environ(inheritExisting bool) (env []string, err error) {
|
|||
return nil, err
|
||||
}
|
||||
defer DestroyEnvironmentBlock(block)
|
||||
blockp := unsafe.Pointer(block)
|
||||
for {
|
||||
entry := UTF16PtrToString((*uint16)(blockp))
|
||||
if len(entry) == 0 {
|
||||
break
|
||||
size := unsafe.Sizeof(*block)
|
||||
for *block != 0 {
|
||||
// find NUL terminator
|
||||
end := unsafe.Pointer(block)
|
||||
for *(*uint16)(end) != 0 {
|
||||
end = unsafe.Add(end, size)
|
||||
}
|
||||
env = append(env, entry)
|
||||
blockp = unsafe.Add(blockp, 2*(len(entry)+1))
|
||||
|
||||
entry := unsafe.Slice(block, (uintptr(end)-uintptr(unsafe.Pointer(block)))/size)
|
||||
env = append(env, UTF16ToString(entry))
|
||||
block = (*uint16)(unsafe.Add(end, size))
|
||||
}
|
||||
return env, nil
|
||||
}
|
||||
|
|
|
@ -125,8 +125,7 @@ func UTF16PtrToString(p *uint16) string {
|
|||
for ptr := unsafe.Pointer(p); *(*uint16)(ptr) != 0; n++ {
|
||||
ptr = unsafe.Pointer(uintptr(ptr) + unsafe.Sizeof(*p))
|
||||
}
|
||||
|
||||
return string(utf16.Decode(unsafe.Slice(p, n)))
|
||||
return UTF16ToString(unsafe.Slice(p, n))
|
||||
}
|
||||
|
||||
func Getpagesize() int { return 4096 }
|
||||
|
|
|
@ -322,6 +322,10 @@ func (d decoder) skipJSONValue() error {
|
|||
if open > d.opts.RecursionLimit {
|
||||
return errors.New("exceeded max recursion depth")
|
||||
}
|
||||
case json.EOF:
|
||||
// This can only happen if there's a bug in Decoder.Read.
|
||||
// Avoid an infinite loop if this does happen.
|
||||
return errors.New("unexpected EOF")
|
||||
}
|
||||
if open == 0 {
|
||||
return nil
|
||||
|
|
|
@ -252,6 +252,7 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu
|
|||
{rv.MethodByName("Values"), "Values"},
|
||||
{rv.MethodByName("ReservedNames"), "ReservedNames"},
|
||||
{rv.MethodByName("ReservedRanges"), "ReservedRanges"},
|
||||
{rv.MethodByName("IsClosed"), "IsClosed"},
|
||||
}...)
|
||||
|
||||
case protoreflect.EnumValueDescriptor:
|
||||
|
|
12
vendor/google.golang.org/protobuf/internal/editiondefaults/defaults.go
generated
vendored
Normal file
12
vendor/google.golang.org/protobuf/internal/editiondefaults/defaults.go
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package editiondefaults contains the binary representation of the editions
|
||||
// defaults.
|
||||
package editiondefaults
|
||||
|
||||
import _ "embed"
|
||||
|
||||
//go:embed editions_defaults.binpb
|
||||
var Defaults []byte
|
BIN
vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb
generated
vendored
Normal file
BIN
vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb
generated
vendored
Normal file
Binary file not shown.
13
vendor/google.golang.org/protobuf/internal/editionssupport/editions.go
generated
vendored
Normal file
13
vendor/google.golang.org/protobuf/internal/editionssupport/editions.go
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package editionssupport defines constants for editions that are supported.
|
||||
package editionssupport
|
||||
|
||||
import descriptorpb "google.golang.org/protobuf/types/descriptorpb"
|
||||
|
||||
const (
|
||||
Minimum = descriptorpb.Edition_EDITION_PROTO2
|
||||
Maximum = descriptorpb.Edition_EDITION_2023
|
||||
)
|
|
@ -121,7 +121,7 @@ func (d *Decoder) Read() (Token, error) {
|
|||
|
||||
case ObjectClose:
|
||||
if len(d.openStack) == 0 ||
|
||||
d.lastToken.kind == comma ||
|
||||
d.lastToken.kind&(Name|comma) != 0 ||
|
||||
d.openStack[len(d.openStack)-1] != ObjectOpen {
|
||||
return Token{}, d.newSyntaxError(tok.pos, unexpectedFmt, tok.RawString())
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ var byteType = reflect.TypeOf(byte(0))
|
|||
func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescriptors) protoreflect.FieldDescriptor {
|
||||
f := new(filedesc.Field)
|
||||
f.L0.ParentFile = filedesc.SurrogateProto2
|
||||
f.L1.EditionFeatures = f.L0.ParentFile.L1.EditionFeatures
|
||||
for len(tag) > 0 {
|
||||
i := strings.IndexByte(tag, ',')
|
||||
if i < 0 {
|
||||
|
@ -107,8 +108,7 @@ func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescri
|
|||
f.L1.StringName.InitJSON(jsonName)
|
||||
}
|
||||
case s == "packed":
|
||||
f.L1.HasPacked = true
|
||||
f.L1.IsPacked = true
|
||||
f.L1.EditionFeatures.IsPacked = true
|
||||
case strings.HasPrefix(s, "weak="):
|
||||
f.L1.IsWeak = true
|
||||
f.L1.Message = filedesc.PlaceholderMessage(protoreflect.FullName(s[len("weak="):]))
|
||||
|
|
|
@ -7,6 +7,7 @@ package filedesc
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
|
@ -68,7 +69,7 @@ type (
|
|||
Extensions Extensions
|
||||
Services Services
|
||||
|
||||
EditionFeatures FileEditionFeatures
|
||||
EditionFeatures EditionFeatures
|
||||
}
|
||||
FileL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
|
@ -76,10 +77,13 @@ type (
|
|||
Locations SourceLocations
|
||||
}
|
||||
|
||||
FileEditionFeatures struct {
|
||||
EditionFeatures struct {
|
||||
// IsFieldPresence is true if field_presence is EXPLICIT
|
||||
// https://protobuf.dev/editions/features/#field_presence
|
||||
IsFieldPresence bool
|
||||
// IsFieldPresence is true if field_presence is LEGACY_REQUIRED
|
||||
// https://protobuf.dev/editions/features/#field_presence
|
||||
IsLegacyRequired bool
|
||||
// IsOpenEnum is true if enum_type is OPEN
|
||||
// https://protobuf.dev/editions/features/#enum_type
|
||||
IsOpenEnum bool
|
||||
|
@ -95,6 +99,9 @@ type (
|
|||
// IsJSONCompliant is true if json_format is ALLOW
|
||||
// https://protobuf.dev/editions/features/#json_format
|
||||
IsJSONCompliant bool
|
||||
// GenerateLegacyUnmarshalJSON determines if the plugin generates the
|
||||
// UnmarshalJSON([]byte) error method for enums.
|
||||
GenerateLegacyUnmarshalJSON bool
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -102,9 +109,12 @@ func (fd *File) ParentFile() protoreflect.FileDescriptor { return fd }
|
|||
func (fd *File) Parent() protoreflect.Descriptor { return nil }
|
||||
func (fd *File) Index() int { return 0 }
|
||||
func (fd *File) Syntax() protoreflect.Syntax { return fd.L1.Syntax }
|
||||
func (fd *File) Name() protoreflect.Name { return fd.L1.Package.Name() }
|
||||
func (fd *File) FullName() protoreflect.FullName { return fd.L1.Package }
|
||||
func (fd *File) IsPlaceholder() bool { return false }
|
||||
|
||||
// Not exported and just used to reconstruct the original FileDescriptor proto
|
||||
func (fd *File) Edition() int32 { return int32(fd.L1.Edition) }
|
||||
func (fd *File) Name() protoreflect.Name { return fd.L1.Package.Name() }
|
||||
func (fd *File) FullName() protoreflect.FullName { return fd.L1.Package }
|
||||
func (fd *File) IsPlaceholder() bool { return false }
|
||||
func (fd *File) Options() protoreflect.ProtoMessage {
|
||||
if f := fd.lazyInit().Options; f != nil {
|
||||
return f()
|
||||
|
@ -156,6 +166,8 @@ type (
|
|||
}
|
||||
EnumL1 struct {
|
||||
eagerValues bool // controls whether EnumL2.Values is already populated
|
||||
|
||||
EditionFeatures EditionFeatures
|
||||
}
|
||||
EnumL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
|
@ -194,6 +206,9 @@ func (ed *Enum) lazyInit() *EnumL2 {
|
|||
ed.L0.ParentFile.lazyInit() // implicitly initializes L2
|
||||
return ed.L2
|
||||
}
|
||||
func (ed *Enum) IsClosed() bool {
|
||||
return !ed.L1.EditionFeatures.IsOpenEnum
|
||||
}
|
||||
|
||||
func (ed *EnumValue) Options() protoreflect.ProtoMessage {
|
||||
if f := ed.L1.Options; f != nil {
|
||||
|
@ -217,6 +232,8 @@ type (
|
|||
Extensions Extensions
|
||||
IsMapEntry bool // promoted from google.protobuf.MessageOptions
|
||||
IsMessageSet bool // promoted from google.protobuf.MessageOptions
|
||||
|
||||
EditionFeatures EditionFeatures
|
||||
}
|
||||
MessageL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
|
@ -241,17 +258,12 @@ type (
|
|||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||
HasPacked bool // promoted from google.protobuf.FieldOptions
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
HasEnforceUTF8 bool // promoted from google.protobuf.FieldOptions
|
||||
EnforceUTF8 bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
ContainingOneof protoreflect.OneofDescriptor // must be consistent with Message.Oneofs.Fields
|
||||
Enum protoreflect.EnumDescriptor
|
||||
Message protoreflect.MessageDescriptor
|
||||
|
||||
// Edition features.
|
||||
Presence bool
|
||||
EditionFeatures EditionFeatures
|
||||
}
|
||||
|
||||
Oneof struct {
|
||||
|
@ -261,6 +273,8 @@ type (
|
|||
OneofL1 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Fields OneofFields // must be consistent with Message.Fields.ContainingOneof
|
||||
|
||||
EditionFeatures EditionFeatures
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -310,28 +324,30 @@ func (fd *Field) Options() protoreflect.ProtoMessage {
|
|||
}
|
||||
func (fd *Field) Number() protoreflect.FieldNumber { return fd.L1.Number }
|
||||
func (fd *Field) Cardinality() protoreflect.Cardinality { return fd.L1.Cardinality }
|
||||
func (fd *Field) Kind() protoreflect.Kind { return fd.L1.Kind }
|
||||
func (fd *Field) HasJSONName() bool { return fd.L1.StringName.hasJSON }
|
||||
func (fd *Field) JSONName() string { return fd.L1.StringName.getJSON(fd) }
|
||||
func (fd *Field) TextName() string { return fd.L1.StringName.getText(fd) }
|
||||
func (fd *Field) Kind() protoreflect.Kind {
|
||||
return fd.L1.Kind
|
||||
}
|
||||
func (fd *Field) HasJSONName() bool { return fd.L1.StringName.hasJSON }
|
||||
func (fd *Field) JSONName() string { return fd.L1.StringName.getJSON(fd) }
|
||||
func (fd *Field) TextName() string { return fd.L1.StringName.getText(fd) }
|
||||
func (fd *Field) HasPresence() bool {
|
||||
if fd.L0.ParentFile.L1.Syntax == protoreflect.Editions {
|
||||
return fd.L1.Presence || fd.L1.Message != nil || fd.L1.ContainingOneof != nil
|
||||
if fd.L1.Cardinality == protoreflect.Repeated {
|
||||
return false
|
||||
}
|
||||
return fd.L1.Cardinality != protoreflect.Repeated && (fd.L0.ParentFile.L1.Syntax == protoreflect.Proto2 || fd.L1.Message != nil || fd.L1.ContainingOneof != nil)
|
||||
return fd.IsExtension() || fd.L1.EditionFeatures.IsFieldPresence || fd.L1.Message != nil || fd.L1.ContainingOneof != nil
|
||||
}
|
||||
func (fd *Field) HasOptionalKeyword() bool {
|
||||
return (fd.L0.ParentFile.L1.Syntax == protoreflect.Proto2 && fd.L1.Cardinality == protoreflect.Optional && fd.L1.ContainingOneof == nil) || fd.L1.IsProto3Optional
|
||||
}
|
||||
func (fd *Field) IsPacked() bool {
|
||||
if !fd.L1.HasPacked && fd.L0.ParentFile.L1.Syntax != protoreflect.Proto2 && fd.L1.Cardinality == protoreflect.Repeated {
|
||||
switch fd.L1.Kind {
|
||||
case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
default:
|
||||
return true
|
||||
}
|
||||
if fd.L1.Cardinality != protoreflect.Repeated {
|
||||
return false
|
||||
}
|
||||
return fd.L1.IsPacked
|
||||
switch fd.L1.Kind {
|
||||
case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
return false
|
||||
}
|
||||
return fd.L1.EditionFeatures.IsPacked
|
||||
}
|
||||
func (fd *Field) IsExtension() bool { return false }
|
||||
func (fd *Field) IsWeak() bool { return fd.L1.IsWeak }
|
||||
|
@ -378,10 +394,7 @@ func (fd *Field) ProtoType(protoreflect.FieldDescriptor) {}
|
|||
// WARNING: This method is exempt from the compatibility promise and may be
|
||||
// removed in the future without warning.
|
||||
func (fd *Field) EnforceUTF8() bool {
|
||||
if fd.L1.HasEnforceUTF8 {
|
||||
return fd.L1.EnforceUTF8
|
||||
}
|
||||
return fd.L0.ParentFile.L1.Syntax == protoreflect.Proto3
|
||||
return fd.L1.EditionFeatures.IsUTF8Validated
|
||||
}
|
||||
|
||||
func (od *Oneof) IsSynthetic() bool {
|
||||
|
@ -404,16 +417,24 @@ type (
|
|||
L2 *ExtensionL2 // protected by fileDesc.once
|
||||
}
|
||||
ExtensionL1 struct {
|
||||
Number protoreflect.FieldNumber
|
||||
Extendee protoreflect.MessageDescriptor
|
||||
Cardinality protoreflect.Cardinality
|
||||
Kind protoreflect.Kind
|
||||
Number protoreflect.FieldNumber
|
||||
Extendee protoreflect.MessageDescriptor
|
||||
Cardinality protoreflect.Cardinality
|
||||
Kind protoreflect.Kind
|
||||
EditionFeatures EditionFeatures
|
||||
// To resolve the EditionFeatures we need to resolve the Extendee which
|
||||
// happens at the end of the initialization of L1. Thus, we need to buffer
|
||||
// the unresolved features (which are parsed when starting to initialize
|
||||
// L1). We cannot move this to L2 because it is required to initialize
|
||||
// Kind properly. Because some of the options (i.e. packed) affect the
|
||||
// EditionFeatures we need to unmarshal the full options after resolving
|
||||
// the Extendee.
|
||||
rawOptions []byte
|
||||
}
|
||||
ExtensionL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
Enum protoreflect.EnumDescriptor
|
||||
Message protoreflect.MessageDescriptor
|
||||
|
@ -436,7 +457,7 @@ func (xd *Extension) HasPresence() bool { return xd.L1.Cardi
|
|||
func (xd *Extension) HasOptionalKeyword() bool {
|
||||
return (xd.L0.ParentFile.L1.Syntax == protoreflect.Proto2 && xd.L1.Cardinality == protoreflect.Optional) || xd.lazyInit().IsProto3Optional
|
||||
}
|
||||
func (xd *Extension) IsPacked() bool { return xd.lazyInit().IsPacked }
|
||||
func (xd *Extension) IsPacked() bool { return xd.L1.EditionFeatures.IsPacked }
|
||||
func (xd *Extension) IsExtension() bool { return true }
|
||||
func (xd *Extension) IsWeak() bool { return false }
|
||||
func (xd *Extension) IsList() bool { return xd.Cardinality() == protoreflect.Repeated }
|
||||
|
@ -517,8 +538,9 @@ func (md *Method) ProtoInternal(pragma.DoNotImplement) {}
|
|||
// Surrogate files are can be used to create standalone descriptors
|
||||
// where the syntax is only information derived from the parent file.
|
||||
var (
|
||||
SurrogateProto2 = &File{L1: FileL1{Syntax: protoreflect.Proto2}, L2: &FileL2{}}
|
||||
SurrogateProto3 = &File{L1: FileL1{Syntax: protoreflect.Proto3}, L2: &FileL2{}}
|
||||
SurrogateProto2 = &File{L1: FileL1{Syntax: protoreflect.Proto2}, L2: &FileL2{}}
|
||||
SurrogateProto3 = &File{L1: FileL1{Syntax: protoreflect.Proto3}, L2: &FileL2{}}
|
||||
SurrogateEdition2023 = &File{L1: FileL1{Syntax: protoreflect.Editions, Edition: Edition2023}, L2: &FileL2{}}
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -560,6 +582,34 @@ func (s *stringName) InitJSON(name string) {
|
|||
s.nameJSON = name
|
||||
}
|
||||
|
||||
// Returns true if this field is structured like the synthetic field of a proto2
|
||||
// group. This allows us to expand our treatment of delimited fields without
|
||||
// breaking proto2 files that have been upgraded to editions.
|
||||
func isGroupLike(fd protoreflect.FieldDescriptor) bool {
|
||||
// Groups are always group types.
|
||||
if fd.Kind() != protoreflect.GroupKind {
|
||||
return false
|
||||
}
|
||||
|
||||
// Group fields are always the lowercase type name.
|
||||
if strings.ToLower(string(fd.Message().Name())) != string(fd.Name()) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Groups could only be defined in the same file they're used.
|
||||
if fd.Message().ParentFile() != fd.ParentFile() {
|
||||
return false
|
||||
}
|
||||
|
||||
// Group messages are always defined in the same scope as the field. File
|
||||
// level extensions will compare NULL == NULL here, which is why the file
|
||||
// comparison above is necessary to ensure both come from the same file.
|
||||
if fd.IsExtension() {
|
||||
return fd.Parent() == fd.Message().Parent()
|
||||
}
|
||||
return fd.ContainingMessage() == fd.Message().Parent()
|
||||
}
|
||||
|
||||
func (s *stringName) lazyInit(fd protoreflect.FieldDescriptor) *stringName {
|
||||
s.once.Do(func() {
|
||||
if fd.IsExtension() {
|
||||
|
@ -580,7 +630,7 @@ func (s *stringName) lazyInit(fd protoreflect.FieldDescriptor) *stringName {
|
|||
|
||||
// Format the text name.
|
||||
s.nameText = string(fd.Name())
|
||||
if fd.Kind() == protoreflect.GroupKind {
|
||||
if isGroupLike(fd) {
|
||||
s.nameText = string(fd.Message().Name())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package filedesc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
|
@ -33,6 +34,20 @@ func newRawFile(db Builder) *File {
|
|||
for i := range fd.allExtensions {
|
||||
xd := &fd.allExtensions[i]
|
||||
xd.L1.Extendee = fd.resolveMessageDependency(xd.L1.Extendee, listExtTargets, int32(i))
|
||||
|
||||
// If the Extendee is not resolved, we cannot resolve the edition
|
||||
// features of the parent. This should (to my knowledge) only happen
|
||||
// for v1 messages for which we don't support editions. In v2 the
|
||||
// Extendee should be resolved at binary start up time.
|
||||
if _, ok := xd.L1.Extendee.(PlaceholderMessage); !ok {
|
||||
xd.L1.EditionFeatures = featuresFromParentDesc(xd.L1.Extendee)
|
||||
}
|
||||
if xd.L1.rawOptions != nil {
|
||||
xd.unmarshalOptions(xd.L1.rawOptions)
|
||||
}
|
||||
if xd.L1.Kind == protoreflect.MessageKind && xd.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
xd.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
}
|
||||
|
||||
fd.checkDecls()
|
||||
|
@ -98,6 +113,7 @@ func (fd *File) unmarshalSeed(b []byte) {
|
|||
var prevField protoreflect.FieldNumber
|
||||
var numEnums, numMessages, numExtensions, numServices int
|
||||
var posEnums, posMessages, posExtensions, posServices int
|
||||
var options []byte
|
||||
b0 := b
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
|
@ -111,8 +127,12 @@ func (fd *File) unmarshalSeed(b []byte) {
|
|||
switch string(v) {
|
||||
case "proto2":
|
||||
fd.L1.Syntax = protoreflect.Proto2
|
||||
fd.L1.Edition = EditionProto2
|
||||
case "proto3":
|
||||
fd.L1.Syntax = protoreflect.Proto3
|
||||
fd.L1.Edition = EditionProto3
|
||||
case "editions":
|
||||
fd.L1.Syntax = protoreflect.Editions
|
||||
default:
|
||||
panic("invalid syntax")
|
||||
}
|
||||
|
@ -120,6 +140,8 @@ func (fd *File) unmarshalSeed(b []byte) {
|
|||
fd.L1.Path = sb.MakeString(v)
|
||||
case genid.FileDescriptorProto_Package_field_number:
|
||||
fd.L1.Package = protoreflect.FullName(sb.MakeString(v))
|
||||
case genid.FileDescriptorProto_Options_field_number:
|
||||
options = v
|
||||
case genid.FileDescriptorProto_EnumType_field_number:
|
||||
if prevField != genid.FileDescriptorProto_EnumType_field_number {
|
||||
if numEnums > 0 {
|
||||
|
@ -154,6 +176,13 @@ func (fd *File) unmarshalSeed(b []byte) {
|
|||
numServices++
|
||||
}
|
||||
prevField = num
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FileDescriptorProto_Edition_field_number:
|
||||
fd.L1.Edition = Edition(v)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
|
@ -164,6 +193,14 @@ func (fd *File) unmarshalSeed(b []byte) {
|
|||
// If syntax is missing, it is assumed to be proto2.
|
||||
if fd.L1.Syntax == 0 {
|
||||
fd.L1.Syntax = protoreflect.Proto2
|
||||
fd.L1.Edition = EditionProto2
|
||||
}
|
||||
|
||||
fd.L1.EditionFeatures = getFeaturesFor(fd.L1.Edition)
|
||||
|
||||
// Parse editions features from options if any
|
||||
if options != nil {
|
||||
fd.unmarshalSeedOptions(options)
|
||||
}
|
||||
|
||||
// Must allocate all declarations before parsing each descriptor type
|
||||
|
@ -219,10 +256,33 @@ func (fd *File) unmarshalSeed(b []byte) {
|
|||
}
|
||||
}
|
||||
|
||||
func (fd *File) unmarshalSeedOptions(b []byte) {
|
||||
for b := b; len(b) > 0; {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FileOptions_Features_field_number:
|
||||
if fd.Syntax() != protoreflect.Editions {
|
||||
panic(fmt.Sprintf("invalid descriptor: using edition features in a proto with syntax %s", fd.Syntax()))
|
||||
}
|
||||
fd.L1.EditionFeatures = unmarshalFeatureSet(v, fd.L1.EditionFeatures)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protoreflect.Descriptor, i int) {
|
||||
ed.L0.ParentFile = pf
|
||||
ed.L0.Parent = pd
|
||||
ed.L0.Index = i
|
||||
ed.L1.EditionFeatures = featuresFromParentDesc(ed.Parent())
|
||||
|
||||
var numValues int
|
||||
for b := b; len(b) > 0; {
|
||||
|
@ -275,6 +335,7 @@ func (md *Message) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protor
|
|||
md.L0.ParentFile = pf
|
||||
md.L0.Parent = pd
|
||||
md.L0.Index = i
|
||||
md.L1.EditionFeatures = featuresFromParentDesc(md.Parent())
|
||||
|
||||
var prevField protoreflect.FieldNumber
|
||||
var numEnums, numMessages, numExtensions int
|
||||
|
@ -380,6 +441,13 @@ func (md *Message) unmarshalSeedOptions(b []byte) {
|
|||
case genid.MessageOptions_MessageSetWireFormat_field_number:
|
||||
md.L1.IsMessageSet = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.MessageOptions_Features_field_number:
|
||||
md.L1.EditionFeatures = unmarshalFeatureSet(v, md.L1.EditionFeatures)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
|
@ -415,6 +483,34 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd prot
|
|||
xd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case genid.FieldDescriptorProto_Extendee_field_number:
|
||||
xd.L1.Extendee = PlaceholderMessage(makeFullName(sb, v))
|
||||
case genid.FieldDescriptorProto_Options_field_number:
|
||||
xd.L1.rawOptions = v
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (xd *Extension) unmarshalOptions(b []byte) {
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
xd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Features_field_number:
|
||||
xd.L1.EditionFeatures = unmarshalFeatureSet(v, xd.L1.EditionFeatures)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
|
|
|
@ -414,6 +414,7 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoref
|
|||
fd.L0.ParentFile = pf
|
||||
fd.L0.Parent = pd
|
||||
fd.L0.Index = i
|
||||
fd.L1.EditionFeatures = featuresFromParentDesc(fd.Parent())
|
||||
|
||||
var rawTypeName []byte
|
||||
var rawOptions []byte
|
||||
|
@ -465,6 +466,12 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoref
|
|||
b = b[m:]
|
||||
}
|
||||
}
|
||||
if fd.L1.Kind == protoreflect.MessageKind && fd.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
fd.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
if fd.L1.EditionFeatures.IsLegacyRequired {
|
||||
fd.L1.Cardinality = protoreflect.Required
|
||||
}
|
||||
if rawTypeName != nil {
|
||||
name := makeFullName(sb, rawTypeName)
|
||||
switch fd.L1.Kind {
|
||||
|
@ -489,13 +496,18 @@ func (fd *Field) unmarshalOptions(b []byte) {
|
|||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
fd.L1.HasPacked = true
|
||||
fd.L1.IsPacked = protowire.DecodeBool(v)
|
||||
fd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v)
|
||||
case genid.FieldOptions_Weak_field_number:
|
||||
fd.L1.IsWeak = protowire.DecodeBool(v)
|
||||
case FieldOptions_EnforceUTF8:
|
||||
fd.L1.HasEnforceUTF8 = true
|
||||
fd.L1.EnforceUTF8 = protowire.DecodeBool(v)
|
||||
fd.L1.EditionFeatures.IsUTF8Validated = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Features_field_number:
|
||||
fd.L1.EditionFeatures = unmarshalFeatureSet(v, fd.L1.EditionFeatures)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
|
@ -557,7 +569,6 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
|||
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||
rawTypeName = v
|
||||
case genid.FieldDescriptorProto_Options_field_number:
|
||||
xd.unmarshalOptions(v)
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
|
@ -577,25 +588,6 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
|||
xd.L2.Options = xd.L0.ParentFile.builder.optionsUnmarshaler(&descopts.Field, rawOptions)
|
||||
}
|
||||
|
||||
func (xd *Extension) unmarshalOptions(b []byte) {
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
xd.L2.IsPacked = protowire.DecodeBool(v)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (sd *Service) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
var rawMethods [][]byte
|
||||
var rawOptions []byte
|
||||
|
|
|
@ -0,0 +1,154 @@
|
|||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package filedesc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/editiondefaults"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
var defaultsCache = make(map[Edition]EditionFeatures)
|
||||
var defaultsKeys = []Edition{}
|
||||
|
||||
func init() {
|
||||
unmarshalEditionDefaults(editiondefaults.Defaults)
|
||||
SurrogateProto2.L1.EditionFeatures = getFeaturesFor(EditionProto2)
|
||||
SurrogateProto3.L1.EditionFeatures = getFeaturesFor(EditionProto3)
|
||||
SurrogateEdition2023.L1.EditionFeatures = getFeaturesFor(Edition2023)
|
||||
}
|
||||
|
||||
func unmarshalGoFeature(b []byte, parent EditionFeatures) EditionFeatures {
|
||||
for len(b) > 0 {
|
||||
num, _, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch num {
|
||||
case genid.GoFeatures_LegacyUnmarshalJsonEnum_field_number:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
parent.GenerateLegacyUnmarshalJSON = protowire.DecodeBool(v)
|
||||
default:
|
||||
panic(fmt.Sprintf("unkown field number %d while unmarshalling GoFeatures", num))
|
||||
}
|
||||
}
|
||||
return parent
|
||||
}
|
||||
|
||||
func unmarshalFeatureSet(b []byte, parent EditionFeatures) EditionFeatures {
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FeatureSet_FieldPresence_field_number:
|
||||
parent.IsFieldPresence = v == genid.FeatureSet_EXPLICIT_enum_value || v == genid.FeatureSet_LEGACY_REQUIRED_enum_value
|
||||
parent.IsLegacyRequired = v == genid.FeatureSet_LEGACY_REQUIRED_enum_value
|
||||
case genid.FeatureSet_EnumType_field_number:
|
||||
parent.IsOpenEnum = v == genid.FeatureSet_OPEN_enum_value
|
||||
case genid.FeatureSet_RepeatedFieldEncoding_field_number:
|
||||
parent.IsPacked = v == genid.FeatureSet_PACKED_enum_value
|
||||
case genid.FeatureSet_Utf8Validation_field_number:
|
||||
parent.IsUTF8Validated = v == genid.FeatureSet_VERIFY_enum_value
|
||||
case genid.FeatureSet_MessageEncoding_field_number:
|
||||
parent.IsDelimitedEncoded = v == genid.FeatureSet_DELIMITED_enum_value
|
||||
case genid.FeatureSet_JsonFormat_field_number:
|
||||
parent.IsJSONCompliant = v == genid.FeatureSet_ALLOW_enum_value
|
||||
default:
|
||||
panic(fmt.Sprintf("unkown field number %d while unmarshalling FeatureSet", num))
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.GoFeatures_LegacyUnmarshalJsonEnum_field_number:
|
||||
parent = unmarshalGoFeature(v, parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parent
|
||||
}
|
||||
|
||||
func featuresFromParentDesc(parentDesc protoreflect.Descriptor) EditionFeatures {
|
||||
var parentFS EditionFeatures
|
||||
switch p := parentDesc.(type) {
|
||||
case *File:
|
||||
parentFS = p.L1.EditionFeatures
|
||||
case *Message:
|
||||
parentFS = p.L1.EditionFeatures
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown parent type %T", parentDesc))
|
||||
}
|
||||
return parentFS
|
||||
}
|
||||
|
||||
func unmarshalEditionDefault(b []byte) {
|
||||
var ed Edition
|
||||
var fs EditionFeatures
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_number:
|
||||
ed = Edition(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FeatureSetDefaults_FeatureSetEditionDefault_Features_field_number:
|
||||
fs = unmarshalFeatureSet(v, fs)
|
||||
}
|
||||
}
|
||||
}
|
||||
defaultsCache[ed] = fs
|
||||
defaultsKeys = append(defaultsKeys, ed)
|
||||
}
|
||||
|
||||
func unmarshalEditionDefaults(b []byte) {
|
||||
for len(b) > 0 {
|
||||
num, _, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch num {
|
||||
case genid.FeatureSetDefaults_Defaults_field_number:
|
||||
def, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
unmarshalEditionDefault(def)
|
||||
case genid.FeatureSetDefaults_MinimumEdition_field_number,
|
||||
genid.FeatureSetDefaults_MaximumEdition_field_number:
|
||||
// We don't care about the minimum and maximum editions. If the
|
||||
// edition we are looking for later on is not in the cache we know
|
||||
// it is outside of the range between minimum and maximum edition.
|
||||
_, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
default:
|
||||
panic(fmt.Sprintf("unkown field number %d while unmarshalling EditionDefault", num))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getFeaturesFor(ed Edition) EditionFeatures {
|
||||
match := EditionUnknown
|
||||
for _, key := range defaultsKeys {
|
||||
if key > ed {
|
||||
break
|
||||
}
|
||||
match = key
|
||||
}
|
||||
if match == EditionUnknown {
|
||||
panic(fmt.Sprintf("unsupported edition: %v", ed))
|
||||
}
|
||||
return defaultsCache[match]
|
||||
}
|
|
@ -63,6 +63,7 @@ func (e PlaceholderEnum) Options() protoreflect.ProtoMessage { return des
|
|||
func (e PlaceholderEnum) Values() protoreflect.EnumValueDescriptors { return emptyEnumValues }
|
||||
func (e PlaceholderEnum) ReservedNames() protoreflect.Names { return emptyNames }
|
||||
func (e PlaceholderEnum) ReservedRanges() protoreflect.EnumRanges { return emptyEnumRanges }
|
||||
func (e PlaceholderEnum) IsClosed() bool { return false }
|
||||
func (e PlaceholderEnum) ProtoType(protoreflect.EnumDescriptor) { return }
|
||||
func (e PlaceholderEnum) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
|
||||
|
|
|
@ -18,6 +18,21 @@ const (
|
|||
Edition_enum_name = "Edition"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.Edition.
|
||||
const (
|
||||
Edition_EDITION_UNKNOWN_enum_value = 0
|
||||
Edition_EDITION_PROTO2_enum_value = 998
|
||||
Edition_EDITION_PROTO3_enum_value = 999
|
||||
Edition_EDITION_2023_enum_value = 1000
|
||||
Edition_EDITION_2024_enum_value = 1001
|
||||
Edition_EDITION_1_TEST_ONLY_enum_value = 1
|
||||
Edition_EDITION_2_TEST_ONLY_enum_value = 2
|
||||
Edition_EDITION_99997_TEST_ONLY_enum_value = 99997
|
||||
Edition_EDITION_99998_TEST_ONLY_enum_value = 99998
|
||||
Edition_EDITION_99999_TEST_ONLY_enum_value = 99999
|
||||
Edition_EDITION_MAX_enum_value = 2147483647
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FileDescriptorSet.
|
||||
const (
|
||||
FileDescriptorSet_message_name protoreflect.Name = "FileDescriptorSet"
|
||||
|
@ -213,6 +228,12 @@ const (
|
|||
ExtensionRangeOptions_VerificationState_enum_name = "VerificationState"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.ExtensionRangeOptions.VerificationState.
|
||||
const (
|
||||
ExtensionRangeOptions_DECLARATION_enum_value = 0
|
||||
ExtensionRangeOptions_UNVERIFIED_enum_value = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.ExtensionRangeOptions.Declaration.
|
||||
const (
|
||||
ExtensionRangeOptions_Declaration_message_name protoreflect.Name = "Declaration"
|
||||
|
@ -297,12 +318,41 @@ const (
|
|||
FieldDescriptorProto_Type_enum_name = "Type"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldDescriptorProto.Type.
|
||||
const (
|
||||
FieldDescriptorProto_TYPE_DOUBLE_enum_value = 1
|
||||
FieldDescriptorProto_TYPE_FLOAT_enum_value = 2
|
||||
FieldDescriptorProto_TYPE_INT64_enum_value = 3
|
||||
FieldDescriptorProto_TYPE_UINT64_enum_value = 4
|
||||
FieldDescriptorProto_TYPE_INT32_enum_value = 5
|
||||
FieldDescriptorProto_TYPE_FIXED64_enum_value = 6
|
||||
FieldDescriptorProto_TYPE_FIXED32_enum_value = 7
|
||||
FieldDescriptorProto_TYPE_BOOL_enum_value = 8
|
||||
FieldDescriptorProto_TYPE_STRING_enum_value = 9
|
||||
FieldDescriptorProto_TYPE_GROUP_enum_value = 10
|
||||
FieldDescriptorProto_TYPE_MESSAGE_enum_value = 11
|
||||
FieldDescriptorProto_TYPE_BYTES_enum_value = 12
|
||||
FieldDescriptorProto_TYPE_UINT32_enum_value = 13
|
||||
FieldDescriptorProto_TYPE_ENUM_enum_value = 14
|
||||
FieldDescriptorProto_TYPE_SFIXED32_enum_value = 15
|
||||
FieldDescriptorProto_TYPE_SFIXED64_enum_value = 16
|
||||
FieldDescriptorProto_TYPE_SINT32_enum_value = 17
|
||||
FieldDescriptorProto_TYPE_SINT64_enum_value = 18
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldDescriptorProto.Label.
|
||||
const (
|
||||
FieldDescriptorProto_Label_enum_fullname = "google.protobuf.FieldDescriptorProto.Label"
|
||||
FieldDescriptorProto_Label_enum_name = "Label"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldDescriptorProto.Label.
|
||||
const (
|
||||
FieldDescriptorProto_LABEL_OPTIONAL_enum_value = 1
|
||||
FieldDescriptorProto_LABEL_REPEATED_enum_value = 3
|
||||
FieldDescriptorProto_LABEL_REQUIRED_enum_value = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.OneofDescriptorProto.
|
||||
const (
|
||||
OneofDescriptorProto_message_name protoreflect.Name = "OneofDescriptorProto"
|
||||
|
@ -474,7 +524,6 @@ const (
|
|||
FileOptions_CcGenericServices_field_name protoreflect.Name = "cc_generic_services"
|
||||
FileOptions_JavaGenericServices_field_name protoreflect.Name = "java_generic_services"
|
||||
FileOptions_PyGenericServices_field_name protoreflect.Name = "py_generic_services"
|
||||
FileOptions_PhpGenericServices_field_name protoreflect.Name = "php_generic_services"
|
||||
FileOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
FileOptions_CcEnableArenas_field_name protoreflect.Name = "cc_enable_arenas"
|
||||
FileOptions_ObjcClassPrefix_field_name protoreflect.Name = "objc_class_prefix"
|
||||
|
@ -497,7 +546,6 @@ const (
|
|||
FileOptions_CcGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.cc_generic_services"
|
||||
FileOptions_JavaGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_generic_services"
|
||||
FileOptions_PyGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.py_generic_services"
|
||||
FileOptions_PhpGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_generic_services"
|
||||
FileOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.deprecated"
|
||||
FileOptions_CcEnableArenas_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.cc_enable_arenas"
|
||||
FileOptions_ObjcClassPrefix_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.objc_class_prefix"
|
||||
|
@ -523,7 +571,6 @@ const (
|
|||
FileOptions_CcGenericServices_field_number protoreflect.FieldNumber = 16
|
||||
FileOptions_JavaGenericServices_field_number protoreflect.FieldNumber = 17
|
||||
FileOptions_PyGenericServices_field_number protoreflect.FieldNumber = 18
|
||||
FileOptions_PhpGenericServices_field_number protoreflect.FieldNumber = 42
|
||||
FileOptions_Deprecated_field_number protoreflect.FieldNumber = 23
|
||||
FileOptions_CcEnableArenas_field_number protoreflect.FieldNumber = 31
|
||||
FileOptions_ObjcClassPrefix_field_number protoreflect.FieldNumber = 36
|
||||
|
@ -543,6 +590,13 @@ const (
|
|||
FileOptions_OptimizeMode_enum_name = "OptimizeMode"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FileOptions.OptimizeMode.
|
||||
const (
|
||||
FileOptions_SPEED_enum_value = 1
|
||||
FileOptions_CODE_SIZE_enum_value = 2
|
||||
FileOptions_LITE_RUNTIME_enum_value = 3
|
||||
)
|
||||
|
||||
// Names for google.protobuf.MessageOptions.
|
||||
const (
|
||||
MessageOptions_message_name protoreflect.Name = "MessageOptions"
|
||||
|
@ -639,24 +693,59 @@ const (
|
|||
FieldOptions_CType_enum_name = "CType"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldOptions.CType.
|
||||
const (
|
||||
FieldOptions_STRING_enum_value = 0
|
||||
FieldOptions_CORD_enum_value = 1
|
||||
FieldOptions_STRING_PIECE_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldOptions.JSType.
|
||||
const (
|
||||
FieldOptions_JSType_enum_fullname = "google.protobuf.FieldOptions.JSType"
|
||||
FieldOptions_JSType_enum_name = "JSType"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldOptions.JSType.
|
||||
const (
|
||||
FieldOptions_JS_NORMAL_enum_value = 0
|
||||
FieldOptions_JS_STRING_enum_value = 1
|
||||
FieldOptions_JS_NUMBER_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldOptions.OptionRetention.
|
||||
const (
|
||||
FieldOptions_OptionRetention_enum_fullname = "google.protobuf.FieldOptions.OptionRetention"
|
||||
FieldOptions_OptionRetention_enum_name = "OptionRetention"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldOptions.OptionRetention.
|
||||
const (
|
||||
FieldOptions_RETENTION_UNKNOWN_enum_value = 0
|
||||
FieldOptions_RETENTION_RUNTIME_enum_value = 1
|
||||
FieldOptions_RETENTION_SOURCE_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldOptions.OptionTargetType.
|
||||
const (
|
||||
FieldOptions_OptionTargetType_enum_fullname = "google.protobuf.FieldOptions.OptionTargetType"
|
||||
FieldOptions_OptionTargetType_enum_name = "OptionTargetType"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldOptions.OptionTargetType.
|
||||
const (
|
||||
FieldOptions_TARGET_TYPE_UNKNOWN_enum_value = 0
|
||||
FieldOptions_TARGET_TYPE_FILE_enum_value = 1
|
||||
FieldOptions_TARGET_TYPE_EXTENSION_RANGE_enum_value = 2
|
||||
FieldOptions_TARGET_TYPE_MESSAGE_enum_value = 3
|
||||
FieldOptions_TARGET_TYPE_FIELD_enum_value = 4
|
||||
FieldOptions_TARGET_TYPE_ONEOF_enum_value = 5
|
||||
FieldOptions_TARGET_TYPE_ENUM_enum_value = 6
|
||||
FieldOptions_TARGET_TYPE_ENUM_ENTRY_enum_value = 7
|
||||
FieldOptions_TARGET_TYPE_SERVICE_enum_value = 8
|
||||
FieldOptions_TARGET_TYPE_METHOD_enum_value = 9
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FieldOptions.EditionDefault.
|
||||
const (
|
||||
FieldOptions_EditionDefault_message_name protoreflect.Name = "EditionDefault"
|
||||
|
@ -813,6 +902,13 @@ const (
|
|||
MethodOptions_IdempotencyLevel_enum_name = "IdempotencyLevel"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.MethodOptions.IdempotencyLevel.
|
||||
const (
|
||||
MethodOptions_IDEMPOTENCY_UNKNOWN_enum_value = 0
|
||||
MethodOptions_NO_SIDE_EFFECTS_enum_value = 1
|
||||
MethodOptions_IDEMPOTENT_enum_value = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.UninterpretedOption.
|
||||
const (
|
||||
UninterpretedOption_message_name protoreflect.Name = "UninterpretedOption"
|
||||
|
@ -909,36 +1005,79 @@ const (
|
|||
FeatureSet_FieldPresence_enum_name = "FieldPresence"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.FieldPresence.
|
||||
const (
|
||||
FeatureSet_FIELD_PRESENCE_UNKNOWN_enum_value = 0
|
||||
FeatureSet_EXPLICIT_enum_value = 1
|
||||
FeatureSet_IMPLICIT_enum_value = 2
|
||||
FeatureSet_LEGACY_REQUIRED_enum_value = 3
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.EnumType.
|
||||
const (
|
||||
FeatureSet_EnumType_enum_fullname = "google.protobuf.FeatureSet.EnumType"
|
||||
FeatureSet_EnumType_enum_name = "EnumType"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.EnumType.
|
||||
const (
|
||||
FeatureSet_ENUM_TYPE_UNKNOWN_enum_value = 0
|
||||
FeatureSet_OPEN_enum_value = 1
|
||||
FeatureSet_CLOSED_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.RepeatedFieldEncoding.
|
||||
const (
|
||||
FeatureSet_RepeatedFieldEncoding_enum_fullname = "google.protobuf.FeatureSet.RepeatedFieldEncoding"
|
||||
FeatureSet_RepeatedFieldEncoding_enum_name = "RepeatedFieldEncoding"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.RepeatedFieldEncoding.
|
||||
const (
|
||||
FeatureSet_REPEATED_FIELD_ENCODING_UNKNOWN_enum_value = 0
|
||||
FeatureSet_PACKED_enum_value = 1
|
||||
FeatureSet_EXPANDED_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.Utf8Validation.
|
||||
const (
|
||||
FeatureSet_Utf8Validation_enum_fullname = "google.protobuf.FeatureSet.Utf8Validation"
|
||||
FeatureSet_Utf8Validation_enum_name = "Utf8Validation"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.Utf8Validation.
|
||||
const (
|
||||
FeatureSet_UTF8_VALIDATION_UNKNOWN_enum_value = 0
|
||||
FeatureSet_VERIFY_enum_value = 2
|
||||
FeatureSet_NONE_enum_value = 3
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.MessageEncoding.
|
||||
const (
|
||||
FeatureSet_MessageEncoding_enum_fullname = "google.protobuf.FeatureSet.MessageEncoding"
|
||||
FeatureSet_MessageEncoding_enum_name = "MessageEncoding"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.MessageEncoding.
|
||||
const (
|
||||
FeatureSet_MESSAGE_ENCODING_UNKNOWN_enum_value = 0
|
||||
FeatureSet_LENGTH_PREFIXED_enum_value = 1
|
||||
FeatureSet_DELIMITED_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.JsonFormat.
|
||||
const (
|
||||
FeatureSet_JsonFormat_enum_fullname = "google.protobuf.FeatureSet.JsonFormat"
|
||||
FeatureSet_JsonFormat_enum_name = "JsonFormat"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.JsonFormat.
|
||||
const (
|
||||
FeatureSet_JSON_FORMAT_UNKNOWN_enum_value = 0
|
||||
FeatureSet_ALLOW_enum_value = 1
|
||||
FeatureSet_LEGACY_BEST_EFFORT_enum_value = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FeatureSetDefaults.
|
||||
const (
|
||||
FeatureSetDefaults_message_name protoreflect.Name = "FeatureSetDefaults"
|
||||
|
@ -1085,3 +1224,10 @@ const (
|
|||
GeneratedCodeInfo_Annotation_Semantic_enum_fullname = "google.protobuf.GeneratedCodeInfo.Annotation.Semantic"
|
||||
GeneratedCodeInfo_Annotation_Semantic_enum_name = "Semantic"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.GeneratedCodeInfo.Annotation.Semantic.
|
||||
const (
|
||||
GeneratedCodeInfo_Annotation_NONE_enum_value = 0
|
||||
GeneratedCodeInfo_Annotation_SET_enum_value = 1
|
||||
GeneratedCodeInfo_Annotation_ALIAS_enum_value = 2
|
||||
)
|
||||
|
|
31
vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go
generated
vendored
Normal file
31
vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_reflect_protodesc_proto_go_features_proto = "reflect/protodesc/proto/go_features.proto"
|
||||
|
||||
// Names for google.protobuf.GoFeatures.
|
||||
const (
|
||||
GoFeatures_message_name protoreflect.Name = "GoFeatures"
|
||||
GoFeatures_message_fullname protoreflect.FullName = "google.protobuf.GoFeatures"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.GoFeatures.
|
||||
const (
|
||||
GoFeatures_LegacyUnmarshalJsonEnum_field_name protoreflect.Name = "legacy_unmarshal_json_enum"
|
||||
|
||||
GoFeatures_LegacyUnmarshalJsonEnum_field_fullname protoreflect.FullName = "google.protobuf.GoFeatures.legacy_unmarshal_json_enum"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.GoFeatures.
|
||||
const (
|
||||
GoFeatures_LegacyUnmarshalJsonEnum_field_number protoreflect.FieldNumber = 1
|
||||
)
|
|
@ -18,6 +18,11 @@ const (
|
|||
NullValue_enum_name = "NullValue"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.NullValue.
|
||||
const (
|
||||
NullValue_NULL_VALUE_enum_value = 0
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Struct.
|
||||
const (
|
||||
Struct_message_name protoreflect.Name = "Struct"
|
||||
|
|
|
@ -18,6 +18,13 @@ const (
|
|||
Syntax_enum_name = "Syntax"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.Syntax.
|
||||
const (
|
||||
Syntax_SYNTAX_PROTO2_enum_value = 0
|
||||
Syntax_SYNTAX_PROTO3_enum_value = 1
|
||||
Syntax_SYNTAX_EDITIONS_enum_value = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Type.
|
||||
const (
|
||||
Type_message_name protoreflect.Name = "Type"
|
||||
|
@ -105,12 +112,43 @@ const (
|
|||
Field_Kind_enum_name = "Kind"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.Field.Kind.
|
||||
const (
|
||||
Field_TYPE_UNKNOWN_enum_value = 0
|
||||
Field_TYPE_DOUBLE_enum_value = 1
|
||||
Field_TYPE_FLOAT_enum_value = 2
|
||||
Field_TYPE_INT64_enum_value = 3
|
||||
Field_TYPE_UINT64_enum_value = 4
|
||||
Field_TYPE_INT32_enum_value = 5
|
||||
Field_TYPE_FIXED64_enum_value = 6
|
||||
Field_TYPE_FIXED32_enum_value = 7
|
||||
Field_TYPE_BOOL_enum_value = 8
|
||||
Field_TYPE_STRING_enum_value = 9
|
||||
Field_TYPE_GROUP_enum_value = 10
|
||||
Field_TYPE_MESSAGE_enum_value = 11
|
||||
Field_TYPE_BYTES_enum_value = 12
|
||||
Field_TYPE_UINT32_enum_value = 13
|
||||
Field_TYPE_ENUM_enum_value = 14
|
||||
Field_TYPE_SFIXED32_enum_value = 15
|
||||
Field_TYPE_SFIXED64_enum_value = 16
|
||||
Field_TYPE_SINT32_enum_value = 17
|
||||
Field_TYPE_SINT64_enum_value = 18
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.Field.Cardinality.
|
||||
const (
|
||||
Field_Cardinality_enum_fullname = "google.protobuf.Field.Cardinality"
|
||||
Field_Cardinality_enum_name = "Cardinality"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.Field.Cardinality.
|
||||
const (
|
||||
Field_CARDINALITY_UNKNOWN_enum_value = 0
|
||||
Field_CARDINALITY_OPTIONAL_enum_value = 1
|
||||
Field_CARDINALITY_REQUIRED_enum_value = 2
|
||||
Field_CARDINALITY_REPEATED_enum_value = 3
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Enum.
|
||||
const (
|
||||
Enum_message_name protoreflect.Name = "Enum"
|
||||
|
|
|
@ -21,26 +21,18 @@ type extensionFieldInfo struct {
|
|||
validation validationInfo
|
||||
}
|
||||
|
||||
var legacyExtensionFieldInfoCache sync.Map // map[protoreflect.ExtensionType]*extensionFieldInfo
|
||||
|
||||
func getExtensionFieldInfo(xt protoreflect.ExtensionType) *extensionFieldInfo {
|
||||
if xi, ok := xt.(*ExtensionInfo); ok {
|
||||
xi.lazyInit()
|
||||
return xi.info
|
||||
}
|
||||
return legacyLoadExtensionFieldInfo(xt)
|
||||
}
|
||||
|
||||
// legacyLoadExtensionFieldInfo dynamically loads a *ExtensionInfo for xt.
|
||||
func legacyLoadExtensionFieldInfo(xt protoreflect.ExtensionType) *extensionFieldInfo {
|
||||
if xi, ok := legacyExtensionFieldInfoCache.Load(xt); ok {
|
||||
return xi.(*extensionFieldInfo)
|
||||
}
|
||||
e := makeExtensionFieldInfo(xt.TypeDescriptor())
|
||||
if e, ok := legacyMessageTypeCache.LoadOrStore(xt, e); ok {
|
||||
return e.(*extensionFieldInfo)
|
||||
}
|
||||
return e
|
||||
// Ideally we'd cache the resulting *extensionFieldInfo so we don't have to
|
||||
// recompute this metadata repeatedly. But without support for something like
|
||||
// weak references, such a cache would pin temporary values (like dynamic
|
||||
// extension types, constructed for the duration of a user request) to the
|
||||
// heap forever, causing memory usage of the cache to grow unbounded.
|
||||
// See discussion in https://github.com/golang/protobuf/issues/1521.
|
||||
return makeExtensionFieldInfo(xt.TypeDescriptor())
|
||||
}
|
||||
|
||||
func makeExtensionFieldInfo(xd protoreflect.ExtensionDescriptor) *extensionFieldInfo {
|
||||
|
|
|
@ -197,7 +197,7 @@ func fieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) (*MessageInfo,
|
|||
return getMessageInfo(ft), makeMessageFieldCoder(fd, ft)
|
||||
case fd.Kind() == protoreflect.GroupKind:
|
||||
return getMessageInfo(ft), makeGroupFieldCoder(fd, ft)
|
||||
case fd.Syntax() == protoreflect.Proto3 && fd.ContainingOneof() == nil:
|
||||
case !fd.HasPresence() && fd.ContainingOneof() == nil:
|
||||
// Populated oneof fields always encode even if set to the zero value,
|
||||
// which normally are not encoded in proto3.
|
||||
switch fd.Kind() {
|
||||
|
|
|
@ -167,6 +167,7 @@ func aberrantLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor {
|
|||
ed := &filedesc.Enum{L2: new(filedesc.EnumL2)}
|
||||
ed.L0.FullName = AberrantDeriveFullName(t) // e.g., github_com.user.repo.MyEnum
|
||||
ed.L0.ParentFile = filedesc.SurrogateProto3
|
||||
ed.L1.EditionFeatures = ed.L0.ParentFile.L1.EditionFeatures
|
||||
ed.L2.Values.List = append(ed.L2.Values.List, filedesc.EnumValue{})
|
||||
|
||||
// TODO: Use the presence of a UnmarshalJSON method to determine proto2?
|
||||
|
|
|
@ -118,7 +118,7 @@ func (xi *ExtensionInfo) initFromLegacy() {
|
|||
xd.L1.Number = protoreflect.FieldNumber(xi.Field)
|
||||
xd.L1.Cardinality = fd.L1.Cardinality
|
||||
xd.L1.Kind = fd.L1.Kind
|
||||
xd.L2.IsPacked = fd.L1.IsPacked
|
||||
xd.L1.EditionFeatures = fd.L1.EditionFeatures
|
||||
xd.L2.Default = fd.L1.Default
|
||||
xd.L1.Extendee = Export{}.MessageDescriptorOf(xi.ExtendedType)
|
||||
xd.L2.Enum = ed
|
||||
|
|
|
@ -204,6 +204,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
|
|||
}
|
||||
}
|
||||
|
||||
md.L1.EditionFeatures = md.L0.ParentFile.L1.EditionFeatures
|
||||
// Obtain a list of oneof wrapper types.
|
||||
var oneofWrappers []reflect.Type
|
||||
methods := make([]reflect.Method, 0, 2)
|
||||
|
@ -250,6 +251,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
|
|||
od := &md.L2.Oneofs.List[n]
|
||||
od.L0.FullName = md.FullName().Append(protoreflect.Name(tag))
|
||||
od.L0.ParentFile = md.L0.ParentFile
|
||||
od.L1.EditionFeatures = md.L1.EditionFeatures
|
||||
od.L0.Parent = md
|
||||
od.L0.Index = n
|
||||
|
||||
|
@ -260,6 +262,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
|
|||
aberrantAppendField(md, f.Type, tag, "", "")
|
||||
fd := &md.L2.Fields.List[len(md.L2.Fields.List)-1]
|
||||
fd.L1.ContainingOneof = od
|
||||
fd.L1.EditionFeatures = od.L1.EditionFeatures
|
||||
od.L1.Fields.List = append(od.L1.Fields.List, fd)
|
||||
}
|
||||
}
|
||||
|
@ -307,14 +310,14 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey,
|
|||
fd.L0.Parent = md
|
||||
fd.L0.Index = n
|
||||
|
||||
if fd.L1.IsWeak || fd.L1.HasPacked {
|
||||
if fd.L1.IsWeak || fd.L1.EditionFeatures.IsPacked {
|
||||
fd.L1.Options = func() protoreflect.ProtoMessage {
|
||||
opts := descopts.Field.ProtoReflect().New()
|
||||
if fd.L1.IsWeak {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("weak"), protoreflect.ValueOfBool(true))
|
||||
}
|
||||
if fd.L1.HasPacked {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.IsPacked))
|
||||
if fd.L1.EditionFeatures.IsPacked {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.EditionFeatures.IsPacked))
|
||||
}
|
||||
return opts.Interface()
|
||||
}
|
||||
|
@ -344,6 +347,7 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey,
|
|||
md2.L0.ParentFile = md.L0.ParentFile
|
||||
md2.L0.Parent = md
|
||||
md2.L0.Index = n
|
||||
md2.L1.EditionFeatures = md.L1.EditionFeatures
|
||||
|
||||
md2.L1.IsMapEntry = true
|
||||
md2.L2.Options = func() protoreflect.ProtoMessage {
|
||||
|
|
|
@ -247,11 +247,10 @@ func (m *extensionMap) Range(f func(protoreflect.FieldDescriptor, protoreflect.V
|
|||
}
|
||||
}
|
||||
}
|
||||
func (m *extensionMap) Has(xt protoreflect.ExtensionType) (ok bool) {
|
||||
func (m *extensionMap) Has(xd protoreflect.ExtensionTypeDescriptor) (ok bool) {
|
||||
if m == nil {
|
||||
return false
|
||||
}
|
||||
xd := xt.TypeDescriptor()
|
||||
x, ok := (*m)[int32(xd.Number())]
|
||||
if !ok {
|
||||
return false
|
||||
|
@ -261,25 +260,22 @@ func (m *extensionMap) Has(xt protoreflect.ExtensionType) (ok bool) {
|
|||
return x.Value().List().Len() > 0
|
||||
case xd.IsMap():
|
||||
return x.Value().Map().Len() > 0
|
||||
case xd.Message() != nil:
|
||||
return x.Value().Message().IsValid()
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *extensionMap) Clear(xt protoreflect.ExtensionType) {
|
||||
delete(*m, int32(xt.TypeDescriptor().Number()))
|
||||
func (m *extensionMap) Clear(xd protoreflect.ExtensionTypeDescriptor) {
|
||||
delete(*m, int32(xd.Number()))
|
||||
}
|
||||
func (m *extensionMap) Get(xt protoreflect.ExtensionType) protoreflect.Value {
|
||||
xd := xt.TypeDescriptor()
|
||||
func (m *extensionMap) Get(xd protoreflect.ExtensionTypeDescriptor) protoreflect.Value {
|
||||
if m != nil {
|
||||
if x, ok := (*m)[int32(xd.Number())]; ok {
|
||||
return x.Value()
|
||||
}
|
||||
}
|
||||
return xt.Zero()
|
||||
return xd.Type().Zero()
|
||||
}
|
||||
func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value) {
|
||||
xd := xt.TypeDescriptor()
|
||||
func (m *extensionMap) Set(xd protoreflect.ExtensionTypeDescriptor, v protoreflect.Value) {
|
||||
xt := xd.Type()
|
||||
isValid := true
|
||||
switch {
|
||||
case !xt.IsValidValue(v):
|
||||
|
@ -292,7 +288,7 @@ func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value)
|
|||
isValid = v.Message().IsValid()
|
||||
}
|
||||
if !isValid {
|
||||
panic(fmt.Sprintf("%v: assigning invalid value", xt.TypeDescriptor().FullName()))
|
||||
panic(fmt.Sprintf("%v: assigning invalid value", xd.FullName()))
|
||||
}
|
||||
|
||||
if *m == nil {
|
||||
|
@ -302,16 +298,15 @@ func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value)
|
|||
x.Set(xt, v)
|
||||
(*m)[int32(xd.Number())] = x
|
||||
}
|
||||
func (m *extensionMap) Mutable(xt protoreflect.ExtensionType) protoreflect.Value {
|
||||
xd := xt.TypeDescriptor()
|
||||
func (m *extensionMap) Mutable(xd protoreflect.ExtensionTypeDescriptor) protoreflect.Value {
|
||||
if xd.Kind() != protoreflect.MessageKind && xd.Kind() != protoreflect.GroupKind && !xd.IsList() && !xd.IsMap() {
|
||||
panic("invalid Mutable on field with non-composite type")
|
||||
}
|
||||
if x, ok := (*m)[int32(xd.Number())]; ok {
|
||||
return x.Value()
|
||||
}
|
||||
v := xt.New()
|
||||
m.Set(xt, v)
|
||||
v := xd.Type().New()
|
||||
m.Set(xd, v)
|
||||
return v
|
||||
}
|
||||
|
||||
|
@ -428,7 +423,7 @@ func (m *messageIfaceWrapper) protoUnwrap() interface{} {
|
|||
|
||||
// checkField verifies that the provided field descriptor is valid.
|
||||
// Exactly one of the returned values is populated.
|
||||
func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo, protoreflect.ExtensionType) {
|
||||
func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo, protoreflect.ExtensionTypeDescriptor) {
|
||||
var fi *fieldInfo
|
||||
if n := fd.Number(); 0 < n && int(n) < len(mi.denseFields) {
|
||||
fi = mi.denseFields[n]
|
||||
|
@ -457,7 +452,7 @@ func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo,
|
|||
if !ok {
|
||||
panic(fmt.Sprintf("extension %v does not implement protoreflect.ExtensionTypeDescriptor", fd.FullName()))
|
||||
}
|
||||
return nil, xtd.Type()
|
||||
return nil, xtd
|
||||
}
|
||||
panic(fmt.Sprintf("field %v is invalid", fd.FullName()))
|
||||
}
|
||||
|
|
|
@ -538,6 +538,6 @@ func isZero(v reflect.Value) bool {
|
|||
}
|
||||
return true
|
||||
default:
|
||||
panic(&reflect.ValueError{"reflect.Value.IsZero", v.Kind()})
|
||||
panic(&reflect.ValueError{Method: "reflect.Value.IsZero", Kind: v.Kind()})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,9 @@ func (m *messageState) protoUnwrap() interface{} {
|
|||
return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
|
||||
}
|
||||
func (m *messageState) ProtoMethods() *protoiface.Methods {
|
||||
m.messageInfo().init()
|
||||
return &m.messageInfo().methods
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return &mi.methods
|
||||
}
|
||||
|
||||
// ProtoMessageInfo is a pseudo-internal API for allowing the v1 code
|
||||
|
@ -41,8 +42,9 @@ func (m *messageState) ProtoMessageInfo() *MessageInfo {
|
|||
}
|
||||
|
||||
func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
m.messageInfo().init()
|
||||
for _, ri := range m.messageInfo().rangeInfos {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
for _, ri := range mi.rangeInfos {
|
||||
switch ri := ri.(type) {
|
||||
case *fieldInfo:
|
||||
if ri.has(m.pointer()) {
|
||||
|
@ -52,77 +54,86 @@ func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.V
|
|||
}
|
||||
case *oneofInfo:
|
||||
if n := ri.which(m.pointer()); n > 0 {
|
||||
fi := m.messageInfo().fields[n]
|
||||
fi := mi.fields[n]
|
||||
if !f(fi.fieldDesc, fi.get(m.pointer())) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m.messageInfo().extensionMap(m.pointer()).Range(f)
|
||||
mi.extensionMap(m.pointer()).Range(f)
|
||||
}
|
||||
func (m *messageState) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.has(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Has(xt)
|
||||
return mi.extensionMap(m.pointer()).Has(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Clear(fd protoreflect.FieldDescriptor) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.clear(m.pointer())
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Clear(xt)
|
||||
mi.extensionMap(m.pointer()).Clear(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.get(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Get(xt)
|
||||
return mi.extensionMap(m.pointer()).Get(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.set(m.pointer(), v)
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
|
||||
mi.extensionMap(m.pointer()).Set(xd, v)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.mutable(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
|
||||
return mi.extensionMap(m.pointer()).Mutable(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.newField()
|
||||
} else {
|
||||
return xt.New()
|
||||
return xd.Type().New()
|
||||
}
|
||||
}
|
||||
func (m *messageState) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||
m.messageInfo().init()
|
||||
if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if oi := mi.oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
return od.Fields().ByNumber(oi.which(m.pointer()))
|
||||
}
|
||||
panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m *messageState) GetUnknown() protoreflect.RawFields {
|
||||
m.messageInfo().init()
|
||||
return m.messageInfo().getUnknown(m.pointer())
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return mi.getUnknown(m.pointer())
|
||||
}
|
||||
func (m *messageState) SetUnknown(b protoreflect.RawFields) {
|
||||
m.messageInfo().init()
|
||||
m.messageInfo().setUnknown(m.pointer(), b)
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
mi.setUnknown(m.pointer(), b)
|
||||
}
|
||||
func (m *messageState) IsValid() bool {
|
||||
return !m.pointer().IsNil()
|
||||
|
@ -147,8 +158,9 @@ func (m *messageReflectWrapper) protoUnwrap() interface{} {
|
|||
return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
|
||||
}
|
||||
func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods {
|
||||
m.messageInfo().init()
|
||||
return &m.messageInfo().methods
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return &mi.methods
|
||||
}
|
||||
|
||||
// ProtoMessageInfo is a pseudo-internal API for allowing the v1 code
|
||||
|
@ -161,8 +173,9 @@ func (m *messageReflectWrapper) ProtoMessageInfo() *MessageInfo {
|
|||
}
|
||||
|
||||
func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
m.messageInfo().init()
|
||||
for _, ri := range m.messageInfo().rangeInfos {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
for _, ri := range mi.rangeInfos {
|
||||
switch ri := ri.(type) {
|
||||
case *fieldInfo:
|
||||
if ri.has(m.pointer()) {
|
||||
|
@ -172,77 +185,86 @@ func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, proto
|
|||
}
|
||||
case *oneofInfo:
|
||||
if n := ri.which(m.pointer()); n > 0 {
|
||||
fi := m.messageInfo().fields[n]
|
||||
fi := mi.fields[n]
|
||||
if !f(fi.fieldDesc, fi.get(m.pointer())) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m.messageInfo().extensionMap(m.pointer()).Range(f)
|
||||
mi.extensionMap(m.pointer()).Range(f)
|
||||
}
|
||||
func (m *messageReflectWrapper) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.has(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Has(xt)
|
||||
return mi.extensionMap(m.pointer()).Has(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Clear(fd protoreflect.FieldDescriptor) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.clear(m.pointer())
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Clear(xt)
|
||||
mi.extensionMap(m.pointer()).Clear(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.get(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Get(xt)
|
||||
return mi.extensionMap(m.pointer()).Get(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.set(m.pointer(), v)
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
|
||||
mi.extensionMap(m.pointer()).Set(xd, v)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.mutable(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
|
||||
return mi.extensionMap(m.pointer()).Mutable(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.newField()
|
||||
} else {
|
||||
return xt.New()
|
||||
return xd.Type().New()
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||
m.messageInfo().init()
|
||||
if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if oi := mi.oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
return od.Fields().ByNumber(oi.which(m.pointer()))
|
||||
}
|
||||
panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields {
|
||||
m.messageInfo().init()
|
||||
return m.messageInfo().getUnknown(m.pointer())
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return mi.getUnknown(m.pointer())
|
||||
}
|
||||
func (m *messageReflectWrapper) SetUnknown(b protoreflect.RawFields) {
|
||||
m.messageInfo().init()
|
||||
m.messageInfo().setUnknown(m.pointer(), b)
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
mi.setUnknown(m.pointer(), b)
|
||||
}
|
||||
func (m *messageReflectWrapper) IsValid() bool {
|
||||
return !m.pointer().IsNil()
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
// EnforceUTF8 reports whether to enforce strict UTF-8 validation.
|
||||
func EnforceUTF8(fd protoreflect.FieldDescriptor) bool {
|
||||
if flags.ProtoLegacy {
|
||||
if flags.ProtoLegacy || fd.Syntax() == protoreflect.Editions {
|
||||
if fd, ok := fd.(interface{ EnforceUTF8() bool }); ok {
|
||||
return fd.EnforceUTF8()
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ import (
|
|||
// 10. Send out the CL for review and submit it.
|
||||
const (
|
||||
Major = 1
|
||||
Minor = 32
|
||||
Minor = 33
|
||||
Patch = 0
|
||||
PreRelease = ""
|
||||
PreRelease = "devel"
|
||||
)
|
||||
|
||||
// String formats the version string for this module in semver format.
|
||||
|
|
|
@ -51,6 +51,8 @@ type UnmarshalOptions struct {
|
|||
|
||||
// Unmarshal parses the wire-format message in b and places the result in m.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
//
|
||||
// See the [UnmarshalOptions] type if you need more control.
|
||||
func Unmarshal(b []byte, m Message) error {
|
||||
_, err := UnmarshalOptions{RecursionLimit: protowire.DefaultRecursionLimit}.unmarshal(b, m.ProtoReflect())
|
||||
return err
|
||||
|
|
|
@ -71,6 +71,10 @@ type MarshalOptions struct {
|
|||
}
|
||||
|
||||
// Marshal returns the wire-format encoding of m.
|
||||
//
|
||||
// This is the most common entry point for encoding a Protobuf message.
|
||||
//
|
||||
// See the [MarshalOptions] type if you need more control.
|
||||
func Marshal(m Message) ([]byte, error) {
|
||||
// Treat nil message interface as an empty message; nothing to output.
|
||||
if m == nil {
|
||||
|
@ -116,6 +120,9 @@ func emptyBytesForMessage(m Message) []byte {
|
|||
|
||||
// MarshalAppend appends the wire-format encoding of m to b,
|
||||
// returning the result.
|
||||
//
|
||||
// This is a less common entry point than [Marshal], which is only needed if you
|
||||
// need to supply your own buffers for performance reasons.
|
||||
func (o MarshalOptions) MarshalAppend(b []byte, m Message) ([]byte, error) {
|
||||
// Treat nil message interface as an empty message; nothing to append.
|
||||
if m == nil {
|
||||
|
|
|
@ -11,18 +11,21 @@ import (
|
|||
// HasExtension reports whether an extension field is populated.
|
||||
// It returns false if m is invalid or if xt does not extend m.
|
||||
func HasExtension(m Message, xt protoreflect.ExtensionType) bool {
|
||||
// Treat nil message interface as an empty message; no populated fields.
|
||||
if m == nil {
|
||||
// Treat nil message interface or descriptor as an empty message; no populated
|
||||
// fields.
|
||||
if m == nil || xt == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// As a special-case, we reports invalid or mismatching descriptors
|
||||
// as always not being populated (since they aren't).
|
||||
if xt == nil || m.ProtoReflect().Descriptor() != xt.TypeDescriptor().ContainingMessage() {
|
||||
mr := m.ProtoReflect()
|
||||
xd := xt.TypeDescriptor()
|
||||
if mr.Descriptor() != xd.ContainingMessage() {
|
||||
return false
|
||||
}
|
||||
|
||||
return m.ProtoReflect().Has(xt.TypeDescriptor())
|
||||
return mr.Has(xd)
|
||||
}
|
||||
|
||||
// ClearExtension clears an extension field such that subsequent
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
package protodesc
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/internal/editionssupport"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
|
@ -91,15 +92,17 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
|
|||
switch fd.GetSyntax() {
|
||||
case "proto2", "":
|
||||
f.L1.Syntax = protoreflect.Proto2
|
||||
f.L1.Edition = filedesc.EditionProto2
|
||||
case "proto3":
|
||||
f.L1.Syntax = protoreflect.Proto3
|
||||
f.L1.Edition = filedesc.EditionProto3
|
||||
case "editions":
|
||||
f.L1.Syntax = protoreflect.Editions
|
||||
f.L1.Edition = fromEditionProto(fd.GetEdition())
|
||||
default:
|
||||
return nil, errors.New("invalid syntax: %q", fd.GetSyntax())
|
||||
}
|
||||
if f.L1.Syntax == protoreflect.Editions && (fd.GetEdition() < SupportedEditionsMinimum || fd.GetEdition() > SupportedEditionsMaximum) {
|
||||
if f.L1.Syntax == protoreflect.Editions && (fd.GetEdition() < editionssupport.Minimum || fd.GetEdition() > editionssupport.Maximum) {
|
||||
return nil, errors.New("use of edition %v not yet supported by the Go Protobuf runtime", fd.GetEdition())
|
||||
}
|
||||
f.L1.Path = fd.GetName()
|
||||
|
@ -114,9 +117,7 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
|
|||
opts = proto.Clone(opts).(*descriptorpb.FileOptions)
|
||||
f.L2.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
}
|
||||
if f.L1.Syntax == protoreflect.Editions {
|
||||
initFileDescFromFeatureSet(f, fd.GetOptions().GetFeatures())
|
||||
}
|
||||
initFileDescFromFeatureSet(f, fd.GetOptions().GetFeatures())
|
||||
|
||||
f.L2.Imports = make(filedesc.FileImports, len(fd.GetDependency()))
|
||||
for _, i := range fd.GetPublicDependency() {
|
||||
|
@ -219,10 +220,10 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
|
|||
if err := validateEnumDeclarations(f.L1.Enums.List, fd.GetEnumType()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := validateMessageDeclarations(f.L1.Messages.List, fd.GetMessageType()); err != nil {
|
||||
if err := validateMessageDeclarations(f, f.L1.Messages.List, fd.GetMessageType()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := validateExtensionDeclarations(f.L1.Extensions.List, fd.GetExtension()); err != nil {
|
||||
if err := validateExtensionDeclarations(f, f.L1.Extensions.List, fd.GetExtension()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ func (r descsByName) initEnumDeclarations(eds []*descriptorpb.EnumDescriptorProt
|
|||
opts = proto.Clone(opts).(*descriptorpb.EnumOptions)
|
||||
e.L2.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
}
|
||||
e.L1.EditionFeatures = mergeEditionFeatures(parent, ed.GetOptions().GetFeatures())
|
||||
for _, s := range ed.GetReservedName() {
|
||||
e.L2.ReservedNames.List = append(e.L2.ReservedNames.List, protoreflect.Name(s))
|
||||
}
|
||||
|
@ -68,6 +69,7 @@ func (r descsByName) initMessagesDeclarations(mds []*descriptorpb.DescriptorProt
|
|||
if m.L0, err = r.makeBase(m, parent, md.GetName(), i, sb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.L1.EditionFeatures = mergeEditionFeatures(parent, md.GetOptions().GetFeatures())
|
||||
if opts := md.GetOptions(); opts != nil {
|
||||
opts = proto.Clone(opts).(*descriptorpb.MessageOptions)
|
||||
m.L2.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
|
@ -114,6 +116,27 @@ func (r descsByName) initMessagesDeclarations(mds []*descriptorpb.DescriptorProt
|
|||
return ms, nil
|
||||
}
|
||||
|
||||
// canBePacked returns whether the field can use packed encoding:
|
||||
// https://protobuf.dev/programming-guides/encoding/#packed
|
||||
func canBePacked(fd *descriptorpb.FieldDescriptorProto) bool {
|
||||
if fd.GetLabel() != descriptorpb.FieldDescriptorProto_LABEL_REPEATED {
|
||||
return false // not a repeated field
|
||||
}
|
||||
|
||||
switch protoreflect.Kind(fd.GetType()) {
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
return false // not a scalar type field
|
||||
|
||||
case protoreflect.StringKind, protoreflect.BytesKind:
|
||||
// string and bytes can explicitly not be declared as packed,
|
||||
// see https://protobuf.dev/programming-guides/encoding/#packed
|
||||
return false
|
||||
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (fs []filedesc.Field, err error) {
|
||||
fs = make([]filedesc.Field, len(fds)) // allocate up-front to ensure stable pointers
|
||||
for i, fd := range fds {
|
||||
|
@ -121,13 +144,15 @@ func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDesc
|
|||
if f.L0, err = r.makeBase(f, parent, fd.GetName(), i, sb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f.L1.EditionFeatures = mergeEditionFeatures(parent, fd.GetOptions().GetFeatures())
|
||||
f.L1.IsProto3Optional = fd.GetProto3Optional()
|
||||
if opts := fd.GetOptions(); opts != nil {
|
||||
opts = proto.Clone(opts).(*descriptorpb.FieldOptions)
|
||||
f.L1.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
f.L1.IsWeak = opts.GetWeak()
|
||||
f.L1.HasPacked = opts.Packed != nil
|
||||
f.L1.IsPacked = opts.GetPacked()
|
||||
if opts.Packed != nil {
|
||||
f.L1.EditionFeatures.IsPacked = opts.GetPacked()
|
||||
}
|
||||
}
|
||||
f.L1.Number = protoreflect.FieldNumber(fd.GetNumber())
|
||||
f.L1.Cardinality = protoreflect.Cardinality(fd.GetLabel())
|
||||
|
@ -138,28 +163,12 @@ func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDesc
|
|||
f.L1.StringName.InitJSON(fd.GetJsonName())
|
||||
}
|
||||
|
||||
if f.Base.L0.ParentFile.Syntax() == protoreflect.Editions {
|
||||
f.L1.Presence = resolveFeatureHasFieldPresence(f.Base.L0.ParentFile, fd)
|
||||
// We reuse the existing field because the old option `[packed =
|
||||
// true]` is mutually exclusive with the editions feature.
|
||||
if fd.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED {
|
||||
f.L1.HasPacked = true
|
||||
f.L1.IsPacked = resolveFeatureRepeatedFieldEncodingPacked(f.Base.L0.ParentFile, fd)
|
||||
}
|
||||
if f.L1.EditionFeatures.IsLegacyRequired {
|
||||
f.L1.Cardinality = protoreflect.Required
|
||||
}
|
||||
|
||||
// We pretend this option is always explicitly set because the only
|
||||
// use of HasEnforceUTF8 is to determine whether to use EnforceUTF8
|
||||
// or to return the appropriate default.
|
||||
// When using editions we either parse the option or resolve the
|
||||
// appropriate default here (instead of later when this option is
|
||||
// requested from the descriptor).
|
||||
// In proto2/proto3 syntax HasEnforceUTF8 might be false.
|
||||
f.L1.HasEnforceUTF8 = true
|
||||
f.L1.EnforceUTF8 = resolveFeatureEnforceUTF8(f.Base.L0.ParentFile, fd)
|
||||
|
||||
if f.L1.Kind == protoreflect.MessageKind && resolveFeatureDelimitedEncoding(f.Base.L0.ParentFile, fd) {
|
||||
f.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
if f.L1.Kind == protoreflect.MessageKind && f.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
f.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
}
|
||||
return fs, nil
|
||||
|
@ -172,6 +181,7 @@ func (r descsByName) initOneofsFromDescriptorProto(ods []*descriptorpb.OneofDesc
|
|||
if o.L0, err = r.makeBase(o, parent, od.GetName(), i, sb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
o.L1.EditionFeatures = mergeEditionFeatures(parent, od.GetOptions().GetFeatures())
|
||||
if opts := od.GetOptions(); opts != nil {
|
||||
opts = proto.Clone(opts).(*descriptorpb.OneofOptions)
|
||||
o.L1.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
|
@ -191,7 +201,9 @@ func (r descsByName) initExtensionDeclarations(xds []*descriptorpb.FieldDescript
|
|||
if opts := xd.GetOptions(); opts != nil {
|
||||
opts = proto.Clone(opts).(*descriptorpb.FieldOptions)
|
||||
x.L2.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
x.L2.IsPacked = opts.GetPacked()
|
||||
if opts.Packed != nil {
|
||||
x.L1.EditionFeatures.IsPacked = opts.GetPacked()
|
||||
}
|
||||
}
|
||||
x.L1.Number = protoreflect.FieldNumber(xd.GetNumber())
|
||||
x.L1.Cardinality = protoreflect.Cardinality(xd.GetLabel())
|
||||
|
|
|
@ -276,8 +276,8 @@ func unmarshalDefault(s string, fd protoreflect.FieldDescriptor, allowUnresolvab
|
|||
} else if err != nil {
|
||||
return v, ev, err
|
||||
}
|
||||
if fd.Syntax() == protoreflect.Proto3 {
|
||||
return v, ev, errors.New("cannot be specified under proto3 semantics")
|
||||
if !fd.HasPresence() {
|
||||
return v, ev, errors.New("cannot be specified with implicit field presence")
|
||||
}
|
||||
if fd.Kind() == protoreflect.MessageKind || fd.Kind() == protoreflect.GroupKind || fd.Cardinality() == protoreflect.Repeated {
|
||||
return v, ev, errors.New("cannot be specified on composite types")
|
||||
|
|
|
@ -45,11 +45,11 @@ func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescri
|
|||
if allowAlias && !foundAlias {
|
||||
return errors.New("enum %q allows aliases, but none were found", e.FullName())
|
||||
}
|
||||
if e.Syntax() == protoreflect.Proto3 {
|
||||
if !e.IsClosed() {
|
||||
if v := e.Values().Get(0); v.Number() != 0 {
|
||||
return errors.New("enum %q using proto3 semantics must have zero number for the first value", v.FullName())
|
||||
return errors.New("enum %q using open semantics must have zero number for the first value", v.FullName())
|
||||
}
|
||||
// Verify that value names in proto3 do not conflict if the
|
||||
// Verify that value names in open enums do not conflict if the
|
||||
// case-insensitive prefix is removed.
|
||||
// See protoc v3.8.0: src/google/protobuf/descriptor.cc:4991-5055
|
||||
names := map[string]protoreflect.EnumValueDescriptor{}
|
||||
|
@ -58,7 +58,7 @@ func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescri
|
|||
v1 := e.Values().Get(i)
|
||||
s := strs.EnumValueName(strs.TrimEnumPrefix(string(v1.Name()), prefix))
|
||||
if v2, ok := names[s]; ok && v1.Number() != v2.Number() {
|
||||
return errors.New("enum %q using proto3 semantics has conflict: %q with %q", e.FullName(), v1.Name(), v2.Name())
|
||||
return errors.New("enum %q using open semantics has conflict: %q with %q", e.FullName(), v1.Name(), v2.Name())
|
||||
}
|
||||
names[s] = v1
|
||||
}
|
||||
|
@ -80,7 +80,9 @@ func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescri
|
|||
return nil
|
||||
}
|
||||
|
||||
func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.DescriptorProto) error {
|
||||
func validateMessageDeclarations(file *filedesc.File, ms []filedesc.Message, mds []*descriptorpb.DescriptorProto) error {
|
||||
// There are a few limited exceptions only for proto3
|
||||
isProto3 := file.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3)
|
||||
for i, md := range mds {
|
||||
m := &ms[i]
|
||||
|
||||
|
@ -107,10 +109,10 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc
|
|||
if isMessageSet && !flags.ProtoLegacy {
|
||||
return errors.New("message %q is a MessageSet, which is a legacy proto1 feature that is no longer supported", m.FullName())
|
||||
}
|
||||
if isMessageSet && (m.Syntax() != protoreflect.Proto2 || m.Fields().Len() > 0 || m.ExtensionRanges().Len() == 0) {
|
||||
if isMessageSet && (isProto3 || m.Fields().Len() > 0 || m.ExtensionRanges().Len() == 0) {
|
||||
return errors.New("message %q is an invalid proto1 MessageSet", m.FullName())
|
||||
}
|
||||
if m.Syntax() == protoreflect.Proto3 {
|
||||
if isProto3 {
|
||||
if m.ExtensionRanges().Len() > 0 {
|
||||
return errors.New("message %q using proto3 semantics cannot have extension ranges", m.FullName())
|
||||
}
|
||||
|
@ -149,7 +151,7 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc
|
|||
return errors.New("message field %q may not have extendee: %q", f.FullName(), fd.GetExtendee())
|
||||
}
|
||||
if f.L1.IsProto3Optional {
|
||||
if f.Syntax() != protoreflect.Proto3 {
|
||||
if !isProto3 {
|
||||
return errors.New("message field %q under proto3 optional semantics must be specified in the proto3 syntax", f.FullName())
|
||||
}
|
||||
if f.Cardinality() != protoreflect.Optional {
|
||||
|
@ -162,26 +164,29 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc
|
|||
if f.IsWeak() && !flags.ProtoLegacy {
|
||||
return errors.New("message field %q is a weak field, which is a legacy proto1 feature that is no longer supported", f.FullName())
|
||||
}
|
||||
if f.IsWeak() && (f.Syntax() != protoreflect.Proto2 || !isOptionalMessage(f) || f.ContainingOneof() != nil) {
|
||||
if f.IsWeak() && (!f.HasPresence() || !isOptionalMessage(f) || f.ContainingOneof() != nil) {
|
||||
return errors.New("message field %q may only be weak for an optional message", f.FullName())
|
||||
}
|
||||
if f.IsPacked() && !isPackable(f) {
|
||||
return errors.New("message field %q is not packable", f.FullName())
|
||||
}
|
||||
if err := checkValidGroup(f); err != nil {
|
||||
if err := checkValidGroup(file, f); err != nil {
|
||||
return errors.New("message field %q is an invalid group: %v", f.FullName(), err)
|
||||
}
|
||||
if err := checkValidMap(f); err != nil {
|
||||
return errors.New("message field %q is an invalid map: %v", f.FullName(), err)
|
||||
}
|
||||
if f.Syntax() == protoreflect.Proto3 {
|
||||
if isProto3 {
|
||||
if f.Cardinality() == protoreflect.Required {
|
||||
return errors.New("message field %q using proto3 semantics cannot be required", f.FullName())
|
||||
}
|
||||
if f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().Syntax() != protoreflect.Proto3 {
|
||||
return errors.New("message field %q using proto3 semantics may only depend on a proto3 enum", f.FullName())
|
||||
if f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().IsClosed() {
|
||||
return errors.New("message field %q using proto3 semantics may only depend on open enums", f.FullName())
|
||||
}
|
||||
}
|
||||
if f.Cardinality() == protoreflect.Optional && !f.HasPresence() && f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().IsClosed() {
|
||||
return errors.New("message field %q with implicit presence may only use open enums", f.FullName())
|
||||
}
|
||||
}
|
||||
seenSynthetic := false // synthetic oneofs for proto3 optional must come after real oneofs
|
||||
for j := range md.GetOneofDecl() {
|
||||
|
@ -215,17 +220,17 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc
|
|||
if err := validateEnumDeclarations(m.L1.Enums.List, md.GetEnumType()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateMessageDeclarations(m.L1.Messages.List, md.GetNestedType()); err != nil {
|
||||
if err := validateMessageDeclarations(file, m.L1.Messages.List, md.GetNestedType()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateExtensionDeclarations(m.L1.Extensions.List, md.GetExtension()); err != nil {
|
||||
if err := validateExtensionDeclarations(file, m.L1.Extensions.List, md.GetExtension()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateExtensionDeclarations(xs []filedesc.Extension, xds []*descriptorpb.FieldDescriptorProto) error {
|
||||
func validateExtensionDeclarations(f *filedesc.File, xs []filedesc.Extension, xds []*descriptorpb.FieldDescriptorProto) error {
|
||||
for i, xd := range xds {
|
||||
x := &xs[i]
|
||||
// NOTE: Avoid using the IsValid method since extensions to MessageSet
|
||||
|
@ -267,13 +272,13 @@ func validateExtensionDeclarations(xs []filedesc.Extension, xds []*descriptorpb.
|
|||
if x.IsPacked() && !isPackable(x) {
|
||||
return errors.New("extension field %q is not packable", x.FullName())
|
||||
}
|
||||
if err := checkValidGroup(x); err != nil {
|
||||
if err := checkValidGroup(f, x); err != nil {
|
||||
return errors.New("extension field %q is an invalid group: %v", x.FullName(), err)
|
||||
}
|
||||
if md := x.Message(); md != nil && md.IsMapEntry() {
|
||||
return errors.New("extension field %q cannot be a map entry", x.FullName())
|
||||
}
|
||||
if x.Syntax() == protoreflect.Proto3 {
|
||||
if f.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3) {
|
||||
switch x.ContainingMessage().FullName() {
|
||||
case (*descriptorpb.FileOptions)(nil).ProtoReflect().Descriptor().FullName():
|
||||
case (*descriptorpb.EnumOptions)(nil).ProtoReflect().Descriptor().FullName():
|
||||
|
@ -309,21 +314,25 @@ func isPackable(fd protoreflect.FieldDescriptor) bool {
|
|||
|
||||
// checkValidGroup reports whether fd is a valid group according to the same
|
||||
// rules that protoc imposes.
|
||||
func checkValidGroup(fd protoreflect.FieldDescriptor) error {
|
||||
func checkValidGroup(f *filedesc.File, fd protoreflect.FieldDescriptor) error {
|
||||
md := fd.Message()
|
||||
switch {
|
||||
case fd.Kind() != protoreflect.GroupKind:
|
||||
return nil
|
||||
case fd.Syntax() != protoreflect.Proto2:
|
||||
return errors.New("invalid under proto2 semantics")
|
||||
case f.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3):
|
||||
return errors.New("invalid under proto3 semantics")
|
||||
case md == nil || md.IsPlaceholder():
|
||||
return errors.New("message must be resolvable")
|
||||
case fd.FullName().Parent() != md.FullName().Parent():
|
||||
return errors.New("message and field must be declared in the same scope")
|
||||
case !unicode.IsUpper(rune(md.Name()[0])):
|
||||
return errors.New("message name must start with an uppercase")
|
||||
case fd.Name() != protoreflect.Name(strings.ToLower(string(md.Name()))):
|
||||
return errors.New("field name must be lowercased form of the message name")
|
||||
}
|
||||
if f.L1.Edition < fromEditionProto(descriptorpb.Edition_EDITION_2023) {
|
||||
switch {
|
||||
case fd.FullName().Parent() != md.FullName().Parent():
|
||||
return errors.New("message and field must be declared in the same scope")
|
||||
case !unicode.IsUpper(rune(md.Name()[0])):
|
||||
return errors.New("message name must start with an uppercase")
|
||||
case fd.Name() != protoreflect.Name(strings.ToLower(string(md.Name()))):
|
||||
return errors.New("field name must be lowercased form of the message name")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,29 +5,24 @@
|
|||
package protodesc
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/internal/editiondefaults"
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/types/descriptorpb"
|
||||
gofeaturespb "google.golang.org/protobuf/types/gofeaturespb"
|
||||
)
|
||||
|
||||
const (
|
||||
SupportedEditionsMinimum = descriptorpb.Edition_EDITION_PROTO2
|
||||
SupportedEditionsMaximum = descriptorpb.Edition_EDITION_2023
|
||||
)
|
||||
|
||||
//go:embed editions_defaults.binpb
|
||||
var binaryEditionDefaults []byte
|
||||
var defaults = &descriptorpb.FeatureSetDefaults{}
|
||||
var defaultsCacheMu sync.Mutex
|
||||
var defaultsCache = make(map[filedesc.Edition]*descriptorpb.FeatureSet)
|
||||
|
||||
func init() {
|
||||
err := proto.Unmarshal(binaryEditionDefaults, defaults)
|
||||
err := proto.Unmarshal(editiondefaults.Defaults, defaults)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unmarshal editions defaults: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
@ -83,37 +78,56 @@ func getFeatureSetFor(ed filedesc.Edition) *descriptorpb.FeatureSet {
|
|||
return fs
|
||||
}
|
||||
|
||||
func resolveFeatureHasFieldPresence(fileDesc *filedesc.File, fieldDesc *descriptorpb.FieldDescriptorProto) bool {
|
||||
fs := fieldDesc.GetOptions().GetFeatures()
|
||||
if fs == nil || fs.FieldPresence == nil {
|
||||
return fileDesc.L1.EditionFeatures.IsFieldPresence
|
||||
// mergeEditionFeatures merges the parent and child feature sets. This function
|
||||
// should be used when initializing Go descriptors from descriptor protos which
|
||||
// is why the parent is a filedesc.EditionsFeatures (Go representation) while
|
||||
// the child is a descriptorproto.FeatureSet (protoc representation).
|
||||
// Any feature set by the child overwrites what is set by the parent.
|
||||
func mergeEditionFeatures(parentDesc protoreflect.Descriptor, child *descriptorpb.FeatureSet) filedesc.EditionFeatures {
|
||||
var parentFS filedesc.EditionFeatures
|
||||
switch p := parentDesc.(type) {
|
||||
case *filedesc.File:
|
||||
parentFS = p.L1.EditionFeatures
|
||||
case *filedesc.Message:
|
||||
parentFS = p.L1.EditionFeatures
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown parent type %T", parentDesc))
|
||||
}
|
||||
if child == nil {
|
||||
return parentFS
|
||||
}
|
||||
if fp := child.FieldPresence; fp != nil {
|
||||
parentFS.IsFieldPresence = *fp == descriptorpb.FeatureSet_LEGACY_REQUIRED ||
|
||||
*fp == descriptorpb.FeatureSet_EXPLICIT
|
||||
parentFS.IsLegacyRequired = *fp == descriptorpb.FeatureSet_LEGACY_REQUIRED
|
||||
}
|
||||
if et := child.EnumType; et != nil {
|
||||
parentFS.IsOpenEnum = *et == descriptorpb.FeatureSet_OPEN
|
||||
}
|
||||
return fs.GetFieldPresence() == descriptorpb.FeatureSet_LEGACY_REQUIRED ||
|
||||
fs.GetFieldPresence() == descriptorpb.FeatureSet_EXPLICIT
|
||||
}
|
||||
|
||||
func resolveFeatureRepeatedFieldEncodingPacked(fileDesc *filedesc.File, fieldDesc *descriptorpb.FieldDescriptorProto) bool {
|
||||
fs := fieldDesc.GetOptions().GetFeatures()
|
||||
if fs == nil || fs.RepeatedFieldEncoding == nil {
|
||||
return fileDesc.L1.EditionFeatures.IsPacked
|
||||
if rfe := child.RepeatedFieldEncoding; rfe != nil {
|
||||
parentFS.IsPacked = *rfe == descriptorpb.FeatureSet_PACKED
|
||||
}
|
||||
return fs.GetRepeatedFieldEncoding() == descriptorpb.FeatureSet_PACKED
|
||||
}
|
||||
|
||||
func resolveFeatureEnforceUTF8(fileDesc *filedesc.File, fieldDesc *descriptorpb.FieldDescriptorProto) bool {
|
||||
fs := fieldDesc.GetOptions().GetFeatures()
|
||||
if fs == nil || fs.Utf8Validation == nil {
|
||||
return fileDesc.L1.EditionFeatures.IsUTF8Validated
|
||||
if utf8val := child.Utf8Validation; utf8val != nil {
|
||||
parentFS.IsUTF8Validated = *utf8val == descriptorpb.FeatureSet_VERIFY
|
||||
}
|
||||
return fs.GetUtf8Validation() == descriptorpb.FeatureSet_VERIFY
|
||||
}
|
||||
|
||||
func resolveFeatureDelimitedEncoding(fileDesc *filedesc.File, fieldDesc *descriptorpb.FieldDescriptorProto) bool {
|
||||
fs := fieldDesc.GetOptions().GetFeatures()
|
||||
if fs == nil || fs.MessageEncoding == nil {
|
||||
return fileDesc.L1.EditionFeatures.IsDelimitedEncoded
|
||||
if me := child.MessageEncoding; me != nil {
|
||||
parentFS.IsDelimitedEncoded = *me == descriptorpb.FeatureSet_DELIMITED
|
||||
}
|
||||
return fs.GetMessageEncoding() == descriptorpb.FeatureSet_DELIMITED
|
||||
|
||||
if jf := child.JsonFormat; jf != nil {
|
||||
parentFS.IsJSONCompliant = *jf == descriptorpb.FeatureSet_ALLOW
|
||||
}
|
||||
|
||||
if goFeatures, ok := proto.GetExtension(child, gofeaturespb.E_Go).(*gofeaturespb.GoFeatures); ok && goFeatures != nil {
|
||||
if luje := goFeatures.LegacyUnmarshalJsonEnum; luje != nil {
|
||||
parentFS.GenerateLegacyUnmarshalJSON = *luje
|
||||
}
|
||||
}
|
||||
|
||||
return parentFS
|
||||
}
|
||||
|
||||
// initFileDescFromFeatureSet initializes editions related fields in fd based
|
||||
|
@ -122,56 +136,8 @@ func resolveFeatureDelimitedEncoding(fileDesc *filedesc.File, fieldDesc *descrip
|
|||
// before calling this function.
|
||||
func initFileDescFromFeatureSet(fd *filedesc.File, fs *descriptorpb.FeatureSet) {
|
||||
dfs := getFeatureSetFor(fd.L1.Edition)
|
||||
if fs == nil {
|
||||
fs = &descriptorpb.FeatureSet{}
|
||||
}
|
||||
|
||||
var fieldPresence descriptorpb.FeatureSet_FieldPresence
|
||||
if fp := fs.FieldPresence; fp != nil {
|
||||
fieldPresence = *fp
|
||||
} else {
|
||||
fieldPresence = *dfs.FieldPresence
|
||||
}
|
||||
fd.L1.EditionFeatures.IsFieldPresence = fieldPresence == descriptorpb.FeatureSet_LEGACY_REQUIRED ||
|
||||
fieldPresence == descriptorpb.FeatureSet_EXPLICIT
|
||||
|
||||
var enumType descriptorpb.FeatureSet_EnumType
|
||||
if et := fs.EnumType; et != nil {
|
||||
enumType = *et
|
||||
} else {
|
||||
enumType = *dfs.EnumType
|
||||
}
|
||||
fd.L1.EditionFeatures.IsOpenEnum = enumType == descriptorpb.FeatureSet_OPEN
|
||||
|
||||
var respeatedFieldEncoding descriptorpb.FeatureSet_RepeatedFieldEncoding
|
||||
if rfe := fs.RepeatedFieldEncoding; rfe != nil {
|
||||
respeatedFieldEncoding = *rfe
|
||||
} else {
|
||||
respeatedFieldEncoding = *dfs.RepeatedFieldEncoding
|
||||
}
|
||||
fd.L1.EditionFeatures.IsPacked = respeatedFieldEncoding == descriptorpb.FeatureSet_PACKED
|
||||
|
||||
var isUTF8Validated descriptorpb.FeatureSet_Utf8Validation
|
||||
if utf8val := fs.Utf8Validation; utf8val != nil {
|
||||
isUTF8Validated = *utf8val
|
||||
} else {
|
||||
isUTF8Validated = *dfs.Utf8Validation
|
||||
}
|
||||
fd.L1.EditionFeatures.IsUTF8Validated = isUTF8Validated == descriptorpb.FeatureSet_VERIFY
|
||||
|
||||
var messageEncoding descriptorpb.FeatureSet_MessageEncoding
|
||||
if me := fs.MessageEncoding; me != nil {
|
||||
messageEncoding = *me
|
||||
} else {
|
||||
messageEncoding = *dfs.MessageEncoding
|
||||
}
|
||||
fd.L1.EditionFeatures.IsDelimitedEncoded = messageEncoding == descriptorpb.FeatureSet_DELIMITED
|
||||
|
||||
var jsonFormat descriptorpb.FeatureSet_JsonFormat
|
||||
if jf := fs.JsonFormat; jf != nil {
|
||||
jsonFormat = *jf
|
||||
} else {
|
||||
jsonFormat = *dfs.JsonFormat
|
||||
}
|
||||
fd.L1.EditionFeatures.IsJSONCompliant = jsonFormat == descriptorpb.FeatureSet_ALLOW
|
||||
// initialize the featureset with the defaults
|
||||
fd.L1.EditionFeatures = mergeEditionFeatures(fd, dfs)
|
||||
// overwrite any options explicitly specified
|
||||
fd.L1.EditionFeatures = mergeEditionFeatures(fd, fs)
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
(0ж
|
||||
(0з
|
||||
(0и ж(и
|
|
@ -73,6 +73,16 @@ func ToFileDescriptorProto(file protoreflect.FileDescriptor) *descriptorpb.FileD
|
|||
if syntax := file.Syntax(); syntax != protoreflect.Proto2 && syntax.IsValid() {
|
||||
p.Syntax = proto.String(file.Syntax().String())
|
||||
}
|
||||
if file.Syntax() == protoreflect.Editions {
|
||||
desc := file
|
||||
if fileImportDesc, ok := file.(protoreflect.FileImport); ok {
|
||||
desc = fileImportDesc.FileDescriptor
|
||||
}
|
||||
|
||||
if editionsInterface, ok := desc.(interface{ Edition() int32 }); ok {
|
||||
p.Edition = descriptorpb.Edition(editionsInterface.Edition()).Enum()
|
||||
}
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
|
@ -153,6 +163,18 @@ func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.Fi
|
|||
if field.Syntax() == protoreflect.Proto3 && field.HasOptionalKeyword() {
|
||||
p.Proto3Optional = proto.Bool(true)
|
||||
}
|
||||
if field.Syntax() == protoreflect.Editions {
|
||||
// Editions have no group keyword, this type is only set so that downstream users continue
|
||||
// treating this as delimited encoding.
|
||||
if p.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP {
|
||||
p.Type = descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum()
|
||||
}
|
||||
// Editions have no required keyword, this label is only set so that downstream users continue
|
||||
// treating it as required.
|
||||
if p.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REQUIRED {
|
||||
p.Label = descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum()
|
||||
}
|
||||
}
|
||||
if field.HasDefault() {
|
||||
def, err := defval.Marshal(field.Default(), field.DefaultEnumValue(), field.Kind(), defval.Descriptor)
|
||||
if err != nil && field.DefaultEnumValue() != nil {
|
||||
|
|
|
@ -161,7 +161,7 @@ const (
|
|||
// IsValid reports whether the syntax is valid.
|
||||
func (s Syntax) IsValid() bool {
|
||||
switch s {
|
||||
case Proto2, Proto3:
|
||||
case Proto2, Proto3, Editions:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
|
@ -175,6 +175,8 @@ func (s Syntax) String() string {
|
|||
return "proto2"
|
||||
case Proto3:
|
||||
return "proto3"
|
||||
case Editions:
|
||||
return "editions"
|
||||
default:
|
||||
return fmt.Sprintf("<unknown:%d>", s)
|
||||
}
|
||||
|
|
|
@ -160,8 +160,6 @@ func (p *SourcePath) appendFileOptions(b []byte) []byte {
|
|||
b = p.appendSingularField(b, "java_generic_services", nil)
|
||||
case 18:
|
||||
b = p.appendSingularField(b, "py_generic_services", nil)
|
||||
case 42:
|
||||
b = p.appendSingularField(b, "php_generic_services", nil)
|
||||
case 23:
|
||||
b = p.appendSingularField(b, "deprecated", nil)
|
||||
case 31:
|
||||
|
|
|
@ -544,6 +544,12 @@ type EnumDescriptor interface {
|
|||
// ReservedRanges is a list of reserved ranges of enum numbers.
|
||||
ReservedRanges() EnumRanges
|
||||
|
||||
// IsClosed reports whether this enum uses closed semantics.
|
||||
// See https://protobuf.dev/programming-guides/enum/#definitions.
|
||||
// Note: the Go protobuf implementation is not spec compliant and treats
|
||||
// all enums as open enums.
|
||||
IsClosed() bool
|
||||
|
||||
isEnumDescriptor
|
||||
}
|
||||
type isEnumDescriptor interface{ ProtoType(EnumDescriptor) }
|
||||
|
|
File diff suppressed because it is too large
Load Diff
177
vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go
generated
vendored
Normal file
177
vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go
generated
vendored
Normal file
|
@ -0,0 +1,177 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2023 Google Inc. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: reflect/protodesc/proto/go_features.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
descriptorpb "google.golang.org/protobuf/types/descriptorpb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
type GoFeatures struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Whether or not to generate the deprecated UnmarshalJSON method for enums.
|
||||
LegacyUnmarshalJsonEnum *bool `protobuf:"varint,1,opt,name=legacy_unmarshal_json_enum,json=legacyUnmarshalJsonEnum" json:"legacy_unmarshal_json_enum,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GoFeatures) Reset() {
|
||||
*x = GoFeatures{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_reflect_protodesc_proto_go_features_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GoFeatures) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GoFeatures) ProtoMessage() {}
|
||||
|
||||
func (x *GoFeatures) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_reflect_protodesc_proto_go_features_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GoFeatures.ProtoReflect.Descriptor instead.
|
||||
func (*GoFeatures) Descriptor() ([]byte, []int) {
|
||||
return file_reflect_protodesc_proto_go_features_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GoFeatures) GetLegacyUnmarshalJsonEnum() bool {
|
||||
if x != nil && x.LegacyUnmarshalJsonEnum != nil {
|
||||
return *x.LegacyUnmarshalJsonEnum
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var file_reflect_protodesc_proto_go_features_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
{
|
||||
ExtendedType: (*descriptorpb.FeatureSet)(nil),
|
||||
ExtensionType: (*GoFeatures)(nil),
|
||||
Field: 1002,
|
||||
Name: "google.protobuf.go",
|
||||
Tag: "bytes,1002,opt,name=go",
|
||||
Filename: "reflect/protodesc/proto/go_features.proto",
|
||||
},
|
||||
}
|
||||
|
||||
// Extension fields to descriptorpb.FeatureSet.
|
||||
var (
|
||||
// optional google.protobuf.GoFeatures go = 1002;
|
||||
E_Go = &file_reflect_protodesc_proto_go_features_proto_extTypes[0]
|
||||
)
|
||||
|
||||
var File_reflect_protodesc_proto_go_features_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_reflect_protodesc_proto_go_features_proto_rawDesc = []byte{
|
||||
0x0a, 0x29, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x64,
|
||||
0x65, 0x73, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x5f, 0x66, 0x65, 0x61,
|
||||
0x74, 0x75, 0x72, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x1a, 0x20, 0x67, 0x6f,
|
||||
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65,
|
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6a,
|
||||
0x0a, 0x0a, 0x47, 0x6f, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x5c, 0x0a, 0x1a,
|
||||
0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x75, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c,
|
||||
0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
|
||||
0x42, 0x1f, 0x88, 0x01, 0x01, 0x98, 0x01, 0x06, 0xa2, 0x01, 0x09, 0x12, 0x04, 0x74, 0x72, 0x75,
|
||||
0x65, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x0a, 0x12, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x18, 0xe7,
|
||||
0x07, 0x52, 0x17, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x55, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68,
|
||||
0x61, 0x6c, 0x4a, 0x73, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x3a, 0x49, 0x0a, 0x02, 0x67, 0x6f,
|
||||
0x12, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x18, 0xea, 0x07,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x6f, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65,
|
||||
0x73, 0x52, 0x02, 0x67, 0x6f, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x62, 0x75, 0x66, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x64, 0x65, 0x73, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
}
|
||||
|
||||
var (
|
||||
file_reflect_protodesc_proto_go_features_proto_rawDescOnce sync.Once
|
||||
file_reflect_protodesc_proto_go_features_proto_rawDescData = file_reflect_protodesc_proto_go_features_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_reflect_protodesc_proto_go_features_proto_rawDescGZIP() []byte {
|
||||
file_reflect_protodesc_proto_go_features_proto_rawDescOnce.Do(func() {
|
||||
file_reflect_protodesc_proto_go_features_proto_rawDescData = protoimpl.X.CompressGZIP(file_reflect_protodesc_proto_go_features_proto_rawDescData)
|
||||
})
|
||||
return file_reflect_protodesc_proto_go_features_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_reflect_protodesc_proto_go_features_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_reflect_protodesc_proto_go_features_proto_goTypes = []interface{}{
|
||||
(*GoFeatures)(nil), // 0: google.protobuf.GoFeatures
|
||||
(*descriptorpb.FeatureSet)(nil), // 1: google.protobuf.FeatureSet
|
||||
}
|
||||
var file_reflect_protodesc_proto_go_features_proto_depIdxs = []int32{
|
||||
1, // 0: google.protobuf.go:extendee -> google.protobuf.FeatureSet
|
||||
0, // 1: google.protobuf.go:type_name -> google.protobuf.GoFeatures
|
||||
2, // [2:2] is the sub-list for method output_type
|
||||
2, // [2:2] is the sub-list for method input_type
|
||||
1, // [1:2] is the sub-list for extension type_name
|
||||
0, // [0:1] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_reflect_protodesc_proto_go_features_proto_init() }
|
||||
func file_reflect_protodesc_proto_go_features_proto_init() {
|
||||
if File_reflect_protodesc_proto_go_features_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_reflect_protodesc_proto_go_features_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GoFeatures); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_reflect_protodesc_proto_go_features_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 1,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_reflect_protodesc_proto_go_features_proto_goTypes,
|
||||
DependencyIndexes: file_reflect_protodesc_proto_go_features_proto_depIdxs,
|
||||
MessageInfos: file_reflect_protodesc_proto_go_features_proto_msgTypes,
|
||||
ExtensionInfos: file_reflect_protodesc_proto_go_features_proto_extTypes,
|
||||
}.Build()
|
||||
File_reflect_protodesc_proto_go_features_proto = out.File
|
||||
file_reflect_protodesc_proto_go_features_proto_rawDesc = nil
|
||||
file_reflect_protodesc_proto_go_features_proto_goTypes = nil
|
||||
file_reflect_protodesc_proto_go_features_proto_depIdxs = nil
|
||||
}
|
28
vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.proto
generated
vendored
Normal file
28
vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.proto
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2023 Google Inc. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package google.protobuf;
|
||||
|
||||
import "google/protobuf/descriptor.proto";
|
||||
|
||||
option go_package = "google.golang.org/protobuf/types/gofeaturespb";
|
||||
|
||||
extend google.protobuf.FeatureSet {
|
||||
optional GoFeatures go = 1002;
|
||||
}
|
||||
|
||||
message GoFeatures {
|
||||
// Whether or not to generate the deprecated UnmarshalJSON method for enums.
|
||||
optional bool legacy_unmarshal_json_enum = 1 [
|
||||
retention = RETENTION_RUNTIME,
|
||||
targets = TARGET_TYPE_ENUM,
|
||||
edition_defaults = { edition: EDITION_PROTO2, value: "true" },
|
||||
edition_defaults = { edition: EDITION_PROTO3, value: "false" }
|
||||
];
|
||||
}
|
|
@ -73,8 +73,8 @@ github.com/gogo/protobuf/sortkeys
|
|||
# github.com/golang/mock v1.6.0
|
||||
## explicit; go 1.11
|
||||
github.com/golang/mock/gomock
|
||||
# github.com/golang/protobuf v1.5.3
|
||||
## explicit; go 1.9
|
||||
# github.com/golang/protobuf v1.5.4
|
||||
## explicit; go 1.17
|
||||
github.com/golang/protobuf/jsonpb
|
||||
github.com/golang/protobuf/proto
|
||||
github.com/golang/protobuf/ptypes
|
||||
|
@ -207,6 +207,8 @@ github.com/robfig/cron/v3
|
|||
# github.com/spaolacci/murmur3 v1.1.0
|
||||
## explicit
|
||||
github.com/spaolacci/murmur3
|
||||
# github.com/stretchr/testify v1.9.0
|
||||
## explicit; go 1.17
|
||||
# github.com/zeromicro/go-zero v1.6.2
|
||||
## explicit; go 1.19
|
||||
github.com/zeromicro/go-zero/core/breaker
|
||||
|
@ -375,7 +377,7 @@ go.uber.org/zap/internal/pool
|
|||
go.uber.org/zap/internal/stacktrace
|
||||
go.uber.org/zap/zapcore
|
||||
go.uber.org/zap/zapgrpc
|
||||
# golang.org/x/crypto v0.18.0
|
||||
# golang.org/x/crypto v0.21.0
|
||||
## explicit; go 1.18
|
||||
golang.org/x/crypto/blowfish
|
||||
golang.org/x/crypto/chacha20
|
||||
|
@ -385,7 +387,7 @@ golang.org/x/crypto/internal/alias
|
|||
golang.org/x/crypto/internal/poly1305
|
||||
golang.org/x/crypto/ssh
|
||||
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
|
||||
# golang.org/x/net v0.20.0
|
||||
# golang.org/x/net v0.22.0
|
||||
## explicit; go 1.18
|
||||
golang.org/x/net/html
|
||||
golang.org/x/net/html/atom
|
||||
|
@ -400,14 +402,16 @@ golang.org/x/net/trace
|
|||
## explicit; go 1.18
|
||||
golang.org/x/oauth2
|
||||
golang.org/x/oauth2/internal
|
||||
# golang.org/x/sys v0.16.0
|
||||
# golang.org/x/sync v0.6.0
|
||||
## explicit; go 1.18
|
||||
# golang.org/x/sys v0.18.0
|
||||
## explicit; go 1.18
|
||||
golang.org/x/sys/cpu
|
||||
golang.org/x/sys/plan9
|
||||
golang.org/x/sys/unix
|
||||
golang.org/x/sys/windows
|
||||
golang.org/x/sys/windows/registry
|
||||
# golang.org/x/term v0.16.0
|
||||
# golang.org/x/term v0.18.0
|
||||
## explicit; go 1.18
|
||||
golang.org/x/term
|
||||
# golang.org/x/text v0.14.0
|
||||
|
@ -500,7 +504,7 @@ google.golang.org/grpc/serviceconfig
|
|||
google.golang.org/grpc/stats
|
||||
google.golang.org/grpc/status
|
||||
google.golang.org/grpc/tap
|
||||
# google.golang.org/protobuf v1.32.0
|
||||
# google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002
|
||||
## explicit; go 1.17
|
||||
google.golang.org/protobuf/encoding/protojson
|
||||
google.golang.org/protobuf/encoding/prototext
|
||||
|
@ -508,6 +512,8 @@ google.golang.org/protobuf/encoding/protowire
|
|||
google.golang.org/protobuf/internal/descfmt
|
||||
google.golang.org/protobuf/internal/descopts
|
||||
google.golang.org/protobuf/internal/detrand
|
||||
google.golang.org/protobuf/internal/editiondefaults
|
||||
google.golang.org/protobuf/internal/editionssupport
|
||||
google.golang.org/protobuf/internal/encoding/defval
|
||||
google.golang.org/protobuf/internal/encoding/json
|
||||
google.golang.org/protobuf/internal/encoding/messageset
|
||||
|
@ -531,6 +537,7 @@ google.golang.org/protobuf/reflect/protoregistry
|
|||
google.golang.org/protobuf/runtime/protoiface
|
||||
google.golang.org/protobuf/runtime/protoimpl
|
||||
google.golang.org/protobuf/types/descriptorpb
|
||||
google.golang.org/protobuf/types/gofeaturespb
|
||||
google.golang.org/protobuf/types/known/anypb
|
||||
google.golang.org/protobuf/types/known/durationpb
|
||||
google.golang.org/protobuf/types/known/fieldmaskpb
|
||||
|
|
Loading…
Reference in New Issue