vendor protobuf & grpc

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2020-02-25 14:27:11 +09:00
parent 9b4967bd6b
commit 8e448bb279
158 changed files with 12967 additions and 10634 deletions

View File

@@ -141,6 +141,7 @@ type size struct {
atleastOne bool
localName string
typesPkg generator.Single
bitsPkg generator.Single
}
func NewSize() *size {
@@ -188,14 +189,7 @@ func keySize(fieldNumber int32, wireType int) int {
func (p *size) sizeVarint() {
p.P(`
func sov`, p.localName, `(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
return (`, p.bitsPkg.Use(), `.Len64(x | 1) + 6)/ 7
}`)
}
@@ -589,6 +583,7 @@ func (p *size) Generate(file *generator.FileDescriptor) {
p.localName = generator.FileName(file)
p.typesPkg = p.NewImport("github.com/gogo/protobuf/types")
protoPkg := p.NewImport("github.com/gogo/protobuf/proto")
p.bitsPkg = p.NewImport("math/bits")
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
protoPkg = p.NewImport("github.com/golang/protobuf/proto")
}