all: Update protobuf package 1.0.0 -> 1.2.0 (#5452)
Also adds a few file global options to keep the generated code similar to what we already had.
This commit is contained in:
@@ -198,7 +198,7 @@ type dependencyRepo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dependencyRepos = []dependencyRepo{
|
var dependencyRepos = []dependencyRepo{
|
||||||
{path: "protobuf", repo: "https://github.com/gogo/protobuf.git", commit: "v1.0.0"},
|
{path: "protobuf", repo: "https://github.com/gogo/protobuf.git", commit: "v1.2.0"},
|
||||||
{path: "xdr", repo: "https://github.com/calmh/xdr.git", commit: "08e072f9cb16"},
|
{path: "xdr", repo: "https://github.com/calmh/xdr.git", commit: "08e072f9cb16"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+127
-63
@@ -1,17 +1,6 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: database.proto
|
// source: database.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package main is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
database.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
DatabaseRecord
|
|
||||||
ReplicationRecord
|
|
||||||
DatabaseAddress
|
|
||||||
*/
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
@@ -33,37 +22,121 @@ var _ = math.Inf
|
|||||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type DatabaseRecord struct {
|
type DatabaseRecord struct {
|
||||||
Addresses []DatabaseAddress `protobuf:"bytes,1,rep,name=addresses" json:"addresses"`
|
Addresses []DatabaseAddress `protobuf:"bytes,1,rep,name=addresses,proto3" json:"addresses"`
|
||||||
Misses int32 `protobuf:"varint,2,opt,name=misses,proto3" json:"misses,omitempty"`
|
Misses int32 `protobuf:"varint,2,opt,name=misses,proto3" json:"misses,omitempty"`
|
||||||
Seen int64 `protobuf:"varint,3,opt,name=seen,proto3" json:"seen,omitempty"`
|
Seen int64 `protobuf:"varint,3,opt,name=seen,proto3" json:"seen,omitempty"`
|
||||||
Missed int64 `protobuf:"varint,4,opt,name=missed,proto3" json:"missed,omitempty"`
|
Missed int64 `protobuf:"varint,4,opt,name=missed,proto3" json:"missed,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *DatabaseRecord) Reset() { *m = DatabaseRecord{} }
|
func (m *DatabaseRecord) Reset() { *m = DatabaseRecord{} }
|
||||||
func (m *DatabaseRecord) String() string { return proto.CompactTextString(m) }
|
func (m *DatabaseRecord) String() string { return proto.CompactTextString(m) }
|
||||||
func (*DatabaseRecord) ProtoMessage() {}
|
func (*DatabaseRecord) ProtoMessage() {}
|
||||||
func (*DatabaseRecord) Descriptor() ([]byte, []int) { return fileDescriptorDatabase, []int{0} }
|
func (*DatabaseRecord) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_database_0f49e029703a04f5, []int{0}
|
||||||
|
}
|
||||||
|
func (m *DatabaseRecord) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *DatabaseRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_DatabaseRecord.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *DatabaseRecord) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_DatabaseRecord.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *DatabaseRecord) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *DatabaseRecord) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_DatabaseRecord.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_DatabaseRecord proto.InternalMessageInfo
|
||||||
|
|
||||||
type ReplicationRecord struct {
|
type ReplicationRecord struct {
|
||||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||||
Addresses []DatabaseAddress `protobuf:"bytes,2,rep,name=addresses" json:"addresses"`
|
Addresses []DatabaseAddress `protobuf:"bytes,2,rep,name=addresses,proto3" json:"addresses"`
|
||||||
Seen int64 `protobuf:"varint,3,opt,name=seen,proto3" json:"seen,omitempty"`
|
Seen int64 `protobuf:"varint,3,opt,name=seen,proto3" json:"seen,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ReplicationRecord) Reset() { *m = ReplicationRecord{} }
|
func (m *ReplicationRecord) Reset() { *m = ReplicationRecord{} }
|
||||||
func (m *ReplicationRecord) String() string { return proto.CompactTextString(m) }
|
func (m *ReplicationRecord) String() string { return proto.CompactTextString(m) }
|
||||||
func (*ReplicationRecord) ProtoMessage() {}
|
func (*ReplicationRecord) ProtoMessage() {}
|
||||||
func (*ReplicationRecord) Descriptor() ([]byte, []int) { return fileDescriptorDatabase, []int{1} }
|
func (*ReplicationRecord) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_database_0f49e029703a04f5, []int{1}
|
||||||
|
}
|
||||||
|
func (m *ReplicationRecord) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *ReplicationRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_ReplicationRecord.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *ReplicationRecord) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_ReplicationRecord.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *ReplicationRecord) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *ReplicationRecord) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_ReplicationRecord.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_ReplicationRecord proto.InternalMessageInfo
|
||||||
|
|
||||||
type DatabaseAddress struct {
|
type DatabaseAddress struct {
|
||||||
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
|
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
|
||||||
Expires int64 `protobuf:"varint,2,opt,name=expires,proto3" json:"expires,omitempty"`
|
Expires int64 `protobuf:"varint,2,opt,name=expires,proto3" json:"expires,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *DatabaseAddress) Reset() { *m = DatabaseAddress{} }
|
func (m *DatabaseAddress) Reset() { *m = DatabaseAddress{} }
|
||||||
func (m *DatabaseAddress) String() string { return proto.CompactTextString(m) }
|
func (m *DatabaseAddress) String() string { return proto.CompactTextString(m) }
|
||||||
func (*DatabaseAddress) ProtoMessage() {}
|
func (*DatabaseAddress) ProtoMessage() {}
|
||||||
func (*DatabaseAddress) Descriptor() ([]byte, []int) { return fileDescriptorDatabase, []int{2} }
|
func (*DatabaseAddress) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_database_0f49e029703a04f5, []int{2}
|
||||||
|
}
|
||||||
|
func (m *DatabaseAddress) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *DatabaseAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_DatabaseAddress.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *DatabaseAddress) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_DatabaseAddress.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *DatabaseAddress) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *DatabaseAddress) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_DatabaseAddress.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_DatabaseAddress proto.InternalMessageInfo
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*DatabaseRecord)(nil), "main.DatabaseRecord")
|
proto.RegisterType((*DatabaseRecord)(nil), "main.DatabaseRecord")
|
||||||
@@ -185,24 +258,6 @@ func (m *DatabaseAddress) MarshalTo(dAtA []byte) (int, error) {
|
|||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeFixed64Database(dAtA []byte, offset int, v uint64) int {
|
|
||||||
dAtA[offset] = uint8(v)
|
|
||||||
dAtA[offset+1] = uint8(v >> 8)
|
|
||||||
dAtA[offset+2] = uint8(v >> 16)
|
|
||||||
dAtA[offset+3] = uint8(v >> 24)
|
|
||||||
dAtA[offset+4] = uint8(v >> 32)
|
|
||||||
dAtA[offset+5] = uint8(v >> 40)
|
|
||||||
dAtA[offset+6] = uint8(v >> 48)
|
|
||||||
dAtA[offset+7] = uint8(v >> 56)
|
|
||||||
return offset + 8
|
|
||||||
}
|
|
||||||
func encodeFixed32Database(dAtA []byte, offset int, v uint32) int {
|
|
||||||
dAtA[offset] = uint8(v)
|
|
||||||
dAtA[offset+1] = uint8(v >> 8)
|
|
||||||
dAtA[offset+2] = uint8(v >> 16)
|
|
||||||
dAtA[offset+3] = uint8(v >> 24)
|
|
||||||
return offset + 4
|
|
||||||
}
|
|
||||||
func encodeVarintDatabase(dAtA []byte, offset int, v uint64) int {
|
func encodeVarintDatabase(dAtA []byte, offset int, v uint64) int {
|
||||||
for v >= 1<<7 {
|
for v >= 1<<7 {
|
||||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||||
@@ -213,6 +268,9 @@ func encodeVarintDatabase(dAtA []byte, offset int, v uint64) int {
|
|||||||
return offset + 1
|
return offset + 1
|
||||||
}
|
}
|
||||||
func (m *DatabaseRecord) Size() (n int) {
|
func (m *DatabaseRecord) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
if len(m.Addresses) > 0 {
|
if len(m.Addresses) > 0 {
|
||||||
@@ -234,6 +292,9 @@ func (m *DatabaseRecord) Size() (n int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *ReplicationRecord) Size() (n int) {
|
func (m *ReplicationRecord) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
l = len(m.Key)
|
l = len(m.Key)
|
||||||
@@ -253,6 +314,9 @@ func (m *ReplicationRecord) Size() (n int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *DatabaseAddress) Size() (n int) {
|
func (m *DatabaseAddress) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
l = len(m.Address)
|
l = len(m.Address)
|
||||||
@@ -748,25 +812,25 @@ var (
|
|||||||
ErrIntOverflowDatabase = fmt.Errorf("proto: integer overflow")
|
ErrIntOverflowDatabase = fmt.Errorf("proto: integer overflow")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { proto.RegisterFile("database.proto", fileDescriptorDatabase) }
|
func init() { proto.RegisterFile("database.proto", fileDescriptor_database_0f49e029703a04f5) }
|
||||||
|
|
||||||
var fileDescriptorDatabase = []byte{
|
var fileDescriptor_database_0f49e029703a04f5 = []byte{
|
||||||
// 258 bytes of a gzipped FileDescriptorProto
|
// 270 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0x49, 0x2c, 0x49,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x90, 0x41, 0x4a, 0xc4, 0x30,
|
||||||
0x4c, 0x4a, 0x2c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xc9, 0x4d, 0xcc, 0xcc,
|
0x18, 0x85, 0x9b, 0x49, 0x1d, 0x99, 0x08, 0xa3, 0x06, 0x94, 0x20, 0x12, 0x4b, 0xdd, 0x74, 0xd5,
|
||||||
0x93, 0x52, 0x2e, 0x4a, 0x2d, 0xc8, 0x2f, 0xd6, 0x07, 0x0b, 0x25, 0x95, 0xa6, 0xe9, 0xa7, 0xe7,
|
0x01, 0x5d, 0xb9, 0x74, 0xd0, 0x0b, 0xe4, 0x06, 0xe9, 0xe4, 0x77, 0x08, 0x3a, 0x4d, 0x49, 0x2a,
|
||||||
0xa7, 0xe7, 0x83, 0x39, 0x60, 0x16, 0x44, 0xa9, 0x52, 0x3f, 0x23, 0x17, 0x9f, 0x0b, 0x54, 0x77,
|
0xe8, 0x29, 0xf4, 0x58, 0x5d, 0xce, 0xd2, 0x95, 0x68, 0x7b, 0x11, 0x69, 0x26, 0x55, 0x14, 0x37,
|
||||||
0x50, 0x6a, 0x72, 0x7e, 0x51, 0x8a, 0x90, 0x25, 0x17, 0x67, 0x62, 0x4a, 0x4a, 0x51, 0x6a, 0x71,
|
0xb3, 0x7b, 0xdf, 0xff, 0xbf, 0x97, 0xbc, 0x84, 0x4c, 0x95, 0xac, 0x65, 0x21, 0x1d, 0xe4, 0x95,
|
||||||
0x71, 0x6a, 0xb1, 0x04, 0xa3, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0xa8, 0x1e, 0xc8, 0x44, 0x3d, 0x98,
|
0x35, 0xb5, 0xa1, 0xf1, 0x4a, 0xea, 0xf2, 0xe4, 0xdc, 0x42, 0x65, 0xdc, 0xcc, 0x8f, 0x8a, 0xc7,
|
||||||
0x42, 0x47, 0x88, 0xb4, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, 0x08, 0xd5, 0x42, 0x62, 0x5c,
|
0xbb, 0xd9, 0xd2, 0x2c, 0x8d, 0x07, 0xaf, 0x36, 0xd6, 0xf4, 0x05, 0x91, 0xe9, 0x4d, 0x48, 0x0b,
|
||||||
0x6c, 0xb9, 0x99, 0x60, 0x7d, 0x4c, 0x0a, 0x8c, 0x1a, 0xac, 0x41, 0x50, 0x9e, 0x90, 0x10, 0x17,
|
0x58, 0x18, 0xab, 0xe8, 0x15, 0x99, 0x48, 0xa5, 0x2c, 0x38, 0x07, 0x8e, 0xa1, 0x04, 0x67, 0x7b,
|
||||||
0x4b, 0x71, 0x6a, 0x6a, 0x9e, 0x04, 0xb3, 0x02, 0xa3, 0x06, 0x73, 0x10, 0x98, 0x0d, 0x57, 0x9b,
|
0x17, 0x47, 0x79, 0x7f, 0x62, 0x3e, 0x18, 0xaf, 0x37, 0xeb, 0x79, 0xdc, 0xbc, 0x9f, 0x45, 0xe2,
|
||||||
0x22, 0xc1, 0x02, 0x16, 0x85, 0xf2, 0x94, 0x4a, 0xb8, 0x04, 0x83, 0x52, 0x0b, 0x72, 0x32, 0x93,
|
0xc7, 0x4d, 0x8f, 0xc9, 0x78, 0xa5, 0x7d, 0x6e, 0x94, 0xa0, 0x6c, 0x47, 0x04, 0xa2, 0x94, 0xc4,
|
||||||
0x13, 0x4b, 0x32, 0xf3, 0xf3, 0xa0, 0x6e, 0x12, 0xe0, 0x62, 0xce, 0x4e, 0xad, 0x94, 0x60, 0x54,
|
0x0e, 0xa0, 0x64, 0x38, 0x41, 0x19, 0x16, 0x5e, 0x7f, 0x7b, 0x15, 0x8b, 0xfd, 0x34, 0x50, 0x5a,
|
||||||
0x60, 0xd4, 0xe0, 0x0c, 0x02, 0x31, 0x51, 0x5d, 0xc9, 0x44, 0x92, 0x2b, 0xb1, 0xb8, 0x46, 0xc9,
|
0x93, 0x43, 0x01, 0xd5, 0x83, 0x5e, 0xc8, 0x5a, 0x9b, 0x32, 0x74, 0x3a, 0x20, 0xf8, 0x1e, 0x9e,
|
||||||
0x95, 0x8b, 0x1f, 0x4d, 0x9f, 0x90, 0x04, 0x17, 0x3b, 0x54, 0x0f, 0xd4, 0x5e, 0x18, 0x17, 0x24,
|
0x19, 0x4a, 0x50, 0x36, 0x11, 0xbd, 0xfc, 0xdd, 0x72, 0xb4, 0x55, 0xcb, 0x7f, 0xda, 0xa4, 0xb7,
|
||||||
0x93, 0x5a, 0x51, 0x90, 0x59, 0x04, 0xf5, 0x27, 0x73, 0x10, 0x8c, 0xeb, 0x24, 0x70, 0xe2, 0xa1,
|
0x64, 0xff, 0x4f, 0x8e, 0x32, 0xb2, 0x1b, 0x32, 0xe1, 0xde, 0x01, 0xfb, 0x0d, 0x3c, 0x55, 0xda,
|
||||||
0x1c, 0xc3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x98, 0xc4,
|
0x86, 0x77, 0x62, 0x31, 0xe0, 0xfc, 0xb4, 0xf9, 0xe4, 0x51, 0xd3, 0x72, 0xb4, 0x6e, 0x39, 0xfa,
|
||||||
0x06, 0x0e, 0x67, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x13, 0xba, 0x28, 0xc9, 0xa4, 0x01,
|
0x68, 0x39, 0x7a, 0xed, 0x78, 0xb4, 0xee, 0x78, 0xf4, 0xd6, 0xf1, 0xa8, 0x18, 0xfb, 0x3f, 0xbf,
|
||||||
0x00, 0x00,
|
0xfc, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x7a, 0xa2, 0xf6, 0x1e, 0xb0, 0x01, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ package main;
|
|||||||
import "repos/protobuf/gogoproto/gogo.proto";
|
import "repos/protobuf/gogoproto/gogo.proto";
|
||||||
|
|
||||||
option (gogoproto.goproto_getters_all) = false;
|
option (gogoproto.goproto_getters_all) = false;
|
||||||
|
option (gogoproto.goproto_unkeyed_all) = false;
|
||||||
|
option (gogoproto.goproto_unrecognized_all) = false;
|
||||||
|
option (gogoproto.goproto_sizecache_all) = false;
|
||||||
|
|
||||||
message DatabaseRecord {
|
message DatabaseRecord {
|
||||||
repeated DatabaseAddress addresses = 1 [(gogoproto.nullable) = false];
|
repeated DatabaseAddress addresses = 1 [(gogoproto.nullable) = false];
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ require (
|
|||||||
github.com/d4l3k/messagediff v1.2.1
|
github.com/d4l3k/messagediff v1.2.1
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/gobwas/glob v0.0.0-20170212200151-51eb1ee00b6d
|
github.com/gobwas/glob v0.0.0-20170212200151-51eb1ee00b6d
|
||||||
github.com/gogo/protobuf v1.0.0
|
github.com/gogo/protobuf v1.2.0
|
||||||
github.com/golang/groupcache v0.0.0-20171101203131-84a468cf14b4
|
github.com/golang/groupcache v0.0.0-20171101203131-84a468cf14b4
|
||||||
github.com/golang/protobuf v0.0.0-20171113180720-1e59b77b52bf // indirect
|
github.com/golang/protobuf v0.0.0-20171113180720-1e59b77b52bf // indirect
|
||||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049 // indirect
|
github.com/golang/snappy v0.0.0-20170215233205-553a64147049 // indirect
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gobwas/glob v0.0.0-20170212200151-51eb1ee00b6d h1:IngNQgbqr5ZOU0exk395Szrvkzes9Ilk1fmJfkw7d+M=
|
github.com/gobwas/glob v0.0.0-20170212200151-51eb1ee00b6d h1:IngNQgbqr5ZOU0exk395Szrvkzes9Ilk1fmJfkw7d+M=
|
||||||
github.com/gobwas/glob v0.0.0-20170212200151-51eb1ee00b6d/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
github.com/gobwas/glob v0.0.0-20170212200151-51eb1ee00b6d/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||||
github.com/gogo/protobuf v1.0.0 h1:2jyBKDKU/8v3v2xVR2PtiWQviFUyiaGk2rpfyFT8rTM=
|
github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI=
|
||||||
github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/golang/groupcache v0.0.0-20171101203131-84a468cf14b4 h1:6o8aP0LGMKzo3NzwhhX6EJsiJ3ejmj+9yA/3p8Fjjlw=
|
github.com/golang/groupcache v0.0.0-20171101203131-84a468cf14b4 h1:6o8aP0LGMKzo3NzwhhX6EJsiJ3ejmj+9yA/3p8Fjjlw=
|
||||||
github.com/golang/groupcache v0.0.0-20171101203131-84a468cf14b4/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20171101203131-84a468cf14b4/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/protobuf v0.0.0-20171113180720-1e59b77b52bf h1:pFr/u+m8QUBMW/itAczltF3guNRAL7XDs5tD3f6nSD0=
|
github.com/golang/protobuf v0.0.0-20171113180720-1e59b77b52bf h1:pFr/u+m8QUBMW/itAczltF3guNRAL7XDs5tD3f6nSD0=
|
||||||
@@ -39,8 +39,6 @@ github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
|
|||||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/minio/sha256-simd v0.0.0-20171213220625-ad98a36ba0da h1:tazA5y1hWYJO8VSYbU36yBhXeIvruLXMUKu6WBtcJck=
|
|
||||||
github.com/minio/sha256-simd v0.0.0-20171213220625-ad98a36ba0da/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
|
|
||||||
github.com/minio/sha256-simd v0.0.0-20190104231041-e529fa194128 h1:hEDK0Zao06IGlO1ada0FLT2g3KEot2vCqFp8gdvJqzM=
|
github.com/minio/sha256-simd v0.0.0-20190104231041-e529fa194128 h1:hEDK0Zao06IGlO1ada0FLT2g3KEot2vCqFp8gdvJqzM=
|
||||||
github.com/minio/sha256-simd v0.0.0-20190104231041-e529fa194128/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
|
github.com/minio/sha256-simd v0.0.0-20190104231041-e529fa194128/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
|
||||||
github.com/onsi/ginkgo v0.0.0-20171221013426-6c46eb8334b3 h1:ZN7kHmC0iunA+4UPmERwsuMQan4lUnntO6WX6H1jOO8=
|
github.com/onsi/ginkgo v0.0.0-20171221013426-6c46eb8334b3 h1:ZN7kHmC0iunA+4UPmERwsuMQan4lUnntO6WX6H1jOO8=
|
||||||
|
|||||||
+225
-100
@@ -1,19 +1,6 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: structs.proto
|
// source: structs.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package db is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
structs.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
FileVersion
|
|
||||||
VersionList
|
|
||||||
FileInfoTruncated
|
|
||||||
Counts
|
|
||||||
CountsSet
|
|
||||||
*/
|
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
@@ -38,23 +25,79 @@ var _ = math.Inf
|
|||||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type FileVersion struct {
|
type FileVersion struct {
|
||||||
Version protocol.Vector `protobuf:"bytes,1,opt,name=version" json:"version"`
|
Version protocol.Vector `protobuf:"bytes,1,opt,name=version,proto3" json:"version"`
|
||||||
Device []byte `protobuf:"bytes,2,opt,name=device,proto3" json:"device,omitempty"`
|
Device []byte `protobuf:"bytes,2,opt,name=device,proto3" json:"device,omitempty"`
|
||||||
Invalid bool `protobuf:"varint,3,opt,name=invalid,proto3" json:"invalid,omitempty"`
|
Invalid bool `protobuf:"varint,3,opt,name=invalid,proto3" json:"invalid,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *FileVersion) Reset() { *m = FileVersion{} }
|
func (m *FileVersion) Reset() { *m = FileVersion{} }
|
||||||
func (m *FileVersion) String() string { return proto.CompactTextString(m) }
|
func (m *FileVersion) String() string { return proto.CompactTextString(m) }
|
||||||
func (*FileVersion) ProtoMessage() {}
|
func (*FileVersion) ProtoMessage() {}
|
||||||
func (*FileVersion) Descriptor() ([]byte, []int) { return fileDescriptorStructs, []int{0} }
|
func (*FileVersion) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_structs_6691fa5e0cf0de4d, []int{0}
|
||||||
type VersionList struct {
|
}
|
||||||
Versions []FileVersion `protobuf:"bytes,1,rep,name=versions" json:"versions"`
|
func (m *FileVersion) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *FileVersion) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_FileVersion.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *FileVersion) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_FileVersion.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *FileVersion) XXX_Size() int {
|
||||||
|
return m.ProtoSize()
|
||||||
|
}
|
||||||
|
func (m *FileVersion) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_FileVersion.DiscardUnknown(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *VersionList) Reset() { *m = VersionList{} }
|
var xxx_messageInfo_FileVersion proto.InternalMessageInfo
|
||||||
func (*VersionList) ProtoMessage() {}
|
|
||||||
func (*VersionList) Descriptor() ([]byte, []int) { return fileDescriptorStructs, []int{1} }
|
type VersionList struct {
|
||||||
|
Versions []FileVersion `protobuf:"bytes,1,rep,name=versions,proto3" json:"versions"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *VersionList) Reset() { *m = VersionList{} }
|
||||||
|
func (*VersionList) ProtoMessage() {}
|
||||||
|
func (*VersionList) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_structs_6691fa5e0cf0de4d, []int{1}
|
||||||
|
}
|
||||||
|
func (m *VersionList) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *VersionList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_VersionList.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *VersionList) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_VersionList.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *VersionList) XXX_Size() int {
|
||||||
|
return m.ProtoSize()
|
||||||
|
}
|
||||||
|
func (m *VersionList) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_VersionList.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_VersionList proto.InternalMessageInfo
|
||||||
|
|
||||||
// Must be the same as FileInfo but without the blocks field
|
// Must be the same as FileInfo but without the blocks field
|
||||||
type FileInfoTruncated struct {
|
type FileInfoTruncated struct {
|
||||||
@@ -68,7 +111,7 @@ type FileInfoTruncated struct {
|
|||||||
Deleted bool `protobuf:"varint,6,opt,name=deleted,proto3" json:"deleted,omitempty"`
|
Deleted bool `protobuf:"varint,6,opt,name=deleted,proto3" json:"deleted,omitempty"`
|
||||||
RawInvalid bool `protobuf:"varint,7,opt,name=invalid,proto3" json:"invalid,omitempty"`
|
RawInvalid bool `protobuf:"varint,7,opt,name=invalid,proto3" json:"invalid,omitempty"`
|
||||||
NoPermissions bool `protobuf:"varint,8,opt,name=no_permissions,json=noPermissions,proto3" json:"no_permissions,omitempty"`
|
NoPermissions bool `protobuf:"varint,8,opt,name=no_permissions,json=noPermissions,proto3" json:"no_permissions,omitempty"`
|
||||||
Version protocol.Vector `protobuf:"bytes,9,opt,name=version" json:"version"`
|
Version protocol.Vector `protobuf:"bytes,9,opt,name=version,proto3" json:"version"`
|
||||||
Sequence int64 `protobuf:"varint,10,opt,name=sequence,proto3" json:"sequence,omitempty"`
|
Sequence int64 `protobuf:"varint,10,opt,name=sequence,proto3" json:"sequence,omitempty"`
|
||||||
RawBlockSize int32 `protobuf:"varint,13,opt,name=block_size,json=blockSize,proto3" json:"block_size,omitempty"`
|
RawBlockSize int32 `protobuf:"varint,13,opt,name=block_size,json=blockSize,proto3" json:"block_size,omitempty"`
|
||||||
// repeated BlockInfo Blocks = 16
|
// repeated BlockInfo Blocks = 16
|
||||||
@@ -77,9 +120,37 @@ type FileInfoTruncated struct {
|
|||||||
LocalFlags uint32 `protobuf:"varint,1000,opt,name=local_flags,json=localFlags,proto3" json:"local_flags,omitempty"`
|
LocalFlags uint32 `protobuf:"varint,1000,opt,name=local_flags,json=localFlags,proto3" json:"local_flags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *FileInfoTruncated) Reset() { *m = FileInfoTruncated{} }
|
func (m *FileInfoTruncated) Reset() { *m = FileInfoTruncated{} }
|
||||||
func (*FileInfoTruncated) ProtoMessage() {}
|
func (*FileInfoTruncated) ProtoMessage() {}
|
||||||
func (*FileInfoTruncated) Descriptor() ([]byte, []int) { return fileDescriptorStructs, []int{2} }
|
func (*FileInfoTruncated) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_structs_6691fa5e0cf0de4d, []int{2}
|
||||||
|
}
|
||||||
|
func (m *FileInfoTruncated) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *FileInfoTruncated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_FileInfoTruncated.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *FileInfoTruncated) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_FileInfoTruncated.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *FileInfoTruncated) XXX_Size() int {
|
||||||
|
return m.ProtoSize()
|
||||||
|
}
|
||||||
|
func (m *FileInfoTruncated) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_FileInfoTruncated.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_FileInfoTruncated proto.InternalMessageInfo
|
||||||
|
|
||||||
// For each folder and device we keep one of these to track the current
|
// For each folder and device we keep one of these to track the current
|
||||||
// counts and sequence. We also keep one for the global state of the folder.
|
// counts and sequence. We also keep one for the global state of the folder.
|
||||||
@@ -94,20 +165,76 @@ type Counts struct {
|
|||||||
LocalFlags uint32 `protobuf:"varint,18,opt,name=localFlags,proto3" json:"localFlags,omitempty"`
|
LocalFlags uint32 `protobuf:"varint,18,opt,name=localFlags,proto3" json:"localFlags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Counts) Reset() { *m = Counts{} }
|
func (m *Counts) Reset() { *m = Counts{} }
|
||||||
func (m *Counts) String() string { return proto.CompactTextString(m) }
|
func (m *Counts) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Counts) ProtoMessage() {}
|
func (*Counts) ProtoMessage() {}
|
||||||
func (*Counts) Descriptor() ([]byte, []int) { return fileDescriptorStructs, []int{3} }
|
func (*Counts) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_structs_6691fa5e0cf0de4d, []int{3}
|
||||||
|
}
|
||||||
|
func (m *Counts) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *Counts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_Counts.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *Counts) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Counts.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *Counts) XXX_Size() int {
|
||||||
|
return m.ProtoSize()
|
||||||
|
}
|
||||||
|
func (m *Counts) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Counts.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Counts proto.InternalMessageInfo
|
||||||
|
|
||||||
type CountsSet struct {
|
type CountsSet struct {
|
||||||
Counts []Counts `protobuf:"bytes,1,rep,name=counts" json:"counts"`
|
Counts []Counts `protobuf:"bytes,1,rep,name=counts,proto3" json:"counts"`
|
||||||
Created int64 `protobuf:"varint,2,opt,name=created,proto3" json:"created,omitempty"`
|
Created int64 `protobuf:"varint,2,opt,name=created,proto3" json:"created,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CountsSet) Reset() { *m = CountsSet{} }
|
func (m *CountsSet) Reset() { *m = CountsSet{} }
|
||||||
func (m *CountsSet) String() string { return proto.CompactTextString(m) }
|
func (m *CountsSet) String() string { return proto.CompactTextString(m) }
|
||||||
func (*CountsSet) ProtoMessage() {}
|
func (*CountsSet) ProtoMessage() {}
|
||||||
func (*CountsSet) Descriptor() ([]byte, []int) { return fileDescriptorStructs, []int{4} }
|
func (*CountsSet) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_structs_6691fa5e0cf0de4d, []int{4}
|
||||||
|
}
|
||||||
|
func (m *CountsSet) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *CountsSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_CountsSet.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *CountsSet) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_CountsSet.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *CountsSet) XXX_Size() int {
|
||||||
|
return m.ProtoSize()
|
||||||
|
}
|
||||||
|
func (m *CountsSet) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_CountsSet.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_CountsSet proto.InternalMessageInfo
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*FileVersion)(nil), "db.FileVersion")
|
proto.RegisterType((*FileVersion)(nil), "db.FileVersion")
|
||||||
@@ -403,24 +530,6 @@ func (m *CountsSet) MarshalTo(dAtA []byte) (int, error) {
|
|||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeFixed64Structs(dAtA []byte, offset int, v uint64) int {
|
|
||||||
dAtA[offset] = uint8(v)
|
|
||||||
dAtA[offset+1] = uint8(v >> 8)
|
|
||||||
dAtA[offset+2] = uint8(v >> 16)
|
|
||||||
dAtA[offset+3] = uint8(v >> 24)
|
|
||||||
dAtA[offset+4] = uint8(v >> 32)
|
|
||||||
dAtA[offset+5] = uint8(v >> 40)
|
|
||||||
dAtA[offset+6] = uint8(v >> 48)
|
|
||||||
dAtA[offset+7] = uint8(v >> 56)
|
|
||||||
return offset + 8
|
|
||||||
}
|
|
||||||
func encodeFixed32Structs(dAtA []byte, offset int, v uint32) int {
|
|
||||||
dAtA[offset] = uint8(v)
|
|
||||||
dAtA[offset+1] = uint8(v >> 8)
|
|
||||||
dAtA[offset+2] = uint8(v >> 16)
|
|
||||||
dAtA[offset+3] = uint8(v >> 24)
|
|
||||||
return offset + 4
|
|
||||||
}
|
|
||||||
func encodeVarintStructs(dAtA []byte, offset int, v uint64) int {
|
func encodeVarintStructs(dAtA []byte, offset int, v uint64) int {
|
||||||
for v >= 1<<7 {
|
for v >= 1<<7 {
|
||||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||||
@@ -431,6 +540,9 @@ func encodeVarintStructs(dAtA []byte, offset int, v uint64) int {
|
|||||||
return offset + 1
|
return offset + 1
|
||||||
}
|
}
|
||||||
func (m *FileVersion) ProtoSize() (n int) {
|
func (m *FileVersion) ProtoSize() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
l = m.Version.ProtoSize()
|
l = m.Version.ProtoSize()
|
||||||
@@ -446,6 +558,9 @@ func (m *FileVersion) ProtoSize() (n int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *VersionList) ProtoSize() (n int) {
|
func (m *VersionList) ProtoSize() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
if len(m.Versions) > 0 {
|
if len(m.Versions) > 0 {
|
||||||
@@ -458,6 +573,9 @@ func (m *VersionList) ProtoSize() (n int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *FileInfoTruncated) ProtoSize() (n int) {
|
func (m *FileInfoTruncated) ProtoSize() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
l = len(m.Name)
|
l = len(m.Name)
|
||||||
@@ -510,6 +628,9 @@ func (m *FileInfoTruncated) ProtoSize() (n int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Counts) ProtoSize() (n int) {
|
func (m *Counts) ProtoSize() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
if m.Files != 0 {
|
if m.Files != 0 {
|
||||||
@@ -541,6 +662,9 @@ func (m *Counts) ProtoSize() (n int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *CountsSet) ProtoSize() (n int) {
|
func (m *CountsSet) ProtoSize() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
if len(m.Counts) > 0 {
|
if len(m.Counts) > 0 {
|
||||||
@@ -1568,50 +1692,51 @@ var (
|
|||||||
ErrIntOverflowStructs = fmt.Errorf("proto: integer overflow")
|
ErrIntOverflowStructs = fmt.Errorf("proto: integer overflow")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { proto.RegisterFile("structs.proto", fileDescriptorStructs) }
|
func init() { proto.RegisterFile("structs.proto", fileDescriptor_structs_6691fa5e0cf0de4d) }
|
||||||
|
|
||||||
var fileDescriptorStructs = []byte{
|
var fileDescriptor_structs_6691fa5e0cf0de4d = []byte{
|
||||||
// 672 bytes of a gzipped FileDescriptorProto
|
// 684 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x4d, 0x6f, 0xdb, 0x38,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x4f, 0x6b, 0xdb, 0x4e,
|
||||||
0x10, 0xb5, 0x62, 0xf9, 0x6b, 0x6c, 0x67, 0x13, 0x22, 0x08, 0x04, 0x03, 0x6b, 0x0b, 0x5e, 0x2c,
|
0x10, 0xb5, 0x62, 0xf9, 0xdf, 0xd8, 0xce, 0x2f, 0x59, 0x42, 0x10, 0x86, 0x9f, 0x2c, 0x5c, 0x0a,
|
||||||
0x20, 0xec, 0x41, 0xde, 0x26, 0xb7, 0xf6, 0xa6, 0x06, 0x01, 0x0c, 0x14, 0x6d, 0x41, 0x07, 0x39,
|
0xa2, 0x07, 0xbb, 0x4d, 0x6e, 0xed, 0xcd, 0x0d, 0x01, 0x43, 0x69, 0xcb, 0x3a, 0xe4, 0x54, 0x30,
|
||||||
0x15, 0x30, 0xf4, 0x41, 0x3b, 0x44, 0x64, 0xd1, 0x11, 0xe9, 0x04, 0xca, 0x2f, 0xe9, 0x31, 0x3f,
|
0xfa, 0xb3, 0x76, 0x96, 0xc8, 0x5a, 0x47, 0xbb, 0x4e, 0x70, 0x3e, 0x45, 0x8f, 0x3d, 0xe6, 0xe3,
|
||||||
0x27, 0xc7, 0x9e, 0x7b, 0x30, 0x52, 0xb7, 0x87, 0xfe, 0x8c, 0x82, 0xa4, 0xa4, 0xa8, 0x39, 0xf5,
|
0xe4, 0x98, 0x63, 0xe9, 0xc1, 0xa4, 0x76, 0x0f, 0xfd, 0x18, 0x65, 0x77, 0x25, 0x45, 0xcd, 0xa9,
|
||||||
0x36, 0xef, 0x71, 0xc8, 0x79, 0x33, 0xf3, 0x08, 0x7d, 0x2e, 0xd2, 0x4d, 0x28, 0xb8, 0xbb, 0x4e,
|
0xb7, 0x79, 0x6f, 0x67, 0x77, 0xde, 0xcc, 0xbc, 0x85, 0x36, 0x17, 0xc9, 0x32, 0x10, 0xbc, 0xbf,
|
||||||
0x99, 0x60, 0x68, 0x2f, 0x0a, 0x06, 0xff, 0xa4, 0x64, 0xcd, 0xf8, 0x44, 0x11, 0xc1, 0x66, 0x31,
|
0x48, 0x98, 0x60, 0x68, 0x27, 0xf4, 0x3b, 0x2f, 0x12, 0xb2, 0x60, 0x7c, 0xa0, 0x08, 0x7f, 0x39,
|
||||||
0x59, 0xb2, 0x25, 0x53, 0x40, 0x45, 0x3a, 0x71, 0x70, 0x1c, 0xd3, 0x40, 0xa7, 0x84, 0x2c, 0x9e,
|
0x1d, 0xcc, 0xd8, 0x8c, 0x29, 0xa0, 0x22, 0x9d, 0xd8, 0x39, 0x8c, 0xa8, 0xaf, 0x53, 0x02, 0x16,
|
||||||
0x04, 0x64, 0xad, 0xf9, 0xf1, 0x0d, 0x74, 0xcf, 0x69, 0x4c, 0x2e, 0x49, 0xca, 0x29, 0x4b, 0xd0,
|
0x0d, 0x7c, 0xb2, 0xd0, 0x7c, 0xef, 0x0a, 0x9a, 0xa7, 0x34, 0x22, 0xe7, 0x24, 0xe1, 0x94, 0xc5,
|
||||||
0xff, 0xd0, 0xba, 0xd5, 0xa1, 0x65, 0xd8, 0x86, 0xd3, 0x3d, 0x39, 0x70, 0x8b, 0x4b, 0xee, 0x25,
|
0xe8, 0x35, 0xd4, 0xae, 0x75, 0x68, 0x19, 0x8e, 0xe1, 0x36, 0x8f, 0xf6, 0xfa, 0xd9, 0xa5, 0xfe,
|
||||||
0x09, 0x05, 0x4b, 0x3d, 0xf3, 0x71, 0x3b, 0xaa, 0xe1, 0x22, 0x0d, 0x1d, 0x43, 0x33, 0x22, 0xb7,
|
0x39, 0x09, 0x04, 0x4b, 0x86, 0xe6, 0xfd, 0xba, 0x5b, 0xc2, 0x59, 0x1a, 0x3a, 0x84, 0x6a, 0x48,
|
||||||
0x34, 0x24, 0xd6, 0x9e, 0x6d, 0x38, 0x3d, 0x9c, 0x23, 0x64, 0x41, 0x8b, 0x26, 0xb7, 0x7e, 0x4c,
|
0xae, 0x69, 0x40, 0xac, 0x1d, 0xc7, 0x70, 0x5b, 0x38, 0x45, 0xc8, 0x82, 0x1a, 0x8d, 0xaf, 0xbd,
|
||||||
0x23, 0xab, 0x6e, 0x1b, 0x4e, 0x1b, 0x17, 0x70, 0x7c, 0x0e, 0xdd, 0xbc, 0xdc, 0x3b, 0xca, 0x05,
|
0x88, 0x86, 0x56, 0xd9, 0x31, 0xdc, 0x3a, 0xce, 0x60, 0xef, 0x14, 0x9a, 0x69, 0xb9, 0x0f, 0x94,
|
||||||
0x7a, 0x05, 0xed, 0xfc, 0x2d, 0x6e, 0x19, 0x76, 0xdd, 0xe9, 0x9e, 0xfc, 0xe5, 0x46, 0x81, 0x5b,
|
0x0b, 0xf4, 0x06, 0xea, 0xe9, 0x5b, 0xdc, 0x32, 0x9c, 0xb2, 0xdb, 0x3c, 0xfa, 0xaf, 0x1f, 0xfa,
|
||||||
0x51, 0x95, 0x97, 0x2c, 0xd3, 0x5e, 0x9b, 0x9f, 0x1f, 0x46, 0xb5, 0xf1, 0x93, 0x09, 0x87, 0x32,
|
0xfd, 0x82, 0xaa, 0xb4, 0x64, 0x9e, 0xf6, 0xd6, 0xfc, 0x76, 0xd7, 0x2d, 0xf5, 0x1e, 0x4d, 0xd8,
|
||||||
0x6b, 0x9a, 0x2c, 0xd8, 0x45, 0xba, 0x49, 0x42, 0x5f, 0x90, 0x08, 0x21, 0x30, 0x13, 0x7f, 0x45,
|
0x97, 0x59, 0xa3, 0x78, 0xca, 0xce, 0x92, 0x65, 0x1c, 0x78, 0x82, 0x84, 0x08, 0x81, 0x19, 0x7b,
|
||||||
0x94, 0xfc, 0x0e, 0x56, 0x31, 0xfa, 0x0f, 0x4c, 0x91, 0xad, 0xb5, 0xc2, 0xfd, 0x93, 0xe3, 0xe7,
|
0x73, 0xa2, 0xe4, 0x37, 0xb0, 0x8a, 0xd1, 0x2b, 0x30, 0xc5, 0x6a, 0xa1, 0x15, 0xee, 0x1e, 0x1d,
|
||||||
0x96, 0xca, 0xeb, 0xd9, 0x9a, 0x60, 0x95, 0x23, 0xef, 0x73, 0x7a, 0x4f, 0x94, 0xe8, 0x3a, 0x56,
|
0x3e, 0xb5, 0x94, 0x5f, 0x5f, 0x2d, 0x08, 0x56, 0x39, 0xf2, 0x3e, 0xa7, 0xb7, 0x44, 0x89, 0x2e,
|
||||||
0x31, 0xb2, 0xa1, 0xbb, 0x26, 0xe9, 0x8a, 0x72, 0xad, 0xd2, 0xb4, 0x0d, 0xa7, 0x8f, 0xab, 0x14,
|
0x63, 0x15, 0x23, 0x07, 0x9a, 0x0b, 0x92, 0xcc, 0x29, 0xd7, 0x2a, 0x4d, 0xc7, 0x70, 0xdb, 0xb8,
|
||||||
0xfa, 0x1b, 0x60, 0xc5, 0x22, 0xba, 0xa0, 0x24, 0x9a, 0x73, 0xab, 0xa1, 0xee, 0x76, 0x0a, 0x66,
|
0x48, 0xa1, 0xff, 0x01, 0xe6, 0x2c, 0xa4, 0x53, 0x4a, 0xc2, 0x09, 0xb7, 0x2a, 0xea, 0x6e, 0x23,
|
||||||
0x26, 0x87, 0x11, 0x91, 0x98, 0x08, 0x12, 0x59, 0x4d, 0x3d, 0x8c, 0x1c, 0x22, 0xe7, 0x79, 0x4c,
|
0x63, 0xc6, 0x72, 0x18, 0x21, 0x89, 0x88, 0x20, 0xa1, 0x55, 0xd5, 0xc3, 0x48, 0x21, 0x72, 0x9f,
|
||||||
0x2d, 0x79, 0xe2, 0xed, 0xef, 0xb6, 0x23, 0xc0, 0xfe, 0xdd, 0x54, 0xb3, 0xe5, 0xd8, 0xd0, 0xbf,
|
0xc6, 0x54, 0x93, 0x27, 0xc3, 0xdd, 0xcd, 0xba, 0x0b, 0xd8, 0xbb, 0x19, 0x69, 0x36, 0x1f, 0x1b,
|
||||||
0xb0, 0x9f, 0xb0, 0x79, 0x55, 0x47, 0x5b, 0x3d, 0xd5, 0x4f, 0xd8, 0xc7, 0x8a, 0x92, 0xca, 0x06,
|
0x7a, 0x09, 0xbb, 0x31, 0x9b, 0x14, 0x75, 0xd4, 0xd5, 0x53, 0xed, 0x98, 0x7d, 0x2e, 0x28, 0x29,
|
||||||
0x3b, 0x7f, 0xb6, 0xc1, 0x01, 0xb4, 0x39, 0xb9, 0xd9, 0x90, 0x24, 0x24, 0x16, 0x28, 0xe5, 0x25,
|
0x6c, 0xb0, 0xf1, 0x6f, 0x1b, 0xec, 0x40, 0x9d, 0x93, 0xab, 0x25, 0x89, 0x03, 0x62, 0x81, 0x52,
|
||||||
0x46, 0x23, 0xe8, 0x96, 0x7d, 0x25, 0xdc, 0xea, 0xda, 0x86, 0xd3, 0xc0, 0x65, 0xab, 0xef, 0x39,
|
0x9e, 0x63, 0xd4, 0x85, 0x66, 0xde, 0x57, 0xcc, 0xad, 0xa6, 0x63, 0xb8, 0x15, 0x9c, 0xb7, 0xfa,
|
||||||
0xfa, 0x54, 0x49, 0x08, 0x32, 0xab, 0x67, 0x1b, 0x8e, 0xe9, 0xbd, 0x91, 0x05, 0xbe, 0x6e, 0x47,
|
0x91, 0xa3, 0x2f, 0x85, 0x04, 0x7f, 0x65, 0xb5, 0x1c, 0xc3, 0x35, 0x87, 0xef, 0x64, 0x81, 0x1f,
|
||||||
0xa7, 0x4b, 0x2a, 0xae, 0x36, 0x81, 0x1b, 0xb2, 0xd5, 0x84, 0x67, 0x49, 0x28, 0xae, 0x68, 0xb2,
|
0xeb, 0xee, 0xf1, 0x8c, 0x8a, 0x8b, 0xa5, 0xdf, 0x0f, 0xd8, 0x7c, 0xc0, 0x57, 0x71, 0x20, 0x2e,
|
||||||
0xac, 0x44, 0x55, 0x4f, 0xba, 0xb3, 0x2b, 0x96, 0x8a, 0xe9, 0xd9, 0xf3, 0xeb, 0x5e, 0x86, 0x26,
|
0x68, 0x3c, 0x2b, 0x44, 0x45, 0x4f, 0xf6, 0xc7, 0x17, 0x2c, 0x11, 0xa3, 0x93, 0xa7, 0xd7, 0x87,
|
||||||
0x00, 0x41, 0xcc, 0xc2, 0xeb, 0xb9, 0x5a, 0x49, 0x5f, 0x56, 0xf7, 0x0e, 0x76, 0xdb, 0x51, 0x0f,
|
0x2b, 0x34, 0x00, 0xf0, 0x23, 0x16, 0x5c, 0x4e, 0xd4, 0x4a, 0xda, 0xb2, 0xfa, 0x70, 0x6f, 0xb3,
|
||||||
0xfb, 0x77, 0x9e, 0x3c, 0x98, 0xd1, 0x7b, 0x82, 0x3b, 0x41, 0x11, 0xca, 0x21, 0xf1, 0x6c, 0x15,
|
0xee, 0xb6, 0xb0, 0x77, 0x33, 0x94, 0x07, 0x63, 0x7a, 0x4b, 0x70, 0xc3, 0xcf, 0x42, 0x39, 0x24,
|
||||||
0xd3, 0xe4, 0x7a, 0x2e, 0xfc, 0x74, 0x49, 0x84, 0x75, 0xa8, 0x7c, 0xd0, 0xcf, 0xd9, 0x0b, 0x45,
|
0xbe, 0x9a, 0x47, 0x34, 0xbe, 0x9c, 0x08, 0x2f, 0x99, 0x11, 0x61, 0xed, 0x2b, 0x1f, 0xb4, 0x53,
|
||||||
0xca, 0x85, 0xc6, 0x2c, 0xf4, 0xe3, 0xf9, 0x22, 0xf6, 0x97, 0xdc, 0xfa, 0xd9, 0x52, 0x1b, 0x05,
|
0xf6, 0x4c, 0x91, 0x72, 0xa1, 0x11, 0x0b, 0xbc, 0x68, 0x32, 0x8d, 0xbc, 0x19, 0xb7, 0x7e, 0xd7,
|
||||||
0xc5, 0x9d, 0x4b, 0x2a, 0xb7, 0xd8, 0x0f, 0x03, 0x9a, 0x6f, 0xd9, 0x26, 0x11, 0x1c, 0x1d, 0x41,
|
0xd4, 0x46, 0x41, 0x71, 0xa7, 0x92, 0x4a, 0x2d, 0xf6, 0xcb, 0x80, 0xea, 0x7b, 0xb6, 0x8c, 0x05,
|
||||||
0x63, 0x41, 0x63, 0xc2, 0x95, 0xb1, 0x1a, 0x58, 0x03, 0xf9, 0x50, 0x44, 0x53, 0x35, 0x56, 0x4a,
|
0x47, 0x07, 0x50, 0x99, 0xd2, 0x88, 0x70, 0x65, 0xac, 0x0a, 0xd6, 0x40, 0x3e, 0x14, 0xd2, 0x44,
|
||||||
0xb8, 0x32, 0x58, 0x03, 0x57, 0x29, 0x35, 0x5d, 0x5d, 0x9b, 0x2b, 0x4f, 0x35, 0x70, 0x89, 0xab,
|
0x8d, 0x95, 0x12, 0xae, 0x0c, 0x56, 0xc1, 0x45, 0x4a, 0x4d, 0x57, 0xd7, 0xe6, 0xca, 0x53, 0x15,
|
||||||
0xb6, 0x30, 0xd5, 0x51, 0x69, 0x8b, 0x23, 0x68, 0x04, 0x99, 0x20, 0x85, 0x95, 0x34, 0xf8, 0x6d,
|
0x9c, 0xe3, 0xa2, 0x2d, 0x4c, 0x75, 0x94, 0xdb, 0xe2, 0x00, 0x2a, 0xfe, 0x4a, 0x90, 0xcc, 0x4a,
|
||||||
0x53, 0xcd, 0x17, 0x9b, 0x1a, 0x40, 0x5b, 0xff, 0xbc, 0xe9, 0x99, 0xea, 0xb9, 0x87, 0x4b, 0x8c,
|
0x1a, 0xfc, 0xb5, 0xa9, 0xea, 0xb3, 0x4d, 0x75, 0xa0, 0xae, 0x7f, 0xde, 0xe8, 0x44, 0xf5, 0xdc,
|
||||||
0x86, 0x50, 0x69, 0xcd, 0x42, 0x2f, 0x9b, 0x1d, 0x7f, 0x80, 0x8e, 0xee, 0x72, 0x46, 0x04, 0x72,
|
0xc2, 0x39, 0x46, 0x36, 0x14, 0x5a, 0xb3, 0xd0, 0xf3, 0x66, 0x7b, 0x9f, 0xa0, 0xa1, 0xbb, 0x1c,
|
||||||
0xa0, 0x19, 0x2a, 0x90, 0xff, 0x46, 0x90, 0xbf, 0x51, 0x1f, 0xe7, 0xce, 0xc9, 0xcf, 0xa5, 0xfc,
|
0x13, 0x81, 0x5c, 0xa8, 0x06, 0x0a, 0xa4, 0xbf, 0x11, 0xe4, 0x6f, 0xd4, 0xc7, 0xa9, 0x73, 0xd2,
|
||||||
0x30, 0x25, 0xf2, 0xd7, 0xa9, 0xc6, 0xeb, 0xb8, 0x80, 0xde, 0xd1, 0xe3, 0xb7, 0x61, 0xed, 0x71,
|
0x73, 0x29, 0x3f, 0x48, 0x88, 0xfc, 0x75, 0xaa, 0xf1, 0x32, 0xce, 0xe0, 0xd0, 0xb9, 0xff, 0x69,
|
||||||
0x37, 0x34, 0xbe, 0xec, 0x86, 0xc6, 0xd3, 0x6e, 0x58, 0x7b, 0xf8, 0x3e, 0x34, 0x82, 0xa6, 0xda,
|
0x97, 0xee, 0x37, 0xb6, 0xf1, 0xb0, 0xb1, 0x8d, 0xc7, 0x8d, 0x5d, 0xfa, 0xba, 0xb5, 0x4b, 0x77,
|
||||||
0xf5, 0xe9, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x08, 0x8f, 0xd2, 0xdf, 0xc4, 0x04, 0x00, 0x00,
|
0x5b, 0xdb, 0x78, 0xd8, 0xda, 0xa5, 0xef, 0x5b, 0xbb, 0xe4, 0x57, 0xd5, 0xde, 0x8f, 0xff, 0x04,
|
||||||
|
0x00, 0x00, 0xff, 0xff, 0x26, 0xe4, 0x54, 0xca, 0xd0, 0x04, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import "lib/protocol/bep.proto";
|
|||||||
option (gogoproto.goproto_getters_all) = false;
|
option (gogoproto.goproto_getters_all) = false;
|
||||||
option (gogoproto.sizer_all) = false;
|
option (gogoproto.sizer_all) = false;
|
||||||
option (gogoproto.protosizer_all) = true;
|
option (gogoproto.protosizer_all) = true;
|
||||||
|
option (gogoproto.goproto_unkeyed_all) = false;
|
||||||
|
option (gogoproto.goproto_unrecognized_all) = false;
|
||||||
|
option (gogoproto.goproto_sizecache_all) = false;
|
||||||
|
|
||||||
message FileVersion {
|
message FileVersion {
|
||||||
protocol.Vector version = 1 [(gogoproto.nullable) = false];
|
protocol.Vector version = 1 [(gogoproto.nullable) = false];
|
||||||
|
|||||||
+54
-50
@@ -1,15 +1,6 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: local.proto
|
// source: local.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package discover is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
local.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
Announce
|
|
||||||
*/
|
|
||||||
package discover
|
package discover
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
@@ -34,14 +25,42 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
|||||||
|
|
||||||
type Announce struct {
|
type Announce struct {
|
||||||
ID github_com_syncthing_syncthing_lib_protocol.DeviceID `protobuf:"bytes,1,opt,name=id,proto3,customtype=github.com/syncthing/syncthing/lib/protocol.DeviceID" json:"id"`
|
ID github_com_syncthing_syncthing_lib_protocol.DeviceID `protobuf:"bytes,1,opt,name=id,proto3,customtype=github.com/syncthing/syncthing/lib/protocol.DeviceID" json:"id"`
|
||||||
Addresses []string `protobuf:"bytes,2,rep,name=addresses" json:"addresses,omitempty"`
|
Addresses []string `protobuf:"bytes,2,rep,name=addresses,proto3" json:"addresses,omitempty"`
|
||||||
InstanceID int64 `protobuf:"varint,3,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"`
|
InstanceID int64 `protobuf:"varint,3,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Announce) Reset() { *m = Announce{} }
|
func (m *Announce) Reset() { *m = Announce{} }
|
||||||
func (m *Announce) String() string { return proto.CompactTextString(m) }
|
func (m *Announce) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Announce) ProtoMessage() {}
|
func (*Announce) ProtoMessage() {}
|
||||||
func (*Announce) Descriptor() ([]byte, []int) { return fileDescriptorLocal, []int{0} }
|
func (*Announce) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_local_652287d527eec38f, []int{0}
|
||||||
|
}
|
||||||
|
func (m *Announce) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *Announce) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_Announce.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *Announce) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Announce.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *Announce) XXX_Size() int {
|
||||||
|
return m.ProtoSize()
|
||||||
|
}
|
||||||
|
func (m *Announce) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Announce.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Announce proto.InternalMessageInfo
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*Announce)(nil), "discover.Announce")
|
proto.RegisterType((*Announce)(nil), "discover.Announce")
|
||||||
@@ -92,24 +111,6 @@ func (m *Announce) MarshalTo(dAtA []byte) (int, error) {
|
|||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeFixed64Local(dAtA []byte, offset int, v uint64) int {
|
|
||||||
dAtA[offset] = uint8(v)
|
|
||||||
dAtA[offset+1] = uint8(v >> 8)
|
|
||||||
dAtA[offset+2] = uint8(v >> 16)
|
|
||||||
dAtA[offset+3] = uint8(v >> 24)
|
|
||||||
dAtA[offset+4] = uint8(v >> 32)
|
|
||||||
dAtA[offset+5] = uint8(v >> 40)
|
|
||||||
dAtA[offset+6] = uint8(v >> 48)
|
|
||||||
dAtA[offset+7] = uint8(v >> 56)
|
|
||||||
return offset + 8
|
|
||||||
}
|
|
||||||
func encodeFixed32Local(dAtA []byte, offset int, v uint32) int {
|
|
||||||
dAtA[offset] = uint8(v)
|
|
||||||
dAtA[offset+1] = uint8(v >> 8)
|
|
||||||
dAtA[offset+2] = uint8(v >> 16)
|
|
||||||
dAtA[offset+3] = uint8(v >> 24)
|
|
||||||
return offset + 4
|
|
||||||
}
|
|
||||||
func encodeVarintLocal(dAtA []byte, offset int, v uint64) int {
|
func encodeVarintLocal(dAtA []byte, offset int, v uint64) int {
|
||||||
for v >= 1<<7 {
|
for v >= 1<<7 {
|
||||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||||
@@ -120,6 +121,9 @@ func encodeVarintLocal(dAtA []byte, offset int, v uint64) int {
|
|||||||
return offset + 1
|
return offset + 1
|
||||||
}
|
}
|
||||||
func (m *Announce) ProtoSize() (n int) {
|
func (m *Announce) ProtoSize() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
l = m.ID.ProtoSize()
|
l = m.ID.ProtoSize()
|
||||||
@@ -382,24 +386,24 @@ var (
|
|||||||
ErrIntOverflowLocal = fmt.Errorf("proto: integer overflow")
|
ErrIntOverflowLocal = fmt.Errorf("proto: integer overflow")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { proto.RegisterFile("local.proto", fileDescriptorLocal) }
|
func init() { proto.RegisterFile("local.proto", fileDescriptor_local_652287d527eec38f) }
|
||||||
|
|
||||||
var fileDescriptorLocal = []byte{
|
var fileDescriptor_local_652287d527eec38f = []byte{
|
||||||
// 241 bytes of a gzipped FileDescriptorProto
|
// 252 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8e, 0x31, 0x4e, 0x84, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8e, 0x31, 0x4e, 0x84, 0x40,
|
||||||
0x14, 0x86, 0x19, 0x48, 0xcc, 0xee, 0xac, 0xb1, 0x20, 0x16, 0xc4, 0x98, 0x81, 0x68, 0x43, 0x05,
|
0x14, 0x86, 0x67, 0x20, 0x31, 0xbb, 0xb3, 0xc6, 0x82, 0x8a, 0x18, 0x33, 0x10, 0x6d, 0xa8, 0xa0,
|
||||||
0x85, 0x5e, 0x40, 0x42, 0x33, 0x2d, 0x17, 0x30, 0x30, 0xf3, 0x64, 0x5f, 0x82, 0xf3, 0x36, 0x0c,
|
0xd0, 0x0b, 0x48, 0x68, 0xa6, 0xe5, 0x02, 0x06, 0x66, 0x46, 0xf6, 0x25, 0x38, 0x6f, 0xc3, 0xc0,
|
||||||
0x6c, 0xe2, 0x6d, 0xbc, 0x80, 0xf7, 0xa0, 0xb4, 0xb6, 0x20, 0x3a, 0x5e, 0xc4, 0x04, 0x34, 0x6e,
|
0x26, 0xde, 0xc2, 0x23, 0x78, 0x01, 0xef, 0x41, 0xb9, 0xa5, 0xb1, 0x20, 0x3a, 0x5c, 0xc4, 0x04,
|
||||||
0xf7, 0xbd, 0x2f, 0x5f, 0xf2, 0x7e, 0xbe, 0xeb, 0x48, 0xd5, 0x5d, 0x76, 0xe8, 0x69, 0xa0, 0x70,
|
0x34, 0xda, 0x7d, 0xef, 0xcb, 0x97, 0xbc, 0x9f, 0xed, 0x5a, 0x94, 0x55, 0x9b, 0x1e, 0x3a, 0xec,
|
||||||
0xa3, 0xd1, 0x2a, 0x3a, 0x42, 0x7f, 0x75, 0xdb, 0xc3, 0x81, 0x6c, 0xbe, 0xe8, 0x66, 0x7c, 0xca,
|
0x31, 0xd8, 0x28, 0xb0, 0x12, 0x8f, 0xba, 0xbb, 0xbc, 0xe9, 0xf4, 0x01, 0x6d, 0xb6, 0xe8, 0x7a,
|
||||||
0x5b, 0x6a, 0x69, 0x39, 0x16, 0x5a, 0xf3, 0x9b, 0x37, 0xc6, 0x37, 0x0f, 0xc6, 0xd0, 0x68, 0x14,
|
0x78, 0xcc, 0x1a, 0x6c, 0x70, 0x39, 0x16, 0x5a, 0xf3, 0xeb, 0x37, 0xca, 0x36, 0xf7, 0xc6, 0xe0,
|
||||||
0x84, 0x15, 0xf7, 0x51, 0x47, 0x2c, 0x61, 0xe9, 0x79, 0x51, 0x4c, 0x73, 0xec, 0x7d, 0xcc, 0xf1,
|
0x60, 0xa4, 0x0e, 0x4a, 0xe6, 0x81, 0x0a, 0x69, 0x4c, 0x93, 0xf3, 0x3c, 0x1f, 0xa7, 0x88, 0x7c,
|
||||||
0x7d, 0x8b, 0xc3, 0x7e, 0x6c, 0x32, 0x45, 0xcf, 0xb9, 0x7d, 0x31, 0x6a, 0xd8, 0xa3, 0x69, 0x4f,
|
0x4c, 0xd1, 0x5d, 0x03, 0xfd, 0x7e, 0xa8, 0x53, 0x89, 0x4f, 0x99, 0x7d, 0x36, 0xb2, 0xdf, 0x83,
|
||||||
0xa8, 0xc3, 0x66, 0x7d, 0xa1, 0xa8, 0xcb, 0x4a, 0x38, 0xa2, 0x02, 0x59, 0xba, 0x39, 0xf6, 0x65,
|
0x69, 0xfe, 0x51, 0x0b, 0xf5, 0xfa, 0x42, 0x62, 0x9b, 0x16, 0xfa, 0x08, 0x52, 0x8b, 0xc2, 0x4d,
|
||||||
0x59, 0xf9, 0xa8, 0xc3, 0x6b, 0xbe, 0xad, 0xb5, 0xee, 0xc1, 0x5a, 0xb0, 0x91, 0x9f, 0x04, 0xe9,
|
0x91, 0x27, 0x8a, 0xd2, 0x03, 0x15, 0x5c, 0xb1, 0x6d, 0xa5, 0x54, 0xa7, 0xad, 0xd5, 0x36, 0xf4,
|
||||||
0xb6, 0xfa, 0x17, 0x61, 0xce, 0x77, 0x68, 0xec, 0x50, 0x1b, 0x05, 0x8f, 0xa8, 0xa3, 0x20, 0x61,
|
0x62, 0x3f, 0xd9, 0x96, 0x7f, 0x22, 0xc8, 0xd8, 0x0e, 0x8c, 0xed, 0x2b, 0x23, 0xf5, 0x03, 0xa8,
|
||||||
0x69, 0x50, 0x5c, 0xb8, 0x39, 0xe6, 0xf2, 0x57, 0xcb, 0xb2, 0xe2, 0x7f, 0x89, 0xd4, 0xc5, 0xe5,
|
0xd0, 0x8f, 0x69, 0xe2, 0xe7, 0x17, 0x6e, 0x8a, 0x98, 0xf8, 0xd1, 0xa2, 0x28, 0xd9, 0x6f, 0x22,
|
||||||
0xf4, 0x25, 0xbc, 0xc9, 0x09, 0xf6, 0xee, 0x04, 0xfb, 0x74, 0xc2, 0x7b, 0xfd, 0x16, 0xac, 0x39,
|
0x54, 0x1e, 0x8f, 0x5f, 0x9c, 0x8c, 0x8e, 0xd3, 0x93, 0xe3, 0xf4, 0xd3, 0x71, 0xf2, 0x32, 0x73,
|
||||||
0x5b, 0x16, 0xdc, 0xfd, 0x04, 0x00, 0x00, 0xff, 0xff, 0x6f, 0x5a, 0xdf, 0xed, 0x0a, 0x01, 0x00,
|
0xf2, 0x3a, 0x73, 0x7a, 0x9a, 0x39, 0x79, 0x9f, 0x39, 0xa9, 0xcf, 0x96, 0x35, 0xb7, 0xdf, 0x01,
|
||||||
0x00,
|
0x00, 0x00, 0xff, 0xff, 0xbc, 0x46, 0xaf, 0x1d, 0x16, 0x01, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import "repos/protobuf/gogoproto/gogo.proto";
|
|||||||
option (gogoproto.goproto_getters_all) = false;
|
option (gogoproto.goproto_getters_all) = false;
|
||||||
option (gogoproto.sizer_all) = false;
|
option (gogoproto.sizer_all) = false;
|
||||||
option (gogoproto.protosizer_all) = true;
|
option (gogoproto.protosizer_all) = true;
|
||||||
|
option (gogoproto.goproto_unkeyed_all) = false;
|
||||||
|
option (gogoproto.goproto_unrecognized_all) = false;
|
||||||
|
option (gogoproto.goproto_sizecache_all) = false;
|
||||||
|
|
||||||
message Announce {
|
message Announce {
|
||||||
bytes id = 1 [(gogoproto.customname) = "ID", (gogoproto.customtype) = "github.com/syncthing/syncthing/lib/protocol.DeviceID", (gogoproto.nullable) = false];
|
bytes id = 1 [(gogoproto.customname) = "ID", (gogoproto.customtype) = "github.com/syncthing/syncthing/lib/protocol.DeviceID", (gogoproto.nullable) = false];
|
||||||
|
|||||||
+753
-247
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,9 @@ option (gogoproto.sizer_all) = false;
|
|||||||
option (gogoproto.protosizer_all) = true;
|
option (gogoproto.protosizer_all) = true;
|
||||||
option (gogoproto.goproto_enum_stringer_all) = true;
|
option (gogoproto.goproto_enum_stringer_all) = true;
|
||||||
option (gogoproto.goproto_enum_prefix_all) = false;
|
option (gogoproto.goproto_enum_prefix_all) = false;
|
||||||
|
option (gogoproto.goproto_unkeyed_all) = false;
|
||||||
|
option (gogoproto.goproto_unrecognized_all) = false;
|
||||||
|
option (gogoproto.goproto_sizecache_all) = false;
|
||||||
|
|
||||||
// --- Pre-auth ---
|
// --- Pre-auth ---
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,6 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: deviceid_test.proto
|
// source: deviceid_test.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package protocol is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
deviceid_test.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
TestOldDeviceID
|
|
||||||
TestNewDeviceID
|
|
||||||
*/
|
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
@@ -35,19 +25,75 @@ type TestOldDeviceID struct {
|
|||||||
Test []byte `protobuf:"bytes,1,opt,name=test,proto3" json:"test,omitempty"`
|
Test []byte `protobuf:"bytes,1,opt,name=test,proto3" json:"test,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *TestOldDeviceID) Reset() { *m = TestOldDeviceID{} }
|
func (m *TestOldDeviceID) Reset() { *m = TestOldDeviceID{} }
|
||||||
func (m *TestOldDeviceID) String() string { return proto.CompactTextString(m) }
|
func (m *TestOldDeviceID) String() string { return proto.CompactTextString(m) }
|
||||||
func (*TestOldDeviceID) ProtoMessage() {}
|
func (*TestOldDeviceID) ProtoMessage() {}
|
||||||
func (*TestOldDeviceID) Descriptor() ([]byte, []int) { return fileDescriptorDeviceidTest, []int{0} }
|
func (*TestOldDeviceID) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_deviceid_test_36bcb89b605bdafe, []int{0}
|
||||||
|
}
|
||||||
|
func (m *TestOldDeviceID) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *TestOldDeviceID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_TestOldDeviceID.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *TestOldDeviceID) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_TestOldDeviceID.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *TestOldDeviceID) XXX_Size() int {
|
||||||
|
return m.ProtoSize()
|
||||||
|
}
|
||||||
|
func (m *TestOldDeviceID) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_TestOldDeviceID.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_TestOldDeviceID proto.InternalMessageInfo
|
||||||
|
|
||||||
type TestNewDeviceID struct {
|
type TestNewDeviceID struct {
|
||||||
Test DeviceID `protobuf:"bytes,1,opt,name=test,proto3,customtype=DeviceID" json:"test"`
|
Test DeviceID `protobuf:"bytes,1,opt,name=test,proto3,customtype=DeviceID" json:"test"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *TestNewDeviceID) Reset() { *m = TestNewDeviceID{} }
|
func (m *TestNewDeviceID) Reset() { *m = TestNewDeviceID{} }
|
||||||
func (m *TestNewDeviceID) String() string { return proto.CompactTextString(m) }
|
func (m *TestNewDeviceID) String() string { return proto.CompactTextString(m) }
|
||||||
func (*TestNewDeviceID) ProtoMessage() {}
|
func (*TestNewDeviceID) ProtoMessage() {}
|
||||||
func (*TestNewDeviceID) Descriptor() ([]byte, []int) { return fileDescriptorDeviceidTest, []int{1} }
|
func (*TestNewDeviceID) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_deviceid_test_36bcb89b605bdafe, []int{1}
|
||||||
|
}
|
||||||
|
func (m *TestNewDeviceID) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *TestNewDeviceID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_TestNewDeviceID.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *TestNewDeviceID) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_TestNewDeviceID.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *TestNewDeviceID) XXX_Size() int {
|
||||||
|
return m.ProtoSize()
|
||||||
|
}
|
||||||
|
func (m *TestNewDeviceID) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_TestNewDeviceID.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_TestNewDeviceID proto.InternalMessageInfo
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*TestOldDeviceID)(nil), "protocol.TestOldDeviceID")
|
proto.RegisterType((*TestOldDeviceID)(nil), "protocol.TestOldDeviceID")
|
||||||
@@ -103,24 +149,6 @@ func (m *TestNewDeviceID) MarshalTo(dAtA []byte) (int, error) {
|
|||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeFixed64DeviceidTest(dAtA []byte, offset int, v uint64) int {
|
|
||||||
dAtA[offset] = uint8(v)
|
|
||||||
dAtA[offset+1] = uint8(v >> 8)
|
|
||||||
dAtA[offset+2] = uint8(v >> 16)
|
|
||||||
dAtA[offset+3] = uint8(v >> 24)
|
|
||||||
dAtA[offset+4] = uint8(v >> 32)
|
|
||||||
dAtA[offset+5] = uint8(v >> 40)
|
|
||||||
dAtA[offset+6] = uint8(v >> 48)
|
|
||||||
dAtA[offset+7] = uint8(v >> 56)
|
|
||||||
return offset + 8
|
|
||||||
}
|
|
||||||
func encodeFixed32DeviceidTest(dAtA []byte, offset int, v uint32) int {
|
|
||||||
dAtA[offset] = uint8(v)
|
|
||||||
dAtA[offset+1] = uint8(v >> 8)
|
|
||||||
dAtA[offset+2] = uint8(v >> 16)
|
|
||||||
dAtA[offset+3] = uint8(v >> 24)
|
|
||||||
return offset + 4
|
|
||||||
}
|
|
||||||
func encodeVarintDeviceidTest(dAtA []byte, offset int, v uint64) int {
|
func encodeVarintDeviceidTest(dAtA []byte, offset int, v uint64) int {
|
||||||
for v >= 1<<7 {
|
for v >= 1<<7 {
|
||||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||||
@@ -131,6 +159,9 @@ func encodeVarintDeviceidTest(dAtA []byte, offset int, v uint64) int {
|
|||||||
return offset + 1
|
return offset + 1
|
||||||
}
|
}
|
||||||
func (m *TestOldDeviceID) ProtoSize() (n int) {
|
func (m *TestOldDeviceID) ProtoSize() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
l = len(m.Test)
|
l = len(m.Test)
|
||||||
@@ -141,6 +172,9 @@ func (m *TestOldDeviceID) ProtoSize() (n int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *TestNewDeviceID) ProtoSize() (n int) {
|
func (m *TestNewDeviceID) ProtoSize() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
l = m.Test.ProtoSize()
|
l = m.Test.ProtoSize()
|
||||||
@@ -427,10 +461,10 @@ var (
|
|||||||
ErrIntOverflowDeviceidTest = fmt.Errorf("proto: integer overflow")
|
ErrIntOverflowDeviceidTest = fmt.Errorf("proto: integer overflow")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { proto.RegisterFile("deviceid_test.proto", fileDescriptorDeviceidTest) }
|
func init() { proto.RegisterFile("deviceid_test.proto", fileDescriptor_deviceid_test_36bcb89b605bdafe) }
|
||||||
|
|
||||||
var fileDescriptorDeviceidTest = []byte{
|
var fileDescriptor_deviceid_test_36bcb89b605bdafe = []byte{
|
||||||
// 169 bytes of a gzipped FileDescriptorProto
|
// 182 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4e, 0x49, 0x2d, 0xcb,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4e, 0x49, 0x2d, 0xcb,
|
||||||
0x4c, 0x4e, 0xcd, 0x4c, 0x89, 0x2f, 0x49, 0x2d, 0x2e, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17,
|
0x4c, 0x4e, 0xcd, 0x4c, 0x89, 0x2f, 0x49, 0x2d, 0x2e, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17,
|
||||||
0xe2, 0x00, 0x53, 0xc9, 0xf9, 0x39, 0x52, 0xca, 0x45, 0xa9, 0x05, 0xf9, 0xc5, 0xfa, 0x60, 0x7e,
|
0xe2, 0x00, 0x53, 0xc9, 0xf9, 0x39, 0x52, 0xca, 0x45, 0xa9, 0x05, 0xf9, 0xc5, 0xfa, 0x60, 0x7e,
|
||||||
@@ -438,8 +472,9 @@ var fileDescriptorDeviceidTest = []byte{
|
|||||||
0xf1, 0x87, 0xa4, 0x16, 0x97, 0xf8, 0xe7, 0xa4, 0xb8, 0x80, 0x0d, 0xf3, 0x74, 0x11, 0x12, 0xe2,
|
0xf1, 0x87, 0xa4, 0x16, 0x97, 0xf8, 0xe7, 0xa4, 0xb8, 0x80, 0x0d, 0xf3, 0x74, 0x11, 0x12, 0xe2,
|
||||||
0x62, 0x01, 0x99, 0x27, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x13, 0x04, 0x66, 0x2b, 0x99, 0x43, 0x94,
|
0x62, 0x01, 0x99, 0x27, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x13, 0x04, 0x66, 0x2b, 0x99, 0x43, 0x94,
|
||||||
0xf9, 0xa5, 0x96, 0xc3, 0x95, 0xa9, 0x20, 0x2b, 0x73, 0x12, 0x38, 0x71, 0x4f, 0x9e, 0xe1, 0xd6,
|
0xf9, 0xa5, 0x96, 0xc3, 0x95, 0xa9, 0x20, 0x2b, 0x73, 0x12, 0x38, 0x71, 0x4f, 0x9e, 0xe1, 0xd6,
|
||||||
0x3d, 0x79, 0x0e, 0x98, 0x3c, 0x44, 0xa3, 0x93, 0xcc, 0x89, 0x87, 0x72, 0x0c, 0x17, 0x1e, 0xca,
|
0x3d, 0x79, 0x0e, 0x98, 0x3c, 0x44, 0xa3, 0x93, 0xc6, 0x89, 0x87, 0x72, 0x0c, 0x17, 0x1e, 0xca,
|
||||||
0x31, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x0c, 0x2f, 0x1e,
|
0x31, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x0c, 0x2f, 0x1e,
|
||||||
0xc9, 0x31, 0x2c, 0x78, 0x2c, 0xc7, 0x98, 0xc4, 0x06, 0x76, 0x84, 0x31, 0x20, 0x00, 0x00, 0xff,
|
0xc9, 0x31, 0x4c, 0x78, 0x2c, 0xc7, 0xb0, 0xe0, 0xb1, 0x1c, 0xe3, 0x85, 0xc7, 0x72, 0x0c, 0x37,
|
||||||
0xff, 0x82, 0x8f, 0xec, 0x3e, 0xca, 0x00, 0x00, 0x00,
|
0x1e, 0xcb, 0x31, 0x24, 0xb1, 0x81, 0x1d, 0x64, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xe3, 0x96,
|
||||||
|
0x3e, 0xc0, 0xd6, 0x00, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ option (gogoproto.sizer_all) = false;
|
|||||||
option (gogoproto.protosizer_all) = true;
|
option (gogoproto.protosizer_all) = true;
|
||||||
option (gogoproto.goproto_enum_stringer_all) = false;
|
option (gogoproto.goproto_enum_stringer_all) = false;
|
||||||
option (gogoproto.goproto_enum_prefix_all) = false;
|
option (gogoproto.goproto_enum_prefix_all) = false;
|
||||||
|
option (gogoproto.goproto_unkeyed_all) = false;
|
||||||
|
option (gogoproto.goproto_unrecognized_all) = false;
|
||||||
|
option (gogoproto.goproto_sizecache_all) = false;
|
||||||
|
|
||||||
message TestOldDeviceID {
|
message TestOldDeviceID {
|
||||||
bytes test = 1;
|
bytes test = 1;
|
||||||
|
|||||||
+2
-3
@@ -1,7 +1,6 @@
|
|||||||
Protocol Buffers for Go with Gadgets
|
|
||||||
|
|
||||||
Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
||||||
http://github.com/gogo/protobuf
|
|
||||||
|
Protocol Buffers for Go with Gadgets
|
||||||
|
|
||||||
Go support for Protocol Buffers - Google's data interchange format
|
Go support for Protocol Buffers - Google's data interchange format
|
||||||
|
|
||||||
|
|||||||
Generated
Vendored
+1814
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+273
@@ -0,0 +1,273 @@
|
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
package conformance;
|
||||||
|
option java_package = "com.google.protobuf.conformance";
|
||||||
|
|
||||||
|
import "google/protobuf/any.proto";
|
||||||
|
import "google/protobuf/duration.proto";
|
||||||
|
import "google/protobuf/field_mask.proto";
|
||||||
|
import "google/protobuf/struct.proto";
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/protobuf/wrappers.proto";
|
||||||
|
|
||||||
|
// This defines the conformance testing protocol. This protocol exists between
|
||||||
|
// the conformance test suite itself and the code being tested. For each test,
|
||||||
|
// the suite will send a ConformanceRequest message and expect a
|
||||||
|
// ConformanceResponse message.
|
||||||
|
//
|
||||||
|
// You can either run the tests in two different ways:
|
||||||
|
//
|
||||||
|
// 1. in-process (using the interface in conformance_test.h).
|
||||||
|
//
|
||||||
|
// 2. as a sub-process communicating over a pipe. Information about how to
|
||||||
|
// do this is in conformance_test_runner.cc.
|
||||||
|
//
|
||||||
|
// Pros/cons of the two approaches:
|
||||||
|
//
|
||||||
|
// - running as a sub-process is much simpler for languages other than C/C++.
|
||||||
|
//
|
||||||
|
// - running as a sub-process may be more tricky in unusual environments like
|
||||||
|
// iOS apps, where fork/stdin/stdout are not available.
|
||||||
|
|
||||||
|
enum WireFormat {
|
||||||
|
UNSPECIFIED = 0;
|
||||||
|
PROTOBUF = 1;
|
||||||
|
JSON = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Represents a single test case's input. The testee should:
|
||||||
|
//
|
||||||
|
// 1. parse this proto (which should always succeed)
|
||||||
|
// 2. parse the protobuf or JSON payload in "payload" (which may fail)
|
||||||
|
// 3. if the parse succeeded, serialize the message in the requested format.
|
||||||
|
message ConformanceRequest {
|
||||||
|
// The payload (whether protobuf of JSON) is always for a TestAllTypes proto
|
||||||
|
// (see below).
|
||||||
|
oneof payload {
|
||||||
|
bytes protobuf_payload = 1;
|
||||||
|
string json_payload = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Which format should the testee serialize its message to?
|
||||||
|
WireFormat requested_output_format = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Represents a single test case's output.
|
||||||
|
message ConformanceResponse {
|
||||||
|
oneof result {
|
||||||
|
// This string should be set to indicate parsing failed. The string can
|
||||||
|
// provide more information about the parse error if it is available.
|
||||||
|
//
|
||||||
|
// Setting this string does not necessarily mean the testee failed the
|
||||||
|
// test. Some of the test cases are intentionally invalid input.
|
||||||
|
string parse_error = 1;
|
||||||
|
|
||||||
|
// If the input was successfully parsed but errors occurred when
|
||||||
|
// serializing it to the requested output format, set the error message in
|
||||||
|
// this field.
|
||||||
|
string serialize_error = 6;
|
||||||
|
|
||||||
|
// This should be set if some other error occurred. This will always
|
||||||
|
// indicate that the test failed. The string can provide more information
|
||||||
|
// about the failure.
|
||||||
|
string runtime_error = 2;
|
||||||
|
|
||||||
|
// If the input was successfully parsed and the requested output was
|
||||||
|
// protobuf, serialize it to protobuf and set it in this field.
|
||||||
|
bytes protobuf_payload = 3;
|
||||||
|
|
||||||
|
// If the input was successfully parsed and the requested output was JSON,
|
||||||
|
// serialize to JSON and set it in this field.
|
||||||
|
string json_payload = 4;
|
||||||
|
|
||||||
|
// For when the testee skipped the test, likely because a certain feature
|
||||||
|
// wasn't supported, like JSON input/output.
|
||||||
|
string skipped = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This proto includes every type of field in both singular and repeated
|
||||||
|
// forms.
|
||||||
|
message TestAllTypes {
|
||||||
|
message NestedMessage {
|
||||||
|
int32 a = 1;
|
||||||
|
TestAllTypes corecursive = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum NestedEnum {
|
||||||
|
FOO = 0;
|
||||||
|
BAR = 1;
|
||||||
|
BAZ = 2;
|
||||||
|
NEG = -1; // Intentionally negative.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Singular
|
||||||
|
int32 optional_int32 = 1;
|
||||||
|
int64 optional_int64 = 2;
|
||||||
|
uint32 optional_uint32 = 3;
|
||||||
|
uint64 optional_uint64 = 4;
|
||||||
|
sint32 optional_sint32 = 5;
|
||||||
|
sint64 optional_sint64 = 6;
|
||||||
|
fixed32 optional_fixed32 = 7;
|
||||||
|
fixed64 optional_fixed64 = 8;
|
||||||
|
sfixed32 optional_sfixed32 = 9;
|
||||||
|
sfixed64 optional_sfixed64 = 10;
|
||||||
|
float optional_float = 11;
|
||||||
|
double optional_double = 12;
|
||||||
|
bool optional_bool = 13;
|
||||||
|
string optional_string = 14;
|
||||||
|
bytes optional_bytes = 15;
|
||||||
|
|
||||||
|
NestedMessage optional_nested_message = 18;
|
||||||
|
ForeignMessage optional_foreign_message = 19;
|
||||||
|
|
||||||
|
NestedEnum optional_nested_enum = 21;
|
||||||
|
ForeignEnum optional_foreign_enum = 22;
|
||||||
|
|
||||||
|
string optional_string_piece = 24 [ctype=STRING_PIECE];
|
||||||
|
string optional_cord = 25 [ctype=CORD];
|
||||||
|
|
||||||
|
TestAllTypes recursive_message = 27;
|
||||||
|
|
||||||
|
// Repeated
|
||||||
|
repeated int32 repeated_int32 = 31;
|
||||||
|
repeated int64 repeated_int64 = 32;
|
||||||
|
repeated uint32 repeated_uint32 = 33;
|
||||||
|
repeated uint64 repeated_uint64 = 34;
|
||||||
|
repeated sint32 repeated_sint32 = 35;
|
||||||
|
repeated sint64 repeated_sint64 = 36;
|
||||||
|
repeated fixed32 repeated_fixed32 = 37;
|
||||||
|
repeated fixed64 repeated_fixed64 = 38;
|
||||||
|
repeated sfixed32 repeated_sfixed32 = 39;
|
||||||
|
repeated sfixed64 repeated_sfixed64 = 40;
|
||||||
|
repeated float repeated_float = 41;
|
||||||
|
repeated double repeated_double = 42;
|
||||||
|
repeated bool repeated_bool = 43;
|
||||||
|
repeated string repeated_string = 44;
|
||||||
|
repeated bytes repeated_bytes = 45;
|
||||||
|
|
||||||
|
repeated NestedMessage repeated_nested_message = 48;
|
||||||
|
repeated ForeignMessage repeated_foreign_message = 49;
|
||||||
|
|
||||||
|
repeated NestedEnum repeated_nested_enum = 51;
|
||||||
|
repeated ForeignEnum repeated_foreign_enum = 52;
|
||||||
|
|
||||||
|
repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
|
||||||
|
repeated string repeated_cord = 55 [ctype=CORD];
|
||||||
|
|
||||||
|
// Map
|
||||||
|
map < int32, int32> map_int32_int32 = 56;
|
||||||
|
map < int64, int64> map_int64_int64 = 57;
|
||||||
|
map < uint32, uint32> map_uint32_uint32 = 58;
|
||||||
|
map < uint64, uint64> map_uint64_uint64 = 59;
|
||||||
|
map < sint32, sint32> map_sint32_sint32 = 60;
|
||||||
|
map < sint64, sint64> map_sint64_sint64 = 61;
|
||||||
|
map < fixed32, fixed32> map_fixed32_fixed32 = 62;
|
||||||
|
map < fixed64, fixed64> map_fixed64_fixed64 = 63;
|
||||||
|
map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
|
||||||
|
map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
|
||||||
|
map < int32, float> map_int32_float = 66;
|
||||||
|
map < int32, double> map_int32_double = 67;
|
||||||
|
map < bool, bool> map_bool_bool = 68;
|
||||||
|
map < string, string> map_string_string = 69;
|
||||||
|
map < string, bytes> map_string_bytes = 70;
|
||||||
|
map < string, NestedMessage> map_string_nested_message = 71;
|
||||||
|
map < string, ForeignMessage> map_string_foreign_message = 72;
|
||||||
|
map < string, NestedEnum> map_string_nested_enum = 73;
|
||||||
|
map < string, ForeignEnum> map_string_foreign_enum = 74;
|
||||||
|
|
||||||
|
oneof oneof_field {
|
||||||
|
uint32 oneof_uint32 = 111;
|
||||||
|
NestedMessage oneof_nested_message = 112;
|
||||||
|
string oneof_string = 113;
|
||||||
|
bytes oneof_bytes = 114;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Well-known types
|
||||||
|
google.protobuf.BoolValue optional_bool_wrapper = 201;
|
||||||
|
google.protobuf.Int32Value optional_int32_wrapper = 202;
|
||||||
|
google.protobuf.Int64Value optional_int64_wrapper = 203;
|
||||||
|
google.protobuf.UInt32Value optional_uint32_wrapper = 204;
|
||||||
|
google.protobuf.UInt64Value optional_uint64_wrapper = 205;
|
||||||
|
google.protobuf.FloatValue optional_float_wrapper = 206;
|
||||||
|
google.protobuf.DoubleValue optional_double_wrapper = 207;
|
||||||
|
google.protobuf.StringValue optional_string_wrapper = 208;
|
||||||
|
google.protobuf.BytesValue optional_bytes_wrapper = 209;
|
||||||
|
|
||||||
|
repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;
|
||||||
|
repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;
|
||||||
|
repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;
|
||||||
|
repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;
|
||||||
|
repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;
|
||||||
|
repeated google.protobuf.FloatValue repeated_float_wrapper = 216;
|
||||||
|
repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;
|
||||||
|
repeated google.protobuf.StringValue repeated_string_wrapper = 218;
|
||||||
|
repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;
|
||||||
|
|
||||||
|
google.protobuf.Duration optional_duration = 301;
|
||||||
|
google.protobuf.Timestamp optional_timestamp = 302;
|
||||||
|
google.protobuf.FieldMask optional_field_mask = 303;
|
||||||
|
google.protobuf.Struct optional_struct = 304;
|
||||||
|
google.protobuf.Any optional_any = 305;
|
||||||
|
google.protobuf.Value optional_value = 306;
|
||||||
|
|
||||||
|
repeated google.protobuf.Duration repeated_duration = 311;
|
||||||
|
repeated google.protobuf.Timestamp repeated_timestamp = 312;
|
||||||
|
repeated google.protobuf.FieldMask repeated_fieldmask = 313;
|
||||||
|
repeated google.protobuf.Struct repeated_struct = 324;
|
||||||
|
repeated google.protobuf.Any repeated_any = 315;
|
||||||
|
repeated google.protobuf.Value repeated_value = 316;
|
||||||
|
|
||||||
|
// Test field-name-to-JSON-name convention.
|
||||||
|
int32 fieldname1 = 401;
|
||||||
|
int32 field_name2 = 402;
|
||||||
|
int32 _field_name3 = 403;
|
||||||
|
int32 field__name4_ = 404;
|
||||||
|
int32 field0name5 = 405;
|
||||||
|
int32 field_0_name6 = 406;
|
||||||
|
int32 fieldName7 = 407;
|
||||||
|
int32 FieldName8 = 408;
|
||||||
|
int32 field_Name9 = 409;
|
||||||
|
int32 Field_Name10 = 410;
|
||||||
|
int32 FIELD_NAME11 = 411;
|
||||||
|
int32 FIELD_name12 = 412;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ForeignMessage {
|
||||||
|
int32 c = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ForeignEnum {
|
||||||
|
FOREIGN_FOO = 0;
|
||||||
|
FOREIGN_BAR = 1;
|
||||||
|
FOREIGN_BAZ = 2;
|
||||||
|
}
|
||||||
+1
-1
@@ -162,7 +162,7 @@ The most complete way to see examples is to look at
|
|||||||
github.com/gogo/protobuf/test/thetest.proto
|
github.com/gogo/protobuf/test/thetest.proto
|
||||||
|
|
||||||
Gogoprototest is a seperate project,
|
Gogoprototest is a seperate project,
|
||||||
because we want to keep gogoprotobuf independant of goprotobuf,
|
because we want to keep gogoprotobuf independent of goprotobuf,
|
||||||
but we still want to test it thoroughly.
|
but we still want to test it thoroughly.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
+227
-159
@@ -1,20 +1,12 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: gogo.proto
|
// source: gogo.proto
|
||||||
|
|
||||||
/*
|
package gogoproto // import "github.com/gogo/protobuf/gogoproto"
|
||||||
Package gogoproto is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
gogo.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
*/
|
|
||||||
package gogoproto
|
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
import descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
var _ = proto.Marshal
|
var _ = proto.Marshal
|
||||||
@@ -28,7 +20,7 @@ var _ = math.Inf
|
|||||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
var E_GoprotoEnumPrefix = &proto.ExtensionDesc{
|
var E_GoprotoEnumPrefix = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.EnumOptions)(nil),
|
ExtendedType: (*descriptor.EnumOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 62001,
|
Field: 62001,
|
||||||
Name: "gogoproto.goproto_enum_prefix",
|
Name: "gogoproto.goproto_enum_prefix",
|
||||||
@@ -37,7 +29,7 @@ var E_GoprotoEnumPrefix = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoEnumStringer = &proto.ExtensionDesc{
|
var E_GoprotoEnumStringer = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.EnumOptions)(nil),
|
ExtendedType: (*descriptor.EnumOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 62021,
|
Field: 62021,
|
||||||
Name: "gogoproto.goproto_enum_stringer",
|
Name: "gogoproto.goproto_enum_stringer",
|
||||||
@@ -46,7 +38,7 @@ var E_GoprotoEnumStringer = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_EnumStringer = &proto.ExtensionDesc{
|
var E_EnumStringer = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.EnumOptions)(nil),
|
ExtendedType: (*descriptor.EnumOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 62022,
|
Field: 62022,
|
||||||
Name: "gogoproto.enum_stringer",
|
Name: "gogoproto.enum_stringer",
|
||||||
@@ -55,7 +47,7 @@ var E_EnumStringer = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_EnumCustomname = &proto.ExtensionDesc{
|
var E_EnumCustomname = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.EnumOptions)(nil),
|
ExtendedType: (*descriptor.EnumOptions)(nil),
|
||||||
ExtensionType: (*string)(nil),
|
ExtensionType: (*string)(nil),
|
||||||
Field: 62023,
|
Field: 62023,
|
||||||
Name: "gogoproto.enum_customname",
|
Name: "gogoproto.enum_customname",
|
||||||
@@ -64,7 +56,7 @@ var E_EnumCustomname = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Enumdecl = &proto.ExtensionDesc{
|
var E_Enumdecl = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.EnumOptions)(nil),
|
ExtendedType: (*descriptor.EnumOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 62024,
|
Field: 62024,
|
||||||
Name: "gogoproto.enumdecl",
|
Name: "gogoproto.enumdecl",
|
||||||
@@ -73,7 +65,7 @@ var E_Enumdecl = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_EnumvalueCustomname = &proto.ExtensionDesc{
|
var E_EnumvalueCustomname = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.EnumValueOptions)(nil),
|
ExtendedType: (*descriptor.EnumValueOptions)(nil),
|
||||||
ExtensionType: (*string)(nil),
|
ExtensionType: (*string)(nil),
|
||||||
Field: 66001,
|
Field: 66001,
|
||||||
Name: "gogoproto.enumvalue_customname",
|
Name: "gogoproto.enumvalue_customname",
|
||||||
@@ -82,7 +74,7 @@ var E_EnumvalueCustomname = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoGettersAll = &proto.ExtensionDesc{
|
var E_GoprotoGettersAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63001,
|
Field: 63001,
|
||||||
Name: "gogoproto.goproto_getters_all",
|
Name: "gogoproto.goproto_getters_all",
|
||||||
@@ -91,7 +83,7 @@ var E_GoprotoGettersAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoEnumPrefixAll = &proto.ExtensionDesc{
|
var E_GoprotoEnumPrefixAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63002,
|
Field: 63002,
|
||||||
Name: "gogoproto.goproto_enum_prefix_all",
|
Name: "gogoproto.goproto_enum_prefix_all",
|
||||||
@@ -100,7 +92,7 @@ var E_GoprotoEnumPrefixAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoStringerAll = &proto.ExtensionDesc{
|
var E_GoprotoStringerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63003,
|
Field: 63003,
|
||||||
Name: "gogoproto.goproto_stringer_all",
|
Name: "gogoproto.goproto_stringer_all",
|
||||||
@@ -109,7 +101,7 @@ var E_GoprotoStringerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_VerboseEqualAll = &proto.ExtensionDesc{
|
var E_VerboseEqualAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63004,
|
Field: 63004,
|
||||||
Name: "gogoproto.verbose_equal_all",
|
Name: "gogoproto.verbose_equal_all",
|
||||||
@@ -118,7 +110,7 @@ var E_VerboseEqualAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_FaceAll = &proto.ExtensionDesc{
|
var E_FaceAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63005,
|
Field: 63005,
|
||||||
Name: "gogoproto.face_all",
|
Name: "gogoproto.face_all",
|
||||||
@@ -127,7 +119,7 @@ var E_FaceAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GostringAll = &proto.ExtensionDesc{
|
var E_GostringAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63006,
|
Field: 63006,
|
||||||
Name: "gogoproto.gostring_all",
|
Name: "gogoproto.gostring_all",
|
||||||
@@ -136,7 +128,7 @@ var E_GostringAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_PopulateAll = &proto.ExtensionDesc{
|
var E_PopulateAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63007,
|
Field: 63007,
|
||||||
Name: "gogoproto.populate_all",
|
Name: "gogoproto.populate_all",
|
||||||
@@ -145,7 +137,7 @@ var E_PopulateAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_StringerAll = &proto.ExtensionDesc{
|
var E_StringerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63008,
|
Field: 63008,
|
||||||
Name: "gogoproto.stringer_all",
|
Name: "gogoproto.stringer_all",
|
||||||
@@ -154,7 +146,7 @@ var E_StringerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_OnlyoneAll = &proto.ExtensionDesc{
|
var E_OnlyoneAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63009,
|
Field: 63009,
|
||||||
Name: "gogoproto.onlyone_all",
|
Name: "gogoproto.onlyone_all",
|
||||||
@@ -163,7 +155,7 @@ var E_OnlyoneAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_EqualAll = &proto.ExtensionDesc{
|
var E_EqualAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63013,
|
Field: 63013,
|
||||||
Name: "gogoproto.equal_all",
|
Name: "gogoproto.equal_all",
|
||||||
@@ -172,7 +164,7 @@ var E_EqualAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_DescriptionAll = &proto.ExtensionDesc{
|
var E_DescriptionAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63014,
|
Field: 63014,
|
||||||
Name: "gogoproto.description_all",
|
Name: "gogoproto.description_all",
|
||||||
@@ -181,7 +173,7 @@ var E_DescriptionAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_TestgenAll = &proto.ExtensionDesc{
|
var E_TestgenAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63015,
|
Field: 63015,
|
||||||
Name: "gogoproto.testgen_all",
|
Name: "gogoproto.testgen_all",
|
||||||
@@ -190,7 +182,7 @@ var E_TestgenAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_BenchgenAll = &proto.ExtensionDesc{
|
var E_BenchgenAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63016,
|
Field: 63016,
|
||||||
Name: "gogoproto.benchgen_all",
|
Name: "gogoproto.benchgen_all",
|
||||||
@@ -199,7 +191,7 @@ var E_BenchgenAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_MarshalerAll = &proto.ExtensionDesc{
|
var E_MarshalerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63017,
|
Field: 63017,
|
||||||
Name: "gogoproto.marshaler_all",
|
Name: "gogoproto.marshaler_all",
|
||||||
@@ -208,7 +200,7 @@ var E_MarshalerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_UnmarshalerAll = &proto.ExtensionDesc{
|
var E_UnmarshalerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63018,
|
Field: 63018,
|
||||||
Name: "gogoproto.unmarshaler_all",
|
Name: "gogoproto.unmarshaler_all",
|
||||||
@@ -217,7 +209,7 @@ var E_UnmarshalerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_StableMarshalerAll = &proto.ExtensionDesc{
|
var E_StableMarshalerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63019,
|
Field: 63019,
|
||||||
Name: "gogoproto.stable_marshaler_all",
|
Name: "gogoproto.stable_marshaler_all",
|
||||||
@@ -226,7 +218,7 @@ var E_StableMarshalerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_SizerAll = &proto.ExtensionDesc{
|
var E_SizerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63020,
|
Field: 63020,
|
||||||
Name: "gogoproto.sizer_all",
|
Name: "gogoproto.sizer_all",
|
||||||
@@ -235,7 +227,7 @@ var E_SizerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoEnumStringerAll = &proto.ExtensionDesc{
|
var E_GoprotoEnumStringerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63021,
|
Field: 63021,
|
||||||
Name: "gogoproto.goproto_enum_stringer_all",
|
Name: "gogoproto.goproto_enum_stringer_all",
|
||||||
@@ -244,7 +236,7 @@ var E_GoprotoEnumStringerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_EnumStringerAll = &proto.ExtensionDesc{
|
var E_EnumStringerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63022,
|
Field: 63022,
|
||||||
Name: "gogoproto.enum_stringer_all",
|
Name: "gogoproto.enum_stringer_all",
|
||||||
@@ -253,7 +245,7 @@ var E_EnumStringerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_UnsafeMarshalerAll = &proto.ExtensionDesc{
|
var E_UnsafeMarshalerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63023,
|
Field: 63023,
|
||||||
Name: "gogoproto.unsafe_marshaler_all",
|
Name: "gogoproto.unsafe_marshaler_all",
|
||||||
@@ -262,7 +254,7 @@ var E_UnsafeMarshalerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_UnsafeUnmarshalerAll = &proto.ExtensionDesc{
|
var E_UnsafeUnmarshalerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63024,
|
Field: 63024,
|
||||||
Name: "gogoproto.unsafe_unmarshaler_all",
|
Name: "gogoproto.unsafe_unmarshaler_all",
|
||||||
@@ -271,7 +263,7 @@ var E_UnsafeUnmarshalerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoExtensionsMapAll = &proto.ExtensionDesc{
|
var E_GoprotoExtensionsMapAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63025,
|
Field: 63025,
|
||||||
Name: "gogoproto.goproto_extensions_map_all",
|
Name: "gogoproto.goproto_extensions_map_all",
|
||||||
@@ -280,7 +272,7 @@ var E_GoprotoExtensionsMapAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoUnrecognizedAll = &proto.ExtensionDesc{
|
var E_GoprotoUnrecognizedAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63026,
|
Field: 63026,
|
||||||
Name: "gogoproto.goproto_unrecognized_all",
|
Name: "gogoproto.goproto_unrecognized_all",
|
||||||
@@ -289,7 +281,7 @@ var E_GoprotoUnrecognizedAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GogoprotoImport = &proto.ExtensionDesc{
|
var E_GogoprotoImport = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63027,
|
Field: 63027,
|
||||||
Name: "gogoproto.gogoproto_import",
|
Name: "gogoproto.gogoproto_import",
|
||||||
@@ -298,7 +290,7 @@ var E_GogoprotoImport = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_ProtosizerAll = &proto.ExtensionDesc{
|
var E_ProtosizerAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63028,
|
Field: 63028,
|
||||||
Name: "gogoproto.protosizer_all",
|
Name: "gogoproto.protosizer_all",
|
||||||
@@ -307,7 +299,7 @@ var E_ProtosizerAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_CompareAll = &proto.ExtensionDesc{
|
var E_CompareAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63029,
|
Field: 63029,
|
||||||
Name: "gogoproto.compare_all",
|
Name: "gogoproto.compare_all",
|
||||||
@@ -316,7 +308,7 @@ var E_CompareAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_TypedeclAll = &proto.ExtensionDesc{
|
var E_TypedeclAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63030,
|
Field: 63030,
|
||||||
Name: "gogoproto.typedecl_all",
|
Name: "gogoproto.typedecl_all",
|
||||||
@@ -325,7 +317,7 @@ var E_TypedeclAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_EnumdeclAll = &proto.ExtensionDesc{
|
var E_EnumdeclAll = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63031,
|
Field: 63031,
|
||||||
Name: "gogoproto.enumdecl_all",
|
Name: "gogoproto.enumdecl_all",
|
||||||
@@ -334,7 +326,7 @@ var E_EnumdeclAll = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoRegistration = &proto.ExtensionDesc{
|
var E_GoprotoRegistration = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 63032,
|
Field: 63032,
|
||||||
Name: "gogoproto.goproto_registration",
|
Name: "gogoproto.goproto_registration",
|
||||||
@@ -342,8 +334,35 @@ var E_GoprotoRegistration = &proto.ExtensionDesc{
|
|||||||
Filename: "gogo.proto",
|
Filename: "gogo.proto",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var E_MessagenameAll = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 63033,
|
||||||
|
Name: "gogoproto.messagename_all",
|
||||||
|
Tag: "varint,63033,opt,name=messagename_all,json=messagenameAll",
|
||||||
|
Filename: "gogo.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_GoprotoSizecacheAll = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 63034,
|
||||||
|
Name: "gogoproto.goproto_sizecache_all",
|
||||||
|
Tag: "varint,63034,opt,name=goproto_sizecache_all,json=goprotoSizecacheAll",
|
||||||
|
Filename: "gogo.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_GoprotoUnkeyedAll = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 63035,
|
||||||
|
Name: "gogoproto.goproto_unkeyed_all",
|
||||||
|
Tag: "varint,63035,opt,name=goproto_unkeyed_all,json=goprotoUnkeyedAll",
|
||||||
|
Filename: "gogo.proto",
|
||||||
|
}
|
||||||
|
|
||||||
var E_GoprotoGetters = &proto.ExtensionDesc{
|
var E_GoprotoGetters = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64001,
|
Field: 64001,
|
||||||
Name: "gogoproto.goproto_getters",
|
Name: "gogoproto.goproto_getters",
|
||||||
@@ -352,7 +371,7 @@ var E_GoprotoGetters = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoStringer = &proto.ExtensionDesc{
|
var E_GoprotoStringer = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64003,
|
Field: 64003,
|
||||||
Name: "gogoproto.goproto_stringer",
|
Name: "gogoproto.goproto_stringer",
|
||||||
@@ -361,7 +380,7 @@ var E_GoprotoStringer = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_VerboseEqual = &proto.ExtensionDesc{
|
var E_VerboseEqual = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64004,
|
Field: 64004,
|
||||||
Name: "gogoproto.verbose_equal",
|
Name: "gogoproto.verbose_equal",
|
||||||
@@ -370,7 +389,7 @@ var E_VerboseEqual = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Face = &proto.ExtensionDesc{
|
var E_Face = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64005,
|
Field: 64005,
|
||||||
Name: "gogoproto.face",
|
Name: "gogoproto.face",
|
||||||
@@ -379,7 +398,7 @@ var E_Face = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Gostring = &proto.ExtensionDesc{
|
var E_Gostring = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64006,
|
Field: 64006,
|
||||||
Name: "gogoproto.gostring",
|
Name: "gogoproto.gostring",
|
||||||
@@ -388,7 +407,7 @@ var E_Gostring = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Populate = &proto.ExtensionDesc{
|
var E_Populate = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64007,
|
Field: 64007,
|
||||||
Name: "gogoproto.populate",
|
Name: "gogoproto.populate",
|
||||||
@@ -397,7 +416,7 @@ var E_Populate = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Stringer = &proto.ExtensionDesc{
|
var E_Stringer = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 67008,
|
Field: 67008,
|
||||||
Name: "gogoproto.stringer",
|
Name: "gogoproto.stringer",
|
||||||
@@ -406,7 +425,7 @@ var E_Stringer = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Onlyone = &proto.ExtensionDesc{
|
var E_Onlyone = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64009,
|
Field: 64009,
|
||||||
Name: "gogoproto.onlyone",
|
Name: "gogoproto.onlyone",
|
||||||
@@ -415,7 +434,7 @@ var E_Onlyone = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Equal = &proto.ExtensionDesc{
|
var E_Equal = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64013,
|
Field: 64013,
|
||||||
Name: "gogoproto.equal",
|
Name: "gogoproto.equal",
|
||||||
@@ -424,7 +443,7 @@ var E_Equal = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Description = &proto.ExtensionDesc{
|
var E_Description = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64014,
|
Field: 64014,
|
||||||
Name: "gogoproto.description",
|
Name: "gogoproto.description",
|
||||||
@@ -433,7 +452,7 @@ var E_Description = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Testgen = &proto.ExtensionDesc{
|
var E_Testgen = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64015,
|
Field: 64015,
|
||||||
Name: "gogoproto.testgen",
|
Name: "gogoproto.testgen",
|
||||||
@@ -442,7 +461,7 @@ var E_Testgen = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Benchgen = &proto.ExtensionDesc{
|
var E_Benchgen = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64016,
|
Field: 64016,
|
||||||
Name: "gogoproto.benchgen",
|
Name: "gogoproto.benchgen",
|
||||||
@@ -451,7 +470,7 @@ var E_Benchgen = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Marshaler = &proto.ExtensionDesc{
|
var E_Marshaler = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64017,
|
Field: 64017,
|
||||||
Name: "gogoproto.marshaler",
|
Name: "gogoproto.marshaler",
|
||||||
@@ -460,7 +479,7 @@ var E_Marshaler = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Unmarshaler = &proto.ExtensionDesc{
|
var E_Unmarshaler = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64018,
|
Field: 64018,
|
||||||
Name: "gogoproto.unmarshaler",
|
Name: "gogoproto.unmarshaler",
|
||||||
@@ -469,7 +488,7 @@ var E_Unmarshaler = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_StableMarshaler = &proto.ExtensionDesc{
|
var E_StableMarshaler = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64019,
|
Field: 64019,
|
||||||
Name: "gogoproto.stable_marshaler",
|
Name: "gogoproto.stable_marshaler",
|
||||||
@@ -478,7 +497,7 @@ var E_StableMarshaler = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Sizer = &proto.ExtensionDesc{
|
var E_Sizer = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64020,
|
Field: 64020,
|
||||||
Name: "gogoproto.sizer",
|
Name: "gogoproto.sizer",
|
||||||
@@ -487,7 +506,7 @@ var E_Sizer = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_UnsafeMarshaler = &proto.ExtensionDesc{
|
var E_UnsafeMarshaler = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64023,
|
Field: 64023,
|
||||||
Name: "gogoproto.unsafe_marshaler",
|
Name: "gogoproto.unsafe_marshaler",
|
||||||
@@ -496,7 +515,7 @@ var E_UnsafeMarshaler = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_UnsafeUnmarshaler = &proto.ExtensionDesc{
|
var E_UnsafeUnmarshaler = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64024,
|
Field: 64024,
|
||||||
Name: "gogoproto.unsafe_unmarshaler",
|
Name: "gogoproto.unsafe_unmarshaler",
|
||||||
@@ -505,7 +524,7 @@ var E_UnsafeUnmarshaler = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoExtensionsMap = &proto.ExtensionDesc{
|
var E_GoprotoExtensionsMap = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64025,
|
Field: 64025,
|
||||||
Name: "gogoproto.goproto_extensions_map",
|
Name: "gogoproto.goproto_extensions_map",
|
||||||
@@ -514,7 +533,7 @@ var E_GoprotoExtensionsMap = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_GoprotoUnrecognized = &proto.ExtensionDesc{
|
var E_GoprotoUnrecognized = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64026,
|
Field: 64026,
|
||||||
Name: "gogoproto.goproto_unrecognized",
|
Name: "gogoproto.goproto_unrecognized",
|
||||||
@@ -523,7 +542,7 @@ var E_GoprotoUnrecognized = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Protosizer = &proto.ExtensionDesc{
|
var E_Protosizer = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64028,
|
Field: 64028,
|
||||||
Name: "gogoproto.protosizer",
|
Name: "gogoproto.protosizer",
|
||||||
@@ -532,7 +551,7 @@ var E_Protosizer = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Compare = &proto.ExtensionDesc{
|
var E_Compare = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64029,
|
Field: 64029,
|
||||||
Name: "gogoproto.compare",
|
Name: "gogoproto.compare",
|
||||||
@@ -541,7 +560,7 @@ var E_Compare = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Typedecl = &proto.ExtensionDesc{
|
var E_Typedecl = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 64030,
|
Field: 64030,
|
||||||
Name: "gogoproto.typedecl",
|
Name: "gogoproto.typedecl",
|
||||||
@@ -549,8 +568,35 @@ var E_Typedecl = &proto.ExtensionDesc{
|
|||||||
Filename: "gogo.proto",
|
Filename: "gogo.proto",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var E_Messagename = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 64033,
|
||||||
|
Name: "gogoproto.messagename",
|
||||||
|
Tag: "varint,64033,opt,name=messagename",
|
||||||
|
Filename: "gogo.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_GoprotoSizecache = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 64034,
|
||||||
|
Name: "gogoproto.goproto_sizecache",
|
||||||
|
Tag: "varint,64034,opt,name=goproto_sizecache,json=goprotoSizecache",
|
||||||
|
Filename: "gogo.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_GoprotoUnkeyed = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 64035,
|
||||||
|
Name: "gogoproto.goproto_unkeyed",
|
||||||
|
Tag: "varint,64035,opt,name=goproto_unkeyed,json=goprotoUnkeyed",
|
||||||
|
Filename: "gogo.proto",
|
||||||
|
}
|
||||||
|
|
||||||
var E_Nullable = &proto.ExtensionDesc{
|
var E_Nullable = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 65001,
|
Field: 65001,
|
||||||
Name: "gogoproto.nullable",
|
Name: "gogoproto.nullable",
|
||||||
@@ -559,7 +605,7 @@ var E_Nullable = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Embed = &proto.ExtensionDesc{
|
var E_Embed = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 65002,
|
Field: 65002,
|
||||||
Name: "gogoproto.embed",
|
Name: "gogoproto.embed",
|
||||||
@@ -568,7 +614,7 @@ var E_Embed = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Customtype = &proto.ExtensionDesc{
|
var E_Customtype = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*string)(nil),
|
ExtensionType: (*string)(nil),
|
||||||
Field: 65003,
|
Field: 65003,
|
||||||
Name: "gogoproto.customtype",
|
Name: "gogoproto.customtype",
|
||||||
@@ -577,7 +623,7 @@ var E_Customtype = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Customname = &proto.ExtensionDesc{
|
var E_Customname = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*string)(nil),
|
ExtensionType: (*string)(nil),
|
||||||
Field: 65004,
|
Field: 65004,
|
||||||
Name: "gogoproto.customname",
|
Name: "gogoproto.customname",
|
||||||
@@ -586,7 +632,7 @@ var E_Customname = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Jsontag = &proto.ExtensionDesc{
|
var E_Jsontag = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*string)(nil),
|
ExtensionType: (*string)(nil),
|
||||||
Field: 65005,
|
Field: 65005,
|
||||||
Name: "gogoproto.jsontag",
|
Name: "gogoproto.jsontag",
|
||||||
@@ -595,7 +641,7 @@ var E_Jsontag = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Moretags = &proto.ExtensionDesc{
|
var E_Moretags = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*string)(nil),
|
ExtensionType: (*string)(nil),
|
||||||
Field: 65006,
|
Field: 65006,
|
||||||
Name: "gogoproto.moretags",
|
Name: "gogoproto.moretags",
|
||||||
@@ -604,7 +650,7 @@ var E_Moretags = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Casttype = &proto.ExtensionDesc{
|
var E_Casttype = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*string)(nil),
|
ExtensionType: (*string)(nil),
|
||||||
Field: 65007,
|
Field: 65007,
|
||||||
Name: "gogoproto.casttype",
|
Name: "gogoproto.casttype",
|
||||||
@@ -613,7 +659,7 @@ var E_Casttype = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Castkey = &proto.ExtensionDesc{
|
var E_Castkey = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*string)(nil),
|
ExtensionType: (*string)(nil),
|
||||||
Field: 65008,
|
Field: 65008,
|
||||||
Name: "gogoproto.castkey",
|
Name: "gogoproto.castkey",
|
||||||
@@ -622,7 +668,7 @@ var E_Castkey = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Castvalue = &proto.ExtensionDesc{
|
var E_Castvalue = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*string)(nil),
|
ExtensionType: (*string)(nil),
|
||||||
Field: 65009,
|
Field: 65009,
|
||||||
Name: "gogoproto.castvalue",
|
Name: "gogoproto.castvalue",
|
||||||
@@ -631,7 +677,7 @@ var E_Castvalue = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Stdtime = &proto.ExtensionDesc{
|
var E_Stdtime = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 65010,
|
Field: 65010,
|
||||||
Name: "gogoproto.stdtime",
|
Name: "gogoproto.stdtime",
|
||||||
@@ -640,7 +686,7 @@ var E_Stdtime = &proto.ExtensionDesc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var E_Stdduration = &proto.ExtensionDesc{
|
var E_Stdduration = &proto.ExtensionDesc{
|
||||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
ExtensionType: (*bool)(nil),
|
ExtensionType: (*bool)(nil),
|
||||||
Field: 65011,
|
Field: 65011,
|
||||||
Name: "gogoproto.stdduration",
|
Name: "gogoproto.stdduration",
|
||||||
@@ -648,6 +694,15 @@ var E_Stdduration = &proto.ExtensionDesc{
|
|||||||
Filename: "gogo.proto",
|
Filename: "gogo.proto",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var E_Wktpointer = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 65012,
|
||||||
|
Name: "gogoproto.wktpointer",
|
||||||
|
Tag: "varint,65012,opt,name=wktpointer",
|
||||||
|
Filename: "gogo.proto",
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterExtension(E_GoprotoEnumPrefix)
|
proto.RegisterExtension(E_GoprotoEnumPrefix)
|
||||||
proto.RegisterExtension(E_GoprotoEnumStringer)
|
proto.RegisterExtension(E_GoprotoEnumStringer)
|
||||||
@@ -684,6 +739,9 @@ func init() {
|
|||||||
proto.RegisterExtension(E_TypedeclAll)
|
proto.RegisterExtension(E_TypedeclAll)
|
||||||
proto.RegisterExtension(E_EnumdeclAll)
|
proto.RegisterExtension(E_EnumdeclAll)
|
||||||
proto.RegisterExtension(E_GoprotoRegistration)
|
proto.RegisterExtension(E_GoprotoRegistration)
|
||||||
|
proto.RegisterExtension(E_MessagenameAll)
|
||||||
|
proto.RegisterExtension(E_GoprotoSizecacheAll)
|
||||||
|
proto.RegisterExtension(E_GoprotoUnkeyedAll)
|
||||||
proto.RegisterExtension(E_GoprotoGetters)
|
proto.RegisterExtension(E_GoprotoGetters)
|
||||||
proto.RegisterExtension(E_GoprotoStringer)
|
proto.RegisterExtension(E_GoprotoStringer)
|
||||||
proto.RegisterExtension(E_VerboseEqual)
|
proto.RegisterExtension(E_VerboseEqual)
|
||||||
@@ -707,6 +765,9 @@ func init() {
|
|||||||
proto.RegisterExtension(E_Protosizer)
|
proto.RegisterExtension(E_Protosizer)
|
||||||
proto.RegisterExtension(E_Compare)
|
proto.RegisterExtension(E_Compare)
|
||||||
proto.RegisterExtension(E_Typedecl)
|
proto.RegisterExtension(E_Typedecl)
|
||||||
|
proto.RegisterExtension(E_Messagename)
|
||||||
|
proto.RegisterExtension(E_GoprotoSizecache)
|
||||||
|
proto.RegisterExtension(E_GoprotoUnkeyed)
|
||||||
proto.RegisterExtension(E_Nullable)
|
proto.RegisterExtension(E_Nullable)
|
||||||
proto.RegisterExtension(E_Embed)
|
proto.RegisterExtension(E_Embed)
|
||||||
proto.RegisterExtension(E_Customtype)
|
proto.RegisterExtension(E_Customtype)
|
||||||
@@ -718,87 +779,94 @@ func init() {
|
|||||||
proto.RegisterExtension(E_Castvalue)
|
proto.RegisterExtension(E_Castvalue)
|
||||||
proto.RegisterExtension(E_Stdtime)
|
proto.RegisterExtension(E_Stdtime)
|
||||||
proto.RegisterExtension(E_Stdduration)
|
proto.RegisterExtension(E_Stdduration)
|
||||||
|
proto.RegisterExtension(E_Wktpointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("gogo.proto", fileDescriptorGogo) }
|
func init() { proto.RegisterFile("gogo.proto", fileDescriptor_gogo_b95f77e237336c7c) }
|
||||||
|
|
||||||
var fileDescriptorGogo = []byte{
|
var fileDescriptor_gogo_b95f77e237336c7c = []byte{
|
||||||
// 1220 bytes of a gzipped FileDescriptorProto
|
// 1328 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x98, 0x4b, 0x6f, 0x1c, 0x45,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x98, 0x49, 0x6f, 0x1c, 0x45,
|
||||||
0x10, 0x80, 0x85, 0x48, 0x14, 0x6f, 0xd9, 0x8e, 0xf1, 0xda, 0x98, 0x10, 0x81, 0x08, 0x9c, 0x38,
|
0x14, 0x80, 0x85, 0x48, 0x64, 0x4f, 0x79, 0x8b, 0xc7, 0xc6, 0x84, 0x08, 0x44, 0xe0, 0xc4, 0xc9,
|
||||||
0xd9, 0xa7, 0x08, 0xa5, 0xad, 0xc8, 0x72, 0x2c, 0xc7, 0x4a, 0x84, 0xc1, 0x98, 0x38, 0xbc, 0x0e,
|
0x3e, 0x45, 0x28, 0x65, 0x45, 0x96, 0x63, 0x39, 0x56, 0x10, 0x0e, 0xc6, 0x89, 0xc3, 0x76, 0x18,
|
||||||
0xab, 0xd9, 0xdd, 0xf6, 0x78, 0x60, 0x66, 0x7a, 0x98, 0xe9, 0x89, 0xe2, 0xdc, 0x50, 0x78, 0x08,
|
0xf5, 0xf4, 0x94, 0xdb, 0x8d, 0xbb, 0xbb, 0x9a, 0xee, 0xea, 0x10, 0xe7, 0x86, 0xc2, 0x22, 0x84,
|
||||||
0x21, 0xde, 0x48, 0x90, 0x90, 0x04, 0x38, 0xf0, 0x7e, 0x86, 0xf7, 0x91, 0x0b, 0x8f, 0x2b, 0xff,
|
0xd8, 0x91, 0x20, 0x21, 0x09, 0x04, 0xc4, 0xbe, 0x86, 0x7d, 0xb9, 0x70, 0x61, 0xb9, 0xf2, 0x1f,
|
||||||
0x81, 0x0b, 0x60, 0xde, 0xbe, 0xf9, 0x82, 0x6a, 0xb6, 0x6a, 0xb6, 0x67, 0xbd, 0x52, 0xf7, 0xde,
|
0xb8, 0x00, 0x66, 0xf7, 0xcd, 0x17, 0xf4, 0xba, 0xdf, 0xeb, 0xa9, 0x69, 0x8f, 0x54, 0x35, 0xb7,
|
||||||
0xc6, 0xeb, 0xfe, 0xbe, 0xad, 0xa9, 0x9a, 0xae, 0xea, 0x59, 0x00, 0x5f, 0xf9, 0x6a, 0x3a, 0x49,
|
0xf6, 0xb8, 0xbe, 0x6f, 0xaa, 0xdf, 0xeb, 0x7a, 0xef, 0x4d, 0x33, 0xe6, 0x49, 0x4f, 0x4e, 0xc6,
|
||||||
0x95, 0x56, 0xf5, 0x1a, 0x5e, 0x17, 0x97, 0x07, 0x0f, 0xf9, 0x4a, 0xf9, 0xa1, 0x9c, 0x29, 0xfe,
|
0x89, 0x54, 0xb2, 0x5e, 0x83, 0xeb, 0xfc, 0x72, 0xdf, 0x7e, 0x4f, 0x4a, 0x2f, 0x10, 0x53, 0xf9,
|
||||||
0x6a, 0xe6, 0xeb, 0x33, 0x6d, 0x99, 0xb5, 0xd2, 0x20, 0xd1, 0x2a, 0xed, 0x2c, 0x16, 0x77, 0xc1,
|
0x5f, 0xcd, 0x6c, 0x75, 0xaa, 0x25, 0x52, 0x37, 0xf1, 0x63, 0x25, 0x93, 0x62, 0x31, 0x3f, 0xc6,
|
||||||
0x04, 0x2d, 0x6e, 0xc8, 0x38, 0x8f, 0x1a, 0x49, 0x2a, 0xd7, 0x83, 0xb3, 0xf5, 0x9b, 0xa6, 0x3b,
|
0xc6, 0x70, 0x71, 0x43, 0x44, 0x59, 0xd8, 0x88, 0x13, 0xb1, 0xea, 0x9f, 0xae, 0x5f, 0x3f, 0x59,
|
||||||
0xe4, 0x34, 0x93, 0xd3, 0x8b, 0x71, 0x1e, 0xdd, 0x9d, 0xe8, 0x40, 0xc5, 0xd9, 0x81, 0xab, 0xbf,
|
0x90, 0x93, 0x44, 0x4e, 0xce, 0x47, 0x59, 0x78, 0x47, 0xac, 0x7c, 0x19, 0xa5, 0x7b, 0xaf, 0xfc,
|
||||||
0x5c, 0x7b, 0xe8, 0x9a, 0xdb, 0x87, 0x56, 0xc7, 0x09, 0xc5, 0xff, 0xad, 0x14, 0xa0, 0x58, 0x85,
|
0x72, 0xf5, 0xfe, 0xab, 0x6e, 0xe9, 0x5f, 0x1e, 0x45, 0x14, 0xfe, 0xb7, 0x94, 0x83, 0x7c, 0x99,
|
||||||
0xeb, 0x2b, 0xbe, 0x4c, 0xa7, 0x41, 0xec, 0xcb, 0xd4, 0x62, 0xfc, 0x9e, 0x8c, 0x13, 0x86, 0xf1,
|
0x5d, 0xd3, 0xe1, 0x4b, 0x55, 0xe2, 0x47, 0x9e, 0x48, 0x0c, 0xc6, 0xef, 0xd1, 0x38, 0xa6, 0x19,
|
||||||
0x5e, 0x42, 0xc5, 0x02, 0x8c, 0x0e, 0xe2, 0xfa, 0x81, 0x5c, 0x23, 0xd2, 0x94, 0x2c, 0xc1, 0x58,
|
0x8f, 0x23, 0xca, 0xe7, 0xd8, 0x50, 0x2f, 0xae, 0x1f, 0xd0, 0x35, 0x28, 0x74, 0xc9, 0x02, 0x1b,
|
||||||
0x21, 0x69, 0xe5, 0x99, 0x56, 0x51, 0xec, 0x45, 0xd2, 0xa2, 0xf9, 0xb1, 0xd0, 0xd4, 0x56, 0xf7,
|
0xc9, 0x25, 0x6e, 0x96, 0x2a, 0x19, 0x46, 0x4e, 0x28, 0x0c, 0x9a, 0x1f, 0x73, 0x4d, 0x6d, 0x79,
|
||||||
0x23, 0xb6, 0x50, 0x52, 0x42, 0xc0, 0x10, 0x7e, 0xd2, 0x96, 0xad, 0xd0, 0x62, 0xf8, 0x89, 0x02,
|
0x18, 0xb0, 0xb9, 0x92, 0xe2, 0x9c, 0xf5, 0xc3, 0x27, 0x2d, 0xe1, 0x06, 0x06, 0xc3, 0x4f, 0xb8,
|
||||||
0x29, 0xd7, 0x8b, 0xd3, 0x30, 0x89, 0xd7, 0x67, 0xbc, 0x30, 0x97, 0x66, 0x24, 0xb7, 0xf6, 0xf5,
|
0x91, 0x72, 0x3d, 0x3f, 0xc9, 0xc6, 0xe1, 0xfa, 0x94, 0x13, 0x64, 0x42, 0xdf, 0xc9, 0x4d, 0x5d,
|
||||||
0x9c, 0xc6, 0x65, 0x2c, 0xfb, 0xf9, 0xfc, 0x9e, 0x22, 0x9c, 0x89, 0x52, 0x60, 0xc4, 0x64, 0x54,
|
0x3d, 0x27, 0x61, 0x19, 0xc9, 0x7e, 0x3e, 0xbb, 0x2b, 0xdf, 0xce, 0x58, 0x29, 0xd0, 0xf6, 0xa4,
|
||||||
0xd1, 0x97, 0x5a, 0xcb, 0x34, 0x6b, 0x78, 0x61, 0xbf, 0xf0, 0x8e, 0x07, 0x61, 0x69, 0xbc, 0xb0,
|
0x65, 0xd1, 0x13, 0x4a, 0x89, 0x24, 0x6d, 0x38, 0x41, 0xb7, 0xed, 0x1d, 0xf1, 0x83, 0xd2, 0x78,
|
||||||
0x55, 0xad, 0xe2, 0x52, 0x87, 0x9c, 0x0f, 0x43, 0xb1, 0x06, 0x37, 0xf4, 0x79, 0x2a, 0x1c, 0x9c,
|
0x6e, 0xb3, 0x33, 0x8b, 0x0b, 0x05, 0x39, 0x1b, 0x04, 0x7c, 0x85, 0x5d, 0xdb, 0xe5, 0xa9, 0xb0,
|
||||||
0x17, 0xc9, 0x39, 0xb9, 0xeb, 0xc9, 0x40, 0xed, 0x0a, 0xf0, 0xe7, 0x65, 0x2d, 0x1d, 0x9c, 0xaf,
|
0x70, 0x9e, 0x47, 0xe7, 0xf8, 0x8e, 0x27, 0x03, 0xb4, 0x4b, 0x8c, 0x3e, 0x2f, 0x73, 0x69, 0xe1,
|
||||||
0x93, 0xb3, 0x4e, 0x2c, 0x97, 0x14, 0x8d, 0x27, 0x61, 0xfc, 0x8c, 0x4c, 0x9b, 0x2a, 0x93, 0x0d,
|
0x7c, 0x19, 0x9d, 0x75, 0x64, 0x29, 0xa5, 0x60, 0xbc, 0x8d, 0x8d, 0x9e, 0x12, 0x49, 0x53, 0xa6,
|
||||||
0xf9, 0x68, 0xee, 0x85, 0x0e, 0xba, 0x4b, 0xa4, 0x1b, 0x23, 0x70, 0x11, 0x39, 0x74, 0x1d, 0x81,
|
0xa2, 0x21, 0x1e, 0xc8, 0x9c, 0xc0, 0x42, 0x77, 0x01, 0x75, 0x23, 0x08, 0xce, 0x03, 0x07, 0xae,
|
||||||
0xa1, 0x75, 0xaf, 0x25, 0x1d, 0x14, 0x97, 0x49, 0xb1, 0x0f, 0xd7, 0x23, 0x3a, 0x0f, 0x23, 0xbe,
|
0x83, 0xac, 0x7f, 0xd5, 0x71, 0x85, 0x85, 0xe2, 0x22, 0x2a, 0xfa, 0x60, 0x3d, 0xa0, 0xb3, 0x6c,
|
||||||
0xea, 0xdc, 0x92, 0x03, 0x7e, 0x85, 0xf0, 0x61, 0x66, 0x48, 0x91, 0xa8, 0x24, 0x0f, 0x3d, 0xed,
|
0xd0, 0x93, 0xc5, 0x2d, 0x59, 0xe0, 0x97, 0x10, 0x1f, 0x20, 0x06, 0x15, 0xb1, 0x8c, 0xb3, 0xc0,
|
||||||
0x12, 0xc1, 0x1b, 0xac, 0x60, 0x86, 0x14, 0x03, 0xa4, 0xf5, 0x4d, 0x56, 0x64, 0x46, 0x3e, 0xe7,
|
0x51, 0x36, 0x3b, 0x78, 0x85, 0x14, 0xc4, 0xa0, 0xa2, 0x87, 0xb0, 0xbe, 0x4a, 0x8a, 0x54, 0x8b,
|
||||||
0x60, 0x58, 0xc5, 0xe1, 0xa6, 0x8a, 0x5d, 0x82, 0x78, 0x8b, 0x0c, 0x40, 0x08, 0x0a, 0x66, 0xa1,
|
0xe7, 0x0c, 0x1b, 0x90, 0x51, 0xb0, 0x21, 0x23, 0x9b, 0x4d, 0x5c, 0x46, 0x03, 0x43, 0x04, 0x04,
|
||||||
0xe6, 0x5a, 0x88, 0xb7, 0xb7, 0x78, 0x7b, 0x70, 0x05, 0x96, 0x60, 0x8c, 0x1b, 0x54, 0xa0, 0x62,
|
0xd3, 0xac, 0x66, 0x9b, 0x88, 0x37, 0x36, 0xe9, 0x78, 0x50, 0x06, 0x16, 0xd8, 0x08, 0x15, 0x28,
|
||||||
0x07, 0xc5, 0x3b, 0xa4, 0xd8, 0x6f, 0x60, 0x74, 0x1b, 0x5a, 0x66, 0xda, 0x97, 0x2e, 0x92, 0x77,
|
0x5f, 0x46, 0x16, 0x8a, 0x37, 0x51, 0x31, 0xac, 0x61, 0x78, 0x1b, 0x4a, 0xa4, 0xca, 0x13, 0x36,
|
||||||
0xf9, 0x36, 0x08, 0xa1, 0x54, 0x36, 0x65, 0xdc, 0xda, 0x70, 0x33, 0xbc, 0xc7, 0xa9, 0x64, 0x06,
|
0x92, 0xb7, 0xe8, 0x36, 0x10, 0xc1, 0x50, 0x36, 0x45, 0xe4, 0xae, 0xd9, 0x19, 0xde, 0xa6, 0x50,
|
||||||
0x15, 0x0b, 0x30, 0x1a, 0x79, 0x69, 0xb6, 0xe1, 0x85, 0x4e, 0xe5, 0x78, 0x9f, 0x1c, 0x23, 0x25,
|
0x12, 0x03, 0x8a, 0x39, 0x36, 0x14, 0x3a, 0x49, 0xba, 0xe6, 0x04, 0x56, 0xe9, 0x78, 0x07, 0x1d,
|
||||||
0x44, 0x19, 0xc9, 0xe3, 0x41, 0x34, 0x1f, 0x70, 0x46, 0x0c, 0x8c, 0xb6, 0x5e, 0xa6, 0xbd, 0x66,
|
0x83, 0x25, 0x84, 0x11, 0xc9, 0xa2, 0x5e, 0x34, 0xef, 0x52, 0x44, 0x34, 0x0c, 0x8f, 0x5e, 0xaa,
|
||||||
0x28, 0x1b, 0x83, 0xd8, 0x3e, 0xe4, 0xad, 0xd7, 0x61, 0x97, 0x4d, 0xe3, 0x2c, 0xd4, 0xb2, 0xe0,
|
0x9c, 0x66, 0x20, 0x1a, 0xbd, 0xd8, 0xde, 0xa3, 0xa3, 0x57, 0xb0, 0x8b, 0xba, 0x71, 0x9a, 0xd5,
|
||||||
0x9c, 0x93, 0xe6, 0x23, 0xae, 0x74, 0x01, 0x20, 0xfc, 0x00, 0xdc, 0xd8, 0x77, 0x4c, 0x38, 0xc8,
|
0x52, 0xff, 0x8c, 0x95, 0xe6, 0x7d, 0xca, 0x74, 0x0e, 0x00, 0x7c, 0x0f, 0xbb, 0xae, 0x6b, 0x9b,
|
||||||
0x3e, 0x26, 0xd9, 0x54, 0x9f, 0x51, 0x41, 0x2d, 0x61, 0x50, 0xe5, 0x27, 0xdc, 0x12, 0x64, 0x8f,
|
0xb0, 0x90, 0x7d, 0x80, 0xb2, 0x89, 0x2e, 0xad, 0x02, 0x4b, 0x42, 0xaf, 0xca, 0x0f, 0xa9, 0x24,
|
||||||
0x6b, 0x05, 0x26, 0xf3, 0x38, 0xf3, 0xd6, 0x07, 0xcb, 0xda, 0xa7, 0x9c, 0xb5, 0x0e, 0x5b, 0xc9,
|
0x88, 0x8a, 0x6b, 0x89, 0x8d, 0x67, 0x51, 0xea, 0xac, 0xf6, 0x16, 0xb5, 0x8f, 0x28, 0x6a, 0x05,
|
||||||
0xda, 0x29, 0x98, 0x22, 0xe3, 0x60, 0x75, 0xfd, 0x8c, 0x1b, 0x6b, 0x87, 0x5e, 0xab, 0x56, 0xf7,
|
0xdb, 0x11, 0xb5, 0x13, 0x6c, 0x02, 0x8d, 0xbd, 0xe5, 0xf5, 0x63, 0x2a, 0xac, 0x05, 0xbd, 0xd2,
|
||||||
0x21, 0x38, 0x58, 0xa6, 0xf3, 0xac, 0x96, 0x71, 0x86, 0x4c, 0x23, 0xf2, 0x12, 0x07, 0xf3, 0x55,
|
0x99, 0xdd, 0xfb, 0xd8, 0xbe, 0x32, 0x9c, 0xa7, 0x95, 0x88, 0x52, 0x60, 0x1a, 0xa1, 0x13, 0x5b,
|
||||||
0x32, 0x73, 0xc7, 0x5f, 0x2c, 0x05, 0xcb, 0x5e, 0x82, 0xf2, 0xfb, 0xe1, 0x00, 0xcb, 0xf3, 0x38,
|
0x98, 0xaf, 0xa0, 0x99, 0x2a, 0xfe, 0x7c, 0x29, 0x58, 0x74, 0x62, 0x90, 0xdf, 0xcd, 0xf6, 0x92,
|
||||||
0x95, 0x2d, 0xe5, 0xc7, 0xc1, 0x39, 0xd9, 0x76, 0x50, 0x7f, 0xde, 0x53, 0xaa, 0x35, 0x03, 0x47,
|
0x3c, 0x8b, 0x12, 0xe1, 0x4a, 0x2f, 0xf2, 0xcf, 0x88, 0x96, 0x85, 0xfa, 0x93, 0x4a, 0xaa, 0x56,
|
||||||
0xf3, 0x09, 0xb8, 0xae, 0x3c, 0xab, 0x34, 0x82, 0x28, 0x51, 0xa9, 0xb6, 0x18, 0xbf, 0xe0, 0x4a,
|
0x34, 0x1c, 0xcc, 0x47, 0xd9, 0x9e, 0x72, 0x56, 0x69, 0xf8, 0x61, 0x2c, 0x13, 0x65, 0x30, 0x7e,
|
||||||
0x95, 0xdc, 0x89, 0x02, 0x13, 0x8b, 0xb0, 0xbf, 0xf8, 0xd3, 0xf5, 0x91, 0xfc, 0x92, 0x44, 0xa3,
|
0x4a, 0x99, 0x2a, 0xb9, 0xa3, 0x39, 0xc6, 0xe7, 0xd9, 0x70, 0xfe, 0xa7, 0xed, 0x23, 0xf9, 0x19,
|
||||||
0x5d, 0x8a, 0x1a, 0x47, 0x4b, 0x45, 0x89, 0x97, 0xba, 0xf4, 0xbf, 0xaf, 0xb8, 0x71, 0x10, 0x42,
|
0x8a, 0x86, 0xda, 0x14, 0x16, 0x0e, 0x57, 0x86, 0xb1, 0x93, 0xd8, 0xd4, 0xbf, 0xcf, 0xa9, 0x70,
|
||||||
0x8d, 0x43, 0x6f, 0x26, 0x12, 0xa7, 0xbd, 0x83, 0xe1, 0x6b, 0x6e, 0x1c, 0xcc, 0x90, 0x82, 0x0f,
|
0x20, 0x82, 0x85, 0x43, 0x6d, 0xc4, 0x02, 0xba, 0xbd, 0x85, 0xe1, 0x0b, 0x2a, 0x1c, 0xc4, 0xa0,
|
||||||
0x0c, 0x0e, 0x8a, 0x6f, 0x58, 0xc1, 0x0c, 0x2a, 0xee, 0xe9, 0x0e, 0xda, 0x54, 0xfa, 0x41, 0xa6,
|
0x82, 0x06, 0x06, 0x0b, 0xc5, 0x97, 0xa4, 0x20, 0x06, 0x14, 0x77, 0xb6, 0x1b, 0x6d, 0x22, 0x3c,
|
||||||
0x53, 0x0f, 0x57, 0x5b, 0x54, 0xdf, 0x6e, 0x55, 0x0f, 0x61, 0xab, 0x06, 0x2a, 0x4e, 0xc2, 0x58,
|
0x3f, 0x55, 0x89, 0x03, 0xab, 0x0d, 0xaa, 0xaf, 0x36, 0x3b, 0x87, 0xb0, 0x65, 0x0d, 0x85, 0x4a,
|
||||||
0xcf, 0x11, 0xa3, 0x7e, 0xcb, 0x2e, 0xdb, 0xb2, 0xcc, 0x32, 0xcf, 0x2f, 0x85, 0x8f, 0x6d, 0x53,
|
0x14, 0x8a, 0x34, 0x75, 0x3c, 0x01, 0x13, 0x87, 0xc5, 0xc6, 0xbe, 0xa6, 0x4a, 0xa4, 0x61, 0xb0,
|
||||||
0x33, 0xaa, 0x9e, 0x30, 0xc4, 0x9d, 0x58, 0xf7, 0xea, 0x39, 0xc0, 0x2e, 0x3b, 0xbf, 0x5d, 0x96,
|
0x37, 0x6d, 0x42, 0x84, 0xb0, 0xbb, 0x8e, 0xbb, 0x66, 0xa3, 0xfb, 0xa6, 0xb2, 0xb9, 0xe3, 0xc4,
|
||||||
0xbe, 0x72, 0x0c, 0x10, 0xc7, 0x61, 0xb4, 0x72, 0x06, 0xb0, 0xab, 0x1e, 0x27, 0xd5, 0x88, 0x79,
|
0x82, 0x53, 0x9b, 0x7f, 0xb2, 0x68, 0x5d, 0x6c, 0x58, 0x3d, 0x9d, 0xdf, 0x56, 0xe6, 0x9f, 0x95,
|
||||||
0x04, 0x10, 0x87, 0x61, 0x0f, 0xce, 0x73, 0x3b, 0xfe, 0x04, 0xe1, 0xc5, 0x72, 0x71, 0x14, 0x86,
|
0x82, 0x2c, 0x6a, 0xc8, 0x48, 0x65, 0x9e, 0xaa, 0xdf, 0xb8, 0xc3, 0xb5, 0x58, 0xdc, 0x17, 0xe9,
|
||||||
0x78, 0x8e, 0xdb, 0xd1, 0x27, 0x09, 0x2d, 0x11, 0xc4, 0x79, 0x86, 0xdb, 0xf1, 0xa7, 0x18, 0x67,
|
0x1e, 0xda, 0xc2, 0xfb, 0xed, 0x1c, 0xa7, 0xf8, 0xed, 0xf0, 0x90, 0x77, 0x0e, 0x3d, 0x66, 0xd9,
|
||||||
0x04, 0x71, 0xf7, 0x14, 0x7e, 0xf7, 0xcc, 0x1e, 0xea, 0xc3, 0x9c, 0xbb, 0x59, 0xd8, 0x47, 0xc3,
|
0xd9, 0xad, 0xf2, 0x39, 0xef, 0x98, 0x79, 0xf8, 0x11, 0x36, 0xd4, 0x31, 0xf0, 0x98, 0x55, 0x0f,
|
||||||
0xdb, 0x4e, 0x3f, 0x4d, 0x5f, 0xce, 0x84, 0xb8, 0x03, 0xf6, 0x3a, 0x26, 0xfc, 0x59, 0x42, 0x3b,
|
0xa3, 0x6a, 0x50, 0x9f, 0x77, 0xf8, 0x01, 0xb6, 0x0b, 0x86, 0x17, 0x33, 0xfe, 0x08, 0xe2, 0xf9,
|
||||||
0xeb, 0xc5, 0x02, 0x0c, 0x1b, 0x03, 0xdb, 0x8e, 0x3f, 0x47, 0xb8, 0x49, 0x61, 0xe8, 0x34, 0xb0,
|
0x72, 0x7e, 0x88, 0xf5, 0xd3, 0xd0, 0x62, 0x46, 0x1f, 0x45, 0xb4, 0x44, 0x00, 0xa7, 0x81, 0xc5,
|
||||||
0xed, 0x82, 0xe7, 0x39, 0x74, 0x22, 0x30, 0x6d, 0x3c, 0xab, 0xed, 0xf4, 0x0b, 0x9c, 0x75, 0x46,
|
0x8c, 0x3f, 0x46, 0x38, 0x21, 0x80, 0xdb, 0x87, 0xf0, 0xbb, 0x27, 0x76, 0x61, 0xd3, 0xa1, 0xd8,
|
||||||
0xc4, 0x1c, 0xd4, 0xca, 0xfe, 0x6b, 0xe7, 0x5f, 0x24, 0xbe, 0xcb, 0x60, 0x06, 0x8c, 0xfe, 0x6f,
|
0x4d, 0xb3, 0x3e, 0x9c, 0x54, 0xcc, 0xf4, 0xe3, 0xf8, 0xe5, 0x44, 0xf0, 0x5b, 0xd9, 0x6e, 0xcb,
|
||||||
0x57, 0xbc, 0xc4, 0x19, 0x30, 0x28, 0xdc, 0x46, 0xbd, 0x33, 0xdd, 0x6e, 0x7a, 0x99, 0xb7, 0x51,
|
0x80, 0x3f, 0x89, 0x68, 0xb1, 0x9e, 0xcf, 0xb1, 0x01, 0x6d, 0x3a, 0x31, 0xe3, 0x4f, 0x21, 0xae,
|
||||||
0xcf, 0x48, 0xc7, 0x6a, 0x16, 0x6d, 0xd0, 0xae, 0x78, 0x85, 0xab, 0x59, 0xac, 0xc7, 0x30, 0x7a,
|
0x53, 0xb0, 0x75, 0x9c, 0x4e, 0xcc, 0x82, 0xa7, 0x69, 0xeb, 0x48, 0x40, 0xd8, 0x68, 0x30, 0x31,
|
||||||
0x87, 0xa4, 0xdd, 0xf1, 0x2a, 0x87, 0xd1, 0x33, 0x23, 0xc5, 0x0a, 0xd4, 0x77, 0x0f, 0x48, 0xbb,
|
0xd3, 0xcf, 0x50, 0xd4, 0x09, 0xe1, 0x33, 0xac, 0x56, 0x36, 0x1b, 0x33, 0xff, 0x2c, 0xf2, 0x6d,
|
||||||
0xef, 0x35, 0xf2, 0x8d, 0xef, 0x9a, 0x8f, 0xe2, 0x3e, 0x98, 0xea, 0x3f, 0x1c, 0xed, 0xd6, 0x0b,
|
0x06, 0x22, 0xa0, 0x35, 0x3b, 0xb3, 0xe2, 0x39, 0x8a, 0x80, 0x46, 0xc1, 0x31, 0xaa, 0x0e, 0x30,
|
||||||
0xdb, 0x3d, 0xaf, 0x33, 0xe6, 0x6c, 0x14, 0xa7, 0xba, 0x5d, 0xd6, 0x1c, 0x8c, 0x76, 0xed, 0xc5,
|
0x66, 0xd3, 0xf3, 0x74, 0x8c, 0x2a, 0xf3, 0x0b, 0x64, 0x33, 0xaf, 0xf9, 0x66, 0xc5, 0x0b, 0x94,
|
||||||
0xed, 0x6a, 0xa3, 0x35, 0xe7, 0xa2, 0x98, 0x07, 0xe8, 0xce, 0x24, 0xbb, 0xeb, 0x12, 0xb9, 0x0c,
|
0xcd, 0x7c, 0x3d, 0x6c, 0xa3, 0x3a, 0x11, 0x98, 0x1d, 0x2f, 0xd2, 0x36, 0x2a, 0x03, 0x01, 0x5f,
|
||||||
0x08, 0xb7, 0x06, 0x8d, 0x24, 0x3b, 0x7f, 0x99, 0xb7, 0x06, 0x11, 0xb8, 0x35, 0x78, 0x1a, 0xd9,
|
0x62, 0xf5, 0x9d, 0xd3, 0x80, 0xd9, 0xf7, 0x12, 0xfa, 0x46, 0x77, 0x0c, 0x03, 0xfc, 0x2e, 0x36,
|
||||||
0xe9, 0x2b, 0xbc, 0x35, 0x18, 0x11, 0xb3, 0x30, 0x14, 0xe7, 0x61, 0x88, 0xcf, 0x56, 0xfd, 0xe6,
|
0xd1, 0x7d, 0x12, 0x30, 0x5b, 0xcf, 0x6d, 0x55, 0x7e, 0xbb, 0xe9, 0x83, 0x00, 0x3f, 0xd1, 0x6e,
|
||||||
0x3e, 0xe3, 0x46, 0x86, 0x6d, 0x86, 0x7f, 0xdd, 0x21, 0x98, 0x01, 0x71, 0x18, 0xf6, 0xca, 0xa8,
|
0x29, 0xfa, 0x14, 0x60, 0xd6, 0x9e, 0xdf, 0xea, 0x2c, 0xdc, 0xfa, 0x10, 0xc0, 0x67, 0x19, 0x6b,
|
||||||
0x29, 0xdb, 0x36, 0xf2, 0xb7, 0x1d, 0xee, 0x27, 0xb8, 0x5a, 0xcc, 0x01, 0x74, 0x5e, 0xa6, 0x31,
|
0x37, 0x60, 0xb3, 0xeb, 0x02, 0xba, 0x34, 0x08, 0x8e, 0x06, 0xf6, 0x5f, 0x33, 0x7f, 0x91, 0x8e,
|
||||||
0x0a, 0x1b, 0xfb, 0xfb, 0x4e, 0xe7, 0xbd, 0xde, 0x40, 0xba, 0x82, 0xe2, 0x6d, 0xdc, 0x22, 0xd8,
|
0x06, 0x12, 0x70, 0x34, 0xa8, 0xf5, 0x9a, 0xe9, 0x4b, 0x74, 0x34, 0x08, 0x81, 0x27, 0x5b, 0xeb,
|
||||||
0xaa, 0x0a, 0x8a, 0x17, 0xf0, 0x23, 0xb0, 0xef, 0xe1, 0x4c, 0xc5, 0xda, 0xf3, 0x6d, 0xf4, 0x1f,
|
0x6e, 0x66, 0xc3, 0x65, 0x7a, 0xb2, 0x35, 0x8a, 0x1f, 0x63, 0xa3, 0x3b, 0x1a, 0xa2, 0x59, 0xf5,
|
||||||
0x44, 0xf3, 0x7a, 0x4c, 0x58, 0xa4, 0x52, 0xa9, 0x3d, 0x3f, 0xb3, 0xb1, 0x7f, 0x12, 0x5b, 0x02,
|
0x1a, 0xaa, 0xf6, 0x54, 0xfb, 0xa1, 0xde, 0xbc, 0xb0, 0x19, 0x9a, 0x6d, 0xaf, 0x57, 0x9a, 0x17,
|
||||||
0x08, 0xb7, 0xbc, 0x4c, 0xbb, 0xdc, 0xf7, 0x5f, 0x0c, 0x33, 0x80, 0x41, 0xe3, 0xf5, 0x23, 0x72,
|
0xf6, 0x42, 0x3e, 0xcd, 0xfa, 0xa3, 0x2c, 0x08, 0xe0, 0xf0, 0xd4, 0x6f, 0xe8, 0xd2, 0x4d, 0x45,
|
||||||
0xd3, 0xc6, 0xfe, 0xcd, 0x41, 0xd3, 0x7a, 0x71, 0x14, 0x6a, 0x78, 0x59, 0xfc, 0x0e, 0x61, 0x83,
|
0xd0, 0x22, 0xc5, 0xaf, 0xdb, 0x18, 0x1d, 0x02, 0xf8, 0x01, 0xb6, 0x5b, 0x84, 0x4d, 0xd1, 0x32,
|
||||||
0xff, 0x21, 0xb8, 0x4b, 0xe0, 0x37, 0x67, 0xba, 0xad, 0x03, 0x7b, 0xb2, 0xff, 0xa5, 0x4a, 0xf3,
|
0x91, 0xbf, 0x6d, 0x53, 0xc1, 0x84, 0xd5, 0x7c, 0x86, 0xb1, 0xe2, 0xd5, 0x08, 0x84, 0xd9, 0xc4,
|
||||||
0x7a, 0x31, 0x0f, 0xc3, 0x99, 0x6e, 0xb7, 0x73, 0x3a, 0xd1, 0x58, 0xf0, 0xff, 0x76, 0xca, 0x97,
|
0xfe, 0xbe, 0x5d, 0xbc, 0xa5, 0xd1, 0x90, 0xb6, 0x20, 0x4f, 0x8a, 0x41, 0xb0, 0xd9, 0x29, 0xc8,
|
||||||
0xdc, 0x92, 0x39, 0xb6, 0x08, 0x13, 0x2d, 0x15, 0xf5, 0x82, 0xc7, 0x60, 0x49, 0x2d, 0xa9, 0x95,
|
0x33, 0x72, 0x90, 0xf5, 0xdd, 0x9f, 0xca, 0x48, 0x39, 0x9e, 0x89, 0xfe, 0x03, 0x69, 0x5a, 0x0f,
|
||||||
0x62, 0x17, 0x3d, 0x78, 0x9b, 0x1f, 0xe8, 0x8d, 0xbc, 0x39, 0xdd, 0x52, 0xd1, 0x0c, 0x1e, 0x35,
|
0x01, 0x0b, 0x65, 0x22, 0x94, 0xe3, 0xa5, 0x26, 0xf6, 0x4f, 0x64, 0x4b, 0x00, 0x60, 0xd7, 0x49,
|
||||||
0xbb, 0xbf, 0xa0, 0x95, 0x07, 0xcf, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xed, 0x5f, 0x6c, 0x20,
|
0x95, 0xcd, 0x7d, 0xff, 0x45, 0x30, 0x01, 0xb0, 0x69, 0xb8, 0x5e, 0x17, 0x1b, 0x26, 0xf6, 0x6f,
|
||||||
0x74, 0x13, 0x00, 0x00,
|
0xda, 0x34, 0xae, 0xe7, 0x87, 0x58, 0x0d, 0x2e, 0xf3, 0xb7, 0x4a, 0x26, 0xf8, 0x1f, 0x84, 0xdb,
|
||||||
|
0x04, 0x7c, 0x73, 0xaa, 0x5a, 0xca, 0x37, 0x07, 0xfb, 0x5f, 0xcc, 0x34, 0xad, 0xe7, 0xb3, 0x6c,
|
||||||
|
0x20, 0x55, 0xad, 0x56, 0x86, 0xf3, 0xa9, 0x01, 0xff, 0x6f, 0xbb, 0x7c, 0x65, 0x51, 0x32, 0x90,
|
||||||
|
0xed, 0x07, 0xd7, 0x55, 0x2c, 0xfd, 0x48, 0x89, 0xc4, 0x64, 0xd8, 0x42, 0x83, 0x86, 0x1c, 0x9e,
|
||||||
|
0x67, 0x63, 0xae, 0x0c, 0xab, 0xdc, 0x61, 0xb6, 0x20, 0x17, 0xe4, 0x52, 0x5e, 0x67, 0xee, 0xbd,
|
||||||
|
0xd9, 0xf3, 0xd5, 0x5a, 0xd6, 0x9c, 0x74, 0x65, 0x38, 0x05, 0xbf, 0x3c, 0xda, 0x2f, 0x54, 0xcb,
|
||||||
|
0xdf, 0x21, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xaf, 0x70, 0x4e, 0x83, 0x15, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|||||||
+11
@@ -83,6 +83,10 @@ extend google.protobuf.FileOptions {
|
|||||||
optional bool enumdecl_all = 63031;
|
optional bool enumdecl_all = 63031;
|
||||||
|
|
||||||
optional bool goproto_registration = 63032;
|
optional bool goproto_registration = 63032;
|
||||||
|
optional bool messagename_all = 63033;
|
||||||
|
|
||||||
|
optional bool goproto_sizecache_all = 63034;
|
||||||
|
optional bool goproto_unkeyed_all = 63035;
|
||||||
}
|
}
|
||||||
|
|
||||||
extend google.protobuf.MessageOptions {
|
extend google.protobuf.MessageOptions {
|
||||||
@@ -115,6 +119,11 @@ extend google.protobuf.MessageOptions {
|
|||||||
optional bool compare = 64029;
|
optional bool compare = 64029;
|
||||||
|
|
||||||
optional bool typedecl = 64030;
|
optional bool typedecl = 64030;
|
||||||
|
|
||||||
|
optional bool messagename = 64033;
|
||||||
|
|
||||||
|
optional bool goproto_sizecache = 64034;
|
||||||
|
optional bool goproto_unkeyed = 64035;
|
||||||
}
|
}
|
||||||
|
|
||||||
extend google.protobuf.FieldOptions {
|
extend google.protobuf.FieldOptions {
|
||||||
@@ -130,4 +139,6 @@ extend google.protobuf.FieldOptions {
|
|||||||
|
|
||||||
optional bool stdtime = 65010;
|
optional bool stdtime = 65010;
|
||||||
optional bool stdduration = 65011;
|
optional bool stdduration = 65011;
|
||||||
|
optional bool wktpointer = 65012;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+61
-3
@@ -47,6 +47,55 @@ func IsStdDuration(field *google_protobuf.FieldDescriptorProto) bool {
|
|||||||
return proto.GetBoolExtension(field.Options, E_Stdduration, false)
|
return proto.GetBoolExtension(field.Options, E_Stdduration, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsStdDouble(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.DoubleValue"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsStdFloat(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.FloatValue"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsStdInt64(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.Int64Value"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsStdUInt64(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.UInt64Value"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsStdInt32(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.Int32Value"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsStdUInt32(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.UInt32Value"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsStdBool(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.BoolValue"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsStdString(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.StringValue"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsStdBytes(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.BytesValue"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsStdType(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return (IsStdTime(field) || IsStdDuration(field) ||
|
||||||
|
IsStdDouble(field) || IsStdFloat(field) ||
|
||||||
|
IsStdInt64(field) || IsStdUInt64(field) ||
|
||||||
|
IsStdInt32(field) || IsStdUInt32(field) ||
|
||||||
|
IsStdBool(field) ||
|
||||||
|
IsStdString(field) || IsStdBytes(field))
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsWktPtr(field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(field.Options, E_Wktpointer, false)
|
||||||
|
}
|
||||||
|
|
||||||
func NeedsNilCheck(proto3 bool, field *google_protobuf.FieldDescriptorProto) bool {
|
func NeedsNilCheck(proto3 bool, field *google_protobuf.FieldDescriptorProto) bool {
|
||||||
nullable := IsNullable(field)
|
nullable := IsNullable(field)
|
||||||
if field.IsMessage() || IsCustomType(field) {
|
if field.IsMessage() || IsCustomType(field) {
|
||||||
@@ -334,9 +383,6 @@ func HasExtensionsMap(file *google_protobuf.FileDescriptorProto, message *google
|
|||||||
}
|
}
|
||||||
|
|
||||||
func HasUnrecognized(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
func HasUnrecognized(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||||
if IsProto3(file) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return proto.GetBoolExtension(message.Options, E_GoprotoUnrecognized, proto.GetBoolExtension(file.Options, E_GoprotoUnrecognizedAll, true))
|
return proto.GetBoolExtension(message.Options, E_GoprotoUnrecognized, proto.GetBoolExtension(file.Options, E_GoprotoUnrecognizedAll, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,3 +401,15 @@ func HasCompare(file *google_protobuf.FileDescriptorProto, message *google_proto
|
|||||||
func RegistersGolangProto(file *google_protobuf.FileDescriptorProto) bool {
|
func RegistersGolangProto(file *google_protobuf.FileDescriptorProto) bool {
|
||||||
return proto.GetBoolExtension(file.Options, E_GoprotoRegistration, false)
|
return proto.GetBoolExtension(file.Options, E_GoprotoRegistration, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HasMessageName(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(message.Options, E_Messagename, proto.GetBoolExtension(file.Options, E_MessagenameAll, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func HasSizecache(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(message.Options, E_GoprotoSizecache, proto.GetBoolExtension(file.Options, E_GoprotoSizecacheAll, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
func HasUnkeyed(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(message.Options, E_GoprotoUnkeyed, proto.GetBoolExtension(file.Options, E_GoprotoUnkeyedAll, true))
|
||||||
|
}
|
||||||
|
|||||||
+14
-15
@@ -42,7 +42,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewDelimitedWriter(w io.Writer) WriteCloser {
|
func NewDelimitedWriter(w io.Writer) WriteCloser {
|
||||||
return &varintWriter{w, make([]byte, 10), nil}
|
return &varintWriter{w, make([]byte, binary.MaxVarintLen64), nil}
|
||||||
}
|
}
|
||||||
|
|
||||||
type varintWriter struct {
|
type varintWriter struct {
|
||||||
@@ -55,26 +55,25 @@ func (this *varintWriter) WriteMsg(msg proto.Message) (err error) {
|
|||||||
var data []byte
|
var data []byte
|
||||||
if m, ok := msg.(marshaler); ok {
|
if m, ok := msg.(marshaler); ok {
|
||||||
n, ok := getSize(m)
|
n, ok := getSize(m)
|
||||||
if !ok {
|
if ok {
|
||||||
data, err = proto.Marshal(msg)
|
if n+binary.MaxVarintLen64 >= len(this.buffer) {
|
||||||
|
this.buffer = make([]byte, n+binary.MaxVarintLen64)
|
||||||
|
}
|
||||||
|
lenOff := binary.PutUvarint(this.buffer, uint64(n))
|
||||||
|
_, err = m.MarshalTo(this.buffer[lenOff:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
_, err = this.w.Write(this.buffer[:lenOff+n])
|
||||||
if n >= len(this.buffer) {
|
|
||||||
this.buffer = make([]byte, n)
|
|
||||||
}
|
|
||||||
_, err = m.MarshalTo(this.buffer)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
data = this.buffer[:n]
|
|
||||||
} else {
|
|
||||||
data, err = proto.Marshal(msg)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fallback
|
||||||
|
data, err = proto.Marshal(msg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
length := uint64(len(data))
|
length := uint64(len(data))
|
||||||
n := binary.PutUvarint(this.lenBuf, length)
|
n := binary.PutUvarint(this.lenBuf, length)
|
||||||
_, err = this.w.Write(this.lenBuf[:n])
|
_, err = this.w.Write(this.lenBuf[:n])
|
||||||
|
|||||||
+226
-38
@@ -55,6 +55,8 @@ import (
|
|||||||
"github.com/gogo/protobuf/types"
|
"github.com/gogo/protobuf/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const secondInNanos = int64(time.Second / time.Nanosecond)
|
||||||
|
|
||||||
// Marshaler is a configurable object for converting between
|
// Marshaler is a configurable object for converting between
|
||||||
// protocol buffer objects and a JSON representation for them.
|
// protocol buffer objects and a JSON representation for them.
|
||||||
type Marshaler struct {
|
type Marshaler struct {
|
||||||
@@ -103,6 +105,9 @@ func defaultResolveAny(typeUrl string) (proto.Message, error) {
|
|||||||
// way they are marshaled to JSON. Messages that implement this should
|
// way they are marshaled to JSON. Messages that implement this should
|
||||||
// also implement JSONPBUnmarshaler so that the custom format can be
|
// also implement JSONPBUnmarshaler so that the custom format can be
|
||||||
// parsed.
|
// parsed.
|
||||||
|
//
|
||||||
|
// The JSON marshaling must follow the proto to JSON specification:
|
||||||
|
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
||||||
type JSONPBMarshaler interface {
|
type JSONPBMarshaler interface {
|
||||||
MarshalJSONPB(*Marshaler) ([]byte, error)
|
MarshalJSONPB(*Marshaler) ([]byte, error)
|
||||||
}
|
}
|
||||||
@@ -111,12 +116,23 @@ type JSONPBMarshaler interface {
|
|||||||
// the way they are unmarshaled from JSON. Messages that implement this
|
// the way they are unmarshaled from JSON. Messages that implement this
|
||||||
// should also implement JSONPBMarshaler so that the custom format can be
|
// should also implement JSONPBMarshaler so that the custom format can be
|
||||||
// produced.
|
// produced.
|
||||||
|
//
|
||||||
|
// The JSON unmarshaling must follow the JSON to proto specification:
|
||||||
|
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
||||||
type JSONPBUnmarshaler interface {
|
type JSONPBUnmarshaler interface {
|
||||||
UnmarshalJSONPB(*Unmarshaler, []byte) error
|
UnmarshalJSONPB(*Unmarshaler, []byte) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marshal marshals a protocol buffer into JSON.
|
// Marshal marshals a protocol buffer into JSON.
|
||||||
func (m *Marshaler) Marshal(out io.Writer, pb proto.Message) error {
|
func (m *Marshaler) Marshal(out io.Writer, pb proto.Message) error {
|
||||||
|
v := reflect.ValueOf(pb)
|
||||||
|
if pb == nil || (v.Kind() == reflect.Ptr && v.IsNil()) {
|
||||||
|
return errors.New("Marshal called with nil")
|
||||||
|
}
|
||||||
|
// Check for unset required fields first.
|
||||||
|
if err := checkRequiredFields(pb); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
writer := &errWriter{writer: out}
|
writer := &errWriter{writer: out}
|
||||||
return m.marshalObject(writer, pb, "", "")
|
return m.marshalObject(writer, pb, "", "")
|
||||||
}
|
}
|
||||||
@@ -189,13 +205,22 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU
|
|||||||
// Any is a bit more involved.
|
// Any is a bit more involved.
|
||||||
return m.marshalAny(out, v, indent)
|
return m.marshalAny(out, v, indent)
|
||||||
case "Duration":
|
case "Duration":
|
||||||
// "Generated output always contains 3, 6, or 9 fractional digits,
|
// "Generated output always contains 0, 3, 6, or 9 fractional digits,
|
||||||
// depending on required precision."
|
// depending on required precision."
|
||||||
s, ns := s.Field(0).Int(), s.Field(1).Int()
|
s, ns := s.Field(0).Int(), s.Field(1).Int()
|
||||||
d := time.Duration(s)*time.Second + time.Duration(ns)*time.Nanosecond
|
if ns <= -secondInNanos || ns >= secondInNanos {
|
||||||
x := fmt.Sprintf("%.9f", d.Seconds())
|
return fmt.Errorf("ns out of range (%v, %v)", -secondInNanos, secondInNanos)
|
||||||
|
}
|
||||||
|
if (s > 0 && ns < 0) || (s < 0 && ns > 0) {
|
||||||
|
return errors.New("signs of seconds and nanos do not match")
|
||||||
|
}
|
||||||
|
if s < 0 {
|
||||||
|
ns = -ns
|
||||||
|
}
|
||||||
|
x := fmt.Sprintf("%d.%09d", s, ns)
|
||||||
x = strings.TrimSuffix(x, "000")
|
x = strings.TrimSuffix(x, "000")
|
||||||
x = strings.TrimSuffix(x, "000")
|
x = strings.TrimSuffix(x, "000")
|
||||||
|
x = strings.TrimSuffix(x, ".000")
|
||||||
out.write(`"`)
|
out.write(`"`)
|
||||||
out.write(x)
|
out.write(x)
|
||||||
out.write(`s"`)
|
out.write(`s"`)
|
||||||
@@ -206,13 +231,17 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU
|
|||||||
return m.marshalValue(out, &proto.Properties{}, s.Field(0), indent)
|
return m.marshalValue(out, &proto.Properties{}, s.Field(0), indent)
|
||||||
case "Timestamp":
|
case "Timestamp":
|
||||||
// "RFC 3339, where generated output will always be Z-normalized
|
// "RFC 3339, where generated output will always be Z-normalized
|
||||||
// and uses 3, 6 or 9 fractional digits."
|
// and uses 0, 3, 6 or 9 fractional digits."
|
||||||
s, ns := s.Field(0).Int(), s.Field(1).Int()
|
s, ns := s.Field(0).Int(), s.Field(1).Int()
|
||||||
|
if ns < 0 || ns >= secondInNanos {
|
||||||
|
return fmt.Errorf("ns out of range [0, %v)", secondInNanos)
|
||||||
|
}
|
||||||
t := time.Unix(s, ns).UTC()
|
t := time.Unix(s, ns).UTC()
|
||||||
// time.RFC3339Nano isn't exactly right (we need to get 3/6/9 fractional digits).
|
// time.RFC3339Nano isn't exactly right (we need to get 3/6/9 fractional digits).
|
||||||
x := t.Format("2006-01-02T15:04:05.000000000")
|
x := t.Format("2006-01-02T15:04:05.000000000")
|
||||||
x = strings.TrimSuffix(x, "000")
|
x = strings.TrimSuffix(x, "000")
|
||||||
x = strings.TrimSuffix(x, "000")
|
x = strings.TrimSuffix(x, "000")
|
||||||
|
x = strings.TrimSuffix(x, ".000")
|
||||||
out.write(`"`)
|
out.write(`"`)
|
||||||
out.write(x)
|
out.write(x)
|
||||||
out.write(`Z"`)
|
out.write(`Z"`)
|
||||||
@@ -306,9 +335,9 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU
|
|||||||
m.writeSep(out)
|
m.writeSep(out)
|
||||||
}
|
}
|
||||||
// If the map value is a cast type, it may not implement proto.Message, therefore
|
// If the map value is a cast type, it may not implement proto.Message, therefore
|
||||||
// allow the struct tag to declare the underlying message type. Instead of changing
|
// allow the struct tag to declare the underlying message type. Change the property
|
||||||
// the signatures of the child types (and because prop.mvalue is not public), use
|
// of the child types, use CustomType as a passer. CastType currently property is
|
||||||
// CustomType as a passer.
|
// not used in json encoding.
|
||||||
if value.Kind() == reflect.Map {
|
if value.Kind() == reflect.Map {
|
||||||
if tag := valueField.Tag.Get("protobuf"); tag != "" {
|
if tag := valueField.Tag.Get("protobuf"); tag != "" {
|
||||||
for _, v := range strings.Split(tag, ",") {
|
for _, v := range strings.Split(tag, ",") {
|
||||||
@@ -316,7 +345,7 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
v = strings.TrimPrefix(v, "castvaluetype=")
|
v = strings.TrimPrefix(v, "castvaluetype=")
|
||||||
prop.CustomType = v
|
prop.MapValProp.CustomType = v
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -626,6 +655,7 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle
|
|||||||
out.write(m.Indent)
|
out.write(m.Indent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO handle map key prop properly
|
||||||
b, err := json.Marshal(k.Interface())
|
b, err := json.Marshal(k.Interface())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -647,7 +677,11 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle
|
|||||||
out.write(` `)
|
out.write(` `)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.marshalValue(out, prop, v.MapIndex(k), indent+m.Indent); err != nil {
|
vprop := prop
|
||||||
|
if prop != nil && prop.MapValProp != nil {
|
||||||
|
vprop = prop.MapValProp
|
||||||
|
}
|
||||||
|
if err := m.marshalValue(out, vprop, v.MapIndex(k), indent+m.Indent); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -716,7 +750,10 @@ func (u *Unmarshaler) UnmarshalNext(dec *json.Decoder, pb proto.Message) error {
|
|||||||
if err := dec.Decode(&inputValue); err != nil {
|
if err := dec.Decode(&inputValue); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return u.unmarshalValue(reflect.ValueOf(pb).Elem(), inputValue, nil)
|
if err := u.unmarshalValue(reflect.ValueOf(pb).Elem(), inputValue, nil); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return checkRequiredFields(pb)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal unmarshals a JSON object stream into a protocol
|
// Unmarshal unmarshals a JSON object stream into a protocol
|
||||||
@@ -836,7 +873,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
case "Duration":
|
case "Duration":
|
||||||
unq, err := strconv.Unquote(string(inputValue))
|
unq, err := unquote(string(inputValue))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -853,7 +890,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
|
|||||||
target.Field(1).SetInt(ns)
|
target.Field(1).SetInt(ns)
|
||||||
return nil
|
return nil
|
||||||
case "Timestamp":
|
case "Timestamp":
|
||||||
unq, err := strconv.Unquote(string(inputValue))
|
unq, err := unquote(string(inputValue))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -886,7 +923,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
|
|||||||
return fmt.Errorf("bad ListValue: %v", err)
|
return fmt.Errorf("bad ListValue: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
target.Field(0).Set(reflect.ValueOf(make([]*types.Value, len(s), len(s))))
|
target.Field(0).Set(reflect.ValueOf(make([]*types.Value, len(s))))
|
||||||
for i, sv := range s {
|
for i, sv := range s {
|
||||||
if err := u.unmarshalValue(target.Field(0).Index(i), sv, prop); err != nil {
|
if err := u.unmarshalValue(target.Field(0).Index(i), sv, prop); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -899,7 +936,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
|
|||||||
target.Field(0).Set(reflect.ValueOf(&types.Value_NullValue{}))
|
target.Field(0).Set(reflect.ValueOf(&types.Value_NullValue{}))
|
||||||
} else if v, err := strconv.ParseFloat(ivStr, 0); err == nil {
|
} else if v, err := strconv.ParseFloat(ivStr, 0); err == nil {
|
||||||
target.Field(0).Set(reflect.ValueOf(&types.Value_NumberValue{NumberValue: v}))
|
target.Field(0).Set(reflect.ValueOf(&types.Value_NumberValue{NumberValue: v}))
|
||||||
} else if v, err := strconv.Unquote(ivStr); err == nil {
|
} else if v, err := unquote(ivStr); err == nil {
|
||||||
target.Field(0).Set(reflect.ValueOf(&types.Value_StringValue{StringValue: v}))
|
target.Field(0).Set(reflect.ValueOf(&types.Value_StringValue{StringValue: v}))
|
||||||
} else if v, err := strconv.ParseBool(ivStr); err == nil {
|
} else if v, err := strconv.ParseBool(ivStr); err == nil {
|
||||||
target.Field(0).Set(reflect.ValueOf(&types.Value_BoolValue{BoolValue: v}))
|
target.Field(0).Set(reflect.ValueOf(&types.Value_BoolValue{BoolValue: v}))
|
||||||
@@ -961,20 +998,23 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
|
|||||||
target.Set(reflect.New(targetType.Elem()))
|
target.Set(reflect.New(targetType.Elem()))
|
||||||
target = target.Elem()
|
target = target.Elem()
|
||||||
}
|
}
|
||||||
|
if targetType.Kind() != reflect.Int32 {
|
||||||
|
return fmt.Errorf("invalid target %q for enum %s", targetType.Kind(), prop.Enum)
|
||||||
|
}
|
||||||
target.SetInt(int64(n))
|
target.SetInt(int64(n))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if prop != nil && len(prop.CustomType) > 0 && target.CanAddr() {
|
||||||
|
if m, ok := target.Addr().Interface().(interface {
|
||||||
|
UnmarshalJSON([]byte) error
|
||||||
|
}); ok {
|
||||||
|
return json.Unmarshal(inputValue, m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Handle nested messages.
|
// Handle nested messages.
|
||||||
if targetType.Kind() == reflect.Struct {
|
if targetType.Kind() == reflect.Struct {
|
||||||
if prop != nil && len(prop.CustomType) > 0 && target.CanAddr() {
|
|
||||||
if m, ok := target.Addr().Interface().(interface {
|
|
||||||
UnmarshalJSON([]byte) error
|
|
||||||
}); ok {
|
|
||||||
return json.Unmarshal(inputValue, m)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var jsonFields map[string]json.RawMessage
|
var jsonFields map[string]json.RawMessage
|
||||||
if err := json.Unmarshal(inputValue, &jsonFields); err != nil {
|
if err := json.Unmarshal(inputValue, &jsonFields); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -1114,13 +1154,6 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
|
|||||||
}
|
}
|
||||||
if mp != nil {
|
if mp != nil {
|
||||||
target.Set(reflect.MakeMap(targetType))
|
target.Set(reflect.MakeMap(targetType))
|
||||||
var keyprop, valprop *proto.Properties
|
|
||||||
if prop != nil {
|
|
||||||
// These could still be nil if the protobuf metadata is broken somehow.
|
|
||||||
// TODO: This won't work because the fields are unexported.
|
|
||||||
// We should probably just reparse them.
|
|
||||||
//keyprop, valprop = prop.mkeyprop, prop.mvalprop
|
|
||||||
}
|
|
||||||
for ks, raw := range mp {
|
for ks, raw := range mp {
|
||||||
// Unmarshal map key. The core json library already decoded the key into a
|
// Unmarshal map key. The core json library already decoded the key into a
|
||||||
// string, so we handle that specially. Other types were quoted post-serialization.
|
// string, so we handle that specially. Other types were quoted post-serialization.
|
||||||
@@ -1129,7 +1162,11 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
|
|||||||
k = reflect.ValueOf(ks)
|
k = reflect.ValueOf(ks)
|
||||||
} else {
|
} else {
|
||||||
k = reflect.New(targetType.Key()).Elem()
|
k = reflect.New(targetType.Key()).Elem()
|
||||||
if err := u.unmarshalValue(k, json.RawMessage(ks), keyprop); err != nil {
|
var kprop *proto.Properties
|
||||||
|
if prop != nil && prop.MapKeyProp != nil {
|
||||||
|
kprop = prop.MapKeyProp
|
||||||
|
}
|
||||||
|
if err := u.unmarshalValue(k, json.RawMessage(ks), kprop); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1140,7 +1177,11 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
|
|||||||
|
|
||||||
// Unmarshal map value.
|
// Unmarshal map value.
|
||||||
v := reflect.New(targetType.Elem()).Elem()
|
v := reflect.New(targetType.Elem()).Elem()
|
||||||
if err := u.unmarshalValue(v, raw, valprop); err != nil {
|
var vprop *proto.Properties
|
||||||
|
if prop != nil && prop.MapValProp != nil {
|
||||||
|
vprop = prop.MapValProp
|
||||||
|
}
|
||||||
|
if err := u.unmarshalValue(v, raw, vprop); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
target.SetMapIndex(k, v)
|
target.SetMapIndex(k, v)
|
||||||
@@ -1149,13 +1190,6 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 64-bit integers can be encoded as strings. In this case we drop
|
|
||||||
// the quotes and proceed as normal.
|
|
||||||
isNum := targetType.Kind() == reflect.Int64 || targetType.Kind() == reflect.Uint64
|
|
||||||
if isNum && strings.HasPrefix(string(inputValue), `"`) {
|
|
||||||
inputValue = inputValue[1 : len(inputValue)-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Non-finite numbers can be encoded as strings.
|
// Non-finite numbers can be encoded as strings.
|
||||||
isFloat := targetType.Kind() == reflect.Float32 || targetType.Kind() == reflect.Float64
|
isFloat := targetType.Kind() == reflect.Float32 || targetType.Kind() == reflect.Float64
|
||||||
if isFloat {
|
if isFloat {
|
||||||
@@ -1165,10 +1199,25 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// integers & floats can be encoded as strings. In this case we drop
|
||||||
|
// the quotes and proceed as normal.
|
||||||
|
isNum := targetType.Kind() == reflect.Int64 || targetType.Kind() == reflect.Uint64 ||
|
||||||
|
targetType.Kind() == reflect.Int32 || targetType.Kind() == reflect.Uint32 ||
|
||||||
|
targetType.Kind() == reflect.Float32 || targetType.Kind() == reflect.Float64
|
||||||
|
if isNum && strings.HasPrefix(string(inputValue), `"`) {
|
||||||
|
inputValue = inputValue[1 : len(inputValue)-1]
|
||||||
|
}
|
||||||
|
|
||||||
// Use the encoding/json for parsing other value types.
|
// Use the encoding/json for parsing other value types.
|
||||||
return json.Unmarshal(inputValue, target.Addr().Interface())
|
return json.Unmarshal(inputValue, target.Addr().Interface())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func unquote(s string) (string, error) {
|
||||||
|
var ret string
|
||||||
|
err := json.Unmarshal([]byte(s), &ret)
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
// jsonProperties returns parsed proto.Properties for the field and corrects JSONName attribute.
|
// jsonProperties returns parsed proto.Properties for the field and corrects JSONName attribute.
|
||||||
func jsonProperties(f reflect.StructField, origName bool) *proto.Properties {
|
func jsonProperties(f reflect.StructField, origName bool) *proto.Properties {
|
||||||
var prop proto.Properties
|
var prop proto.Properties
|
||||||
@@ -1218,6 +1267,8 @@ func (s mapKeys) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
|||||||
func (s mapKeys) Less(i, j int) bool {
|
func (s mapKeys) Less(i, j int) bool {
|
||||||
if k := s[i].Kind(); k == s[j].Kind() {
|
if k := s[i].Kind(); k == s[j].Kind() {
|
||||||
switch k {
|
switch k {
|
||||||
|
case reflect.String:
|
||||||
|
return s[i].String() < s[j].String()
|
||||||
case reflect.Int32, reflect.Int64:
|
case reflect.Int32, reflect.Int64:
|
||||||
return s[i].Int() < s[j].Int()
|
return s[i].Int() < s[j].Int()
|
||||||
case reflect.Uint32, reflect.Uint64:
|
case reflect.Uint32, reflect.Uint64:
|
||||||
@@ -1226,3 +1277,140 @@ func (s mapKeys) Less(i, j int) bool {
|
|||||||
}
|
}
|
||||||
return fmt.Sprint(s[i].Interface()) < fmt.Sprint(s[j].Interface())
|
return fmt.Sprint(s[i].Interface()) < fmt.Sprint(s[j].Interface())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checkRequiredFields returns an error if any required field in the given proto message is not set.
|
||||||
|
// This function is used by both Marshal and Unmarshal. While required fields only exist in a
|
||||||
|
// proto2 message, a proto3 message can contain proto2 message(s).
|
||||||
|
func checkRequiredFields(pb proto.Message) error {
|
||||||
|
// Most well-known type messages do not contain required fields. The "Any" type may contain
|
||||||
|
// a message that has required fields.
|
||||||
|
//
|
||||||
|
// When an Any message is being marshaled, the code will invoked proto.Unmarshal on Any.Value
|
||||||
|
// field in order to transform that into JSON, and that should have returned an error if a
|
||||||
|
// required field is not set in the embedded message.
|
||||||
|
//
|
||||||
|
// When an Any message is being unmarshaled, the code will have invoked proto.Marshal on the
|
||||||
|
// embedded message to store the serialized message in Any.Value field, and that should have
|
||||||
|
// returned an error if a required field is not set.
|
||||||
|
if _, ok := pb.(isWkt); ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
v := reflect.ValueOf(pb)
|
||||||
|
// Skip message if it is not a struct pointer.
|
||||||
|
if v.Kind() != reflect.Ptr {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
v = v.Elem()
|
||||||
|
if v.Kind() != reflect.Struct {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < v.NumField(); i++ {
|
||||||
|
field := v.Field(i)
|
||||||
|
sfield := v.Type().Field(i)
|
||||||
|
|
||||||
|
if sfield.PkgPath != "" {
|
||||||
|
// blank PkgPath means the field is exported; skip if not exported
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(sfield.Name, "XXX_") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Oneof field is an interface implemented by wrapper structs containing the actual oneof
|
||||||
|
// field, i.e. an interface containing &T{real_value}.
|
||||||
|
if sfield.Tag.Get("protobuf_oneof") != "" {
|
||||||
|
if field.Kind() != reflect.Interface {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
v := field.Elem()
|
||||||
|
if v.Kind() != reflect.Ptr || v.IsNil() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
v = v.Elem()
|
||||||
|
if v.Kind() != reflect.Struct || v.NumField() < 1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
field = v.Field(0)
|
||||||
|
sfield = v.Type().Field(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
protoTag := sfield.Tag.Get("protobuf")
|
||||||
|
if protoTag == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var prop proto.Properties
|
||||||
|
prop.Init(sfield.Type, sfield.Name, protoTag, &sfield)
|
||||||
|
|
||||||
|
switch field.Kind() {
|
||||||
|
case reflect.Map:
|
||||||
|
if field.IsNil() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// Check each map value.
|
||||||
|
keys := field.MapKeys()
|
||||||
|
for _, k := range keys {
|
||||||
|
v := field.MapIndex(k)
|
||||||
|
if err := checkRequiredFieldsInValue(v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Slice:
|
||||||
|
// Handle non-repeated type, e.g. bytes.
|
||||||
|
if !prop.Repeated {
|
||||||
|
if prop.Required && field.IsNil() {
|
||||||
|
return fmt.Errorf("required field %q is not set", prop.Name)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle repeated type.
|
||||||
|
if field.IsNil() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// Check each slice item.
|
||||||
|
for i := 0; i < field.Len(); i++ {
|
||||||
|
v := field.Index(i)
|
||||||
|
if err := checkRequiredFieldsInValue(v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Ptr:
|
||||||
|
if field.IsNil() {
|
||||||
|
if prop.Required {
|
||||||
|
return fmt.Errorf("required field %q is not set", prop.Name)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := checkRequiredFieldsInValue(field); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle proto2 extensions.
|
||||||
|
for _, ext := range proto.RegisteredExtensions(pb) {
|
||||||
|
if !proto.HasExtension(pb, ext) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ep, err := proto.GetExtension(pb, ext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = checkRequiredFieldsInValue(reflect.ValueOf(ep))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkRequiredFieldsInValue(v reflect.Value) error {
|
||||||
|
if pm, ok := v.Interface().(proto.Message); ok {
|
||||||
|
return checkRequiredFields(pm)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
+164
-62
@@ -1,29 +1,6 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: more_test_objects.proto
|
// source: more_test_objects.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package jsonpb is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
more_test_objects.proto
|
|
||||||
test_objects.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
Simple3
|
|
||||||
SimpleSlice3
|
|
||||||
SimpleMap3
|
|
||||||
SimpleNull3
|
|
||||||
Mappy
|
|
||||||
Simple
|
|
||||||
NonFinites
|
|
||||||
Repeats
|
|
||||||
Widget
|
|
||||||
Maps
|
|
||||||
MsgWithOneof
|
|
||||||
Real
|
|
||||||
Complex
|
|
||||||
KnownTypes
|
|
||||||
*/
|
|
||||||
package jsonpb
|
package jsonpb
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
@@ -63,16 +40,40 @@ var Numeral_value = map[string]int32{
|
|||||||
func (x Numeral) String() string {
|
func (x Numeral) String() string {
|
||||||
return proto.EnumName(Numeral_name, int32(x))
|
return proto.EnumName(Numeral_name, int32(x))
|
||||||
}
|
}
|
||||||
func (Numeral) EnumDescriptor() ([]byte, []int) { return fileDescriptorMoreTestObjects, []int{0} }
|
func (Numeral) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{0}
|
||||||
type Simple3 struct {
|
|
||||||
Dub float64 `protobuf:"fixed64,1,opt,name=dub,proto3" json:"dub,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Simple3) Reset() { *m = Simple3{} }
|
type Simple3 struct {
|
||||||
func (m *Simple3) String() string { return proto.CompactTextString(m) }
|
Dub float64 `protobuf:"fixed64,1,opt,name=dub,proto3" json:"dub,omitempty"`
|
||||||
func (*Simple3) ProtoMessage() {}
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
func (*Simple3) Descriptor() ([]byte, []int) { return fileDescriptorMoreTestObjects, []int{0} }
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Simple3) Reset() { *m = Simple3{} }
|
||||||
|
func (m *Simple3) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Simple3) ProtoMessage() {}
|
||||||
|
func (*Simple3) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{0}
|
||||||
|
}
|
||||||
|
func (m *Simple3) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Simple3.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Simple3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Simple3.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *Simple3) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Simple3.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *Simple3) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Simple3.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Simple3) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Simple3.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Simple3 proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *Simple3) GetDub() float64 {
|
func (m *Simple3) GetDub() float64 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -82,13 +83,35 @@ func (m *Simple3) GetDub() float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SimpleSlice3 struct {
|
type SimpleSlice3 struct {
|
||||||
Slices []string `protobuf:"bytes,1,rep,name=slices" json:"slices,omitempty"`
|
Slices []string `protobuf:"bytes,1,rep,name=slices,proto3" json:"slices,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SimpleSlice3) Reset() { *m = SimpleSlice3{} }
|
func (m *SimpleSlice3) Reset() { *m = SimpleSlice3{} }
|
||||||
func (m *SimpleSlice3) String() string { return proto.CompactTextString(m) }
|
func (m *SimpleSlice3) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SimpleSlice3) ProtoMessage() {}
|
func (*SimpleSlice3) ProtoMessage() {}
|
||||||
func (*SimpleSlice3) Descriptor() ([]byte, []int) { return fileDescriptorMoreTestObjects, []int{1} }
|
func (*SimpleSlice3) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{1}
|
||||||
|
}
|
||||||
|
func (m *SimpleSlice3) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_SimpleSlice3.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *SimpleSlice3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_SimpleSlice3.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *SimpleSlice3) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_SimpleSlice3.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *SimpleSlice3) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_SimpleSlice3.Size(m)
|
||||||
|
}
|
||||||
|
func (m *SimpleSlice3) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_SimpleSlice3.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_SimpleSlice3 proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *SimpleSlice3) GetSlices() []string {
|
func (m *SimpleSlice3) GetSlices() []string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -98,13 +121,35 @@ func (m *SimpleSlice3) GetSlices() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SimpleMap3 struct {
|
type SimpleMap3 struct {
|
||||||
Stringy map[string]string `protobuf:"bytes,1,rep,name=stringy" json:"stringy,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
Stringy map[string]string `protobuf:"bytes,1,rep,name=stringy,proto3" json:"stringy,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SimpleMap3) Reset() { *m = SimpleMap3{} }
|
func (m *SimpleMap3) Reset() { *m = SimpleMap3{} }
|
||||||
func (m *SimpleMap3) String() string { return proto.CompactTextString(m) }
|
func (m *SimpleMap3) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SimpleMap3) ProtoMessage() {}
|
func (*SimpleMap3) ProtoMessage() {}
|
||||||
func (*SimpleMap3) Descriptor() ([]byte, []int) { return fileDescriptorMoreTestObjects, []int{2} }
|
func (*SimpleMap3) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{2}
|
||||||
|
}
|
||||||
|
func (m *SimpleMap3) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_SimpleMap3.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *SimpleMap3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_SimpleMap3.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *SimpleMap3) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_SimpleMap3.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *SimpleMap3) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_SimpleMap3.Size(m)
|
||||||
|
}
|
||||||
|
func (m *SimpleMap3) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_SimpleMap3.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_SimpleMap3 proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *SimpleMap3) GetStringy() map[string]string {
|
func (m *SimpleMap3) GetStringy() map[string]string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -114,13 +159,35 @@ func (m *SimpleMap3) GetStringy() map[string]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SimpleNull3 struct {
|
type SimpleNull3 struct {
|
||||||
Simple *Simple3 `protobuf:"bytes,1,opt,name=simple" json:"simple,omitempty"`
|
Simple *Simple3 `protobuf:"bytes,1,opt,name=simple,proto3" json:"simple,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SimpleNull3) Reset() { *m = SimpleNull3{} }
|
func (m *SimpleNull3) Reset() { *m = SimpleNull3{} }
|
||||||
func (m *SimpleNull3) String() string { return proto.CompactTextString(m) }
|
func (m *SimpleNull3) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SimpleNull3) ProtoMessage() {}
|
func (*SimpleNull3) ProtoMessage() {}
|
||||||
func (*SimpleNull3) Descriptor() ([]byte, []int) { return fileDescriptorMoreTestObjects, []int{3} }
|
func (*SimpleNull3) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{3}
|
||||||
|
}
|
||||||
|
func (m *SimpleNull3) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_SimpleNull3.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *SimpleNull3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_SimpleNull3.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *SimpleNull3) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_SimpleNull3.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *SimpleNull3) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_SimpleNull3.Size(m)
|
||||||
|
}
|
||||||
|
func (m *SimpleNull3) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_SimpleNull3.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_SimpleNull3 proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *SimpleNull3) GetSimple() *Simple3 {
|
func (m *SimpleNull3) GetSimple() *Simple3 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -130,22 +197,44 @@ func (m *SimpleNull3) GetSimple() *Simple3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Mappy struct {
|
type Mappy struct {
|
||||||
Nummy map[int64]int32 `protobuf:"bytes,1,rep,name=nummy" json:"nummy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
Nummy map[int64]int32 `protobuf:"bytes,1,rep,name=nummy,proto3" json:"nummy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
Strry map[string]string `protobuf:"bytes,2,rep,name=strry" json:"strry,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
Strry map[string]string `protobuf:"bytes,2,rep,name=strry,proto3" json:"strry,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
Objjy map[int32]*Simple3 `protobuf:"bytes,3,rep,name=objjy" json:"objjy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"`
|
Objjy map[int32]*Simple3 `protobuf:"bytes,3,rep,name=objjy,proto3" json:"objjy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
Buggy map[int64]string `protobuf:"bytes,4,rep,name=buggy" json:"buggy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
Buggy map[int64]string `protobuf:"bytes,4,rep,name=buggy,proto3" json:"buggy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
Booly map[bool]bool `protobuf:"bytes,5,rep,name=booly" json:"booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
Booly map[bool]bool `protobuf:"bytes,5,rep,name=booly,proto3" json:"booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
Enumy map[string]Numeral `protobuf:"bytes,6,rep,name=enumy" json:"enumy,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=jsonpb.Numeral"`
|
Enumy map[string]Numeral `protobuf:"bytes,6,rep,name=enumy,proto3" json:"enumy,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=jsonpb.Numeral"`
|
||||||
S32Booly map[int32]bool `protobuf:"bytes,7,rep,name=s32booly" json:"s32booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
S32Booly map[int32]bool `protobuf:"bytes,7,rep,name=s32booly,proto3" json:"s32booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
S64Booly map[int64]bool `protobuf:"bytes,8,rep,name=s64booly" json:"s64booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
S64Booly map[int64]bool `protobuf:"bytes,8,rep,name=s64booly,proto3" json:"s64booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
U32Booly map[uint32]bool `protobuf:"bytes,9,rep,name=u32booly" json:"u32booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
U32Booly map[uint32]bool `protobuf:"bytes,9,rep,name=u32booly,proto3" json:"u32booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
U64Booly map[uint64]bool `protobuf:"bytes,10,rep,name=u64booly" json:"u64booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
U64Booly map[uint64]bool `protobuf:"bytes,10,rep,name=u64booly,proto3" json:"u64booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mappy) Reset() { *m = Mappy{} }
|
func (m *Mappy) Reset() { *m = Mappy{} }
|
||||||
func (m *Mappy) String() string { return proto.CompactTextString(m) }
|
func (m *Mappy) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Mappy) ProtoMessage() {}
|
func (*Mappy) ProtoMessage() {}
|
||||||
func (*Mappy) Descriptor() ([]byte, []int) { return fileDescriptorMoreTestObjects, []int{4} }
|
func (*Mappy) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{4}
|
||||||
|
}
|
||||||
|
func (m *Mappy) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Mappy.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Mappy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Mappy.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *Mappy) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Mappy.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *Mappy) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Mappy.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Mappy) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Mappy.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Mappy proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *Mappy) GetNummy() map[int64]int32 {
|
func (m *Mappy) GetNummy() map[int64]int32 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -221,14 +310,27 @@ func init() {
|
|||||||
proto.RegisterType((*Simple3)(nil), "jsonpb.Simple3")
|
proto.RegisterType((*Simple3)(nil), "jsonpb.Simple3")
|
||||||
proto.RegisterType((*SimpleSlice3)(nil), "jsonpb.SimpleSlice3")
|
proto.RegisterType((*SimpleSlice3)(nil), "jsonpb.SimpleSlice3")
|
||||||
proto.RegisterType((*SimpleMap3)(nil), "jsonpb.SimpleMap3")
|
proto.RegisterType((*SimpleMap3)(nil), "jsonpb.SimpleMap3")
|
||||||
|
proto.RegisterMapType((map[string]string)(nil), "jsonpb.SimpleMap3.StringyEntry")
|
||||||
proto.RegisterType((*SimpleNull3)(nil), "jsonpb.SimpleNull3")
|
proto.RegisterType((*SimpleNull3)(nil), "jsonpb.SimpleNull3")
|
||||||
proto.RegisterType((*Mappy)(nil), "jsonpb.Mappy")
|
proto.RegisterType((*Mappy)(nil), "jsonpb.Mappy")
|
||||||
|
proto.RegisterMapType((map[bool]bool)(nil), "jsonpb.Mappy.BoolyEntry")
|
||||||
|
proto.RegisterMapType((map[int64]string)(nil), "jsonpb.Mappy.BuggyEntry")
|
||||||
|
proto.RegisterMapType((map[string]Numeral)(nil), "jsonpb.Mappy.EnumyEntry")
|
||||||
|
proto.RegisterMapType((map[int64]int32)(nil), "jsonpb.Mappy.NummyEntry")
|
||||||
|
proto.RegisterMapType((map[int32]*Simple3)(nil), "jsonpb.Mappy.ObjjyEntry")
|
||||||
|
proto.RegisterMapType((map[int32]bool)(nil), "jsonpb.Mappy.S32boolyEntry")
|
||||||
|
proto.RegisterMapType((map[int64]bool)(nil), "jsonpb.Mappy.S64boolyEntry")
|
||||||
|
proto.RegisterMapType((map[string]string)(nil), "jsonpb.Mappy.StrryEntry")
|
||||||
|
proto.RegisterMapType((map[uint32]bool)(nil), "jsonpb.Mappy.U32boolyEntry")
|
||||||
|
proto.RegisterMapType((map[uint64]bool)(nil), "jsonpb.Mappy.U64boolyEntry")
|
||||||
proto.RegisterEnum("jsonpb.Numeral", Numeral_name, Numeral_value)
|
proto.RegisterEnum("jsonpb.Numeral", Numeral_name, Numeral_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("more_test_objects.proto", fileDescriptorMoreTestObjects) }
|
func init() {
|
||||||
|
proto.RegisterFile("more_test_objects.proto", fileDescriptor_more_test_objects_bef0d79b901f4c4a)
|
||||||
|
}
|
||||||
|
|
||||||
var fileDescriptorMoreTestObjects = []byte{
|
var fileDescriptor_more_test_objects_bef0d79b901f4c4a = []byte{
|
||||||
// 526 bytes of a gzipped FileDescriptorProto
|
// 526 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xdd, 0x6b, 0xdb, 0x3c,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xdd, 0x6b, 0xdb, 0x3c,
|
||||||
0x14, 0x87, 0x5f, 0x27, 0xf5, 0xd7, 0x49, 0xfb, 0x2e, 0x88, 0xb1, 0x99, 0xf4, 0x62, 0xc5, 0xb0,
|
0x14, 0x87, 0x5f, 0x27, 0xf5, 0xd7, 0x49, 0xfb, 0x2e, 0x88, 0xb1, 0x99, 0xf4, 0x62, 0xc5, 0xb0,
|
||||||
|
|||||||
+696
-204
File diff suppressed because it is too large
Load Diff
+42
-10
@@ -45,16 +45,24 @@ import weak "gogoproto/gogo.proto";
|
|||||||
message Simple {
|
message Simple {
|
||||||
optional bool o_bool = 1;
|
optional bool o_bool = 1;
|
||||||
optional int32 o_int32 = 2;
|
optional int32 o_int32 = 2;
|
||||||
optional int64 o_int64 = 3;
|
optional int32 o_int32_str = 3;
|
||||||
optional uint32 o_uint32 = 4;
|
optional int64 o_int64 = 4;
|
||||||
optional uint64 o_uint64 = 5;
|
optional int64 o_int64_str = 5;
|
||||||
optional sint32 o_sint32 = 6;
|
optional uint32 o_uint32 = 6;
|
||||||
optional sint64 o_sint64 = 7;
|
optional uint32 o_uint32_str = 7;
|
||||||
optional float o_float = 8;
|
optional uint64 o_uint64 = 8;
|
||||||
optional double o_double = 9;
|
optional uint64 o_uint64_str = 9;
|
||||||
optional string o_string = 10;
|
optional sint32 o_sint32 = 10;
|
||||||
optional bytes o_bytes = 11;
|
optional sint32 o_sint32_str = 11;
|
||||||
optional bytes o_cast_bytes = 12 [(gogoproto.casttype) = "Bytes"];
|
optional sint64 o_sint64 = 12;
|
||||||
|
optional sint64 o_sint64_str = 13;
|
||||||
|
optional float o_float = 14;
|
||||||
|
optional float o_float_str = 15;
|
||||||
|
optional double o_double = 16;
|
||||||
|
optional double o_double_str = 17;
|
||||||
|
optional string o_string = 18;
|
||||||
|
optional bytes o_bytes = 19;
|
||||||
|
optional bytes o_cast_bytes = 20 [(gogoproto.casttype) = "Bytes"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test message for holding special non-finites primitives.
|
// Test message for holding special non-finites primitives.
|
||||||
@@ -111,6 +119,7 @@ message MsgWithOneof {
|
|||||||
int64 salary = 2;
|
int64 salary = 2;
|
||||||
string Country = 3;
|
string Country = 3;
|
||||||
string home_address = 4;
|
string home_address = 4;
|
||||||
|
MsgWithRequired msg_with_required = 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,3 +158,26 @@ message KnownTypes {
|
|||||||
optional google.protobuf.StringValue str = 10;
|
optional google.protobuf.StringValue str = 10;
|
||||||
optional google.protobuf.BytesValue bytes = 11;
|
optional google.protobuf.BytesValue bytes = 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test messages for marshaling/unmarshaling required fields.
|
||||||
|
message MsgWithRequired {
|
||||||
|
required string str = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MsgWithIndirectRequired {
|
||||||
|
optional MsgWithRequired subm = 1;
|
||||||
|
map<string, MsgWithRequired> map_field = 2;
|
||||||
|
repeated MsgWithRequired slice_field = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MsgWithRequiredBytes {
|
||||||
|
required bytes byts = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MsgWithRequiredWKT {
|
||||||
|
required google.protobuf.StringValue str = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extend Real {
|
||||||
|
optional MsgWithRequired extm = 125;
|
||||||
|
}
|
||||||
|
|||||||
+3
-2
@@ -47,9 +47,10 @@ package embedcheck
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/gogo/protobuf/gogoproto"
|
"github.com/gogo/protobuf/gogoproto"
|
||||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type plugin struct {
|
type plugin struct {
|
||||||
@@ -163,7 +164,7 @@ func (p *plugin) checkOverwrite(message *generator.Descriptor, enablers map[stri
|
|||||||
desc := p.ObjectNamed(field.GetTypeName())
|
desc := p.ObjectNamed(field.GetTypeName())
|
||||||
msg := desc.(*generator.Descriptor)
|
msg := desc.(*generator.Descriptor)
|
||||||
for errStr, enabled := range enablers {
|
for errStr, enabled := range enablers {
|
||||||
if enabled(msg.File(), msg.DescriptorProto) {
|
if enabled(msg.File().FileDescriptorProto, msg.DescriptorProto) {
|
||||||
fmt.Fprintf(os.Stderr, "WARNING: found non-%v %v with embedded %v %v\n", names, ccTypeName, errStr, fieldname)
|
fmt.Fprintf(os.Stderr, "WARNING: found non-%v %v with embedded %v %v\n", names, ccTypeName, errStr, fieldname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+68
-5
@@ -292,7 +292,16 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato
|
|||||||
repeated := field.IsRepeated()
|
repeated := field.IsRepeated()
|
||||||
ctype := gogoproto.IsCustomType(field)
|
ctype := gogoproto.IsCustomType(field)
|
||||||
nullable := gogoproto.IsNullable(field)
|
nullable := gogoproto.IsNullable(field)
|
||||||
isDuration := gogoproto.IsStdDuration(field)
|
isNormal := (gogoproto.IsStdDuration(field) ||
|
||||||
|
gogoproto.IsStdDouble(field) ||
|
||||||
|
gogoproto.IsStdFloat(field) ||
|
||||||
|
gogoproto.IsStdInt64(field) ||
|
||||||
|
gogoproto.IsStdUInt64(field) ||
|
||||||
|
gogoproto.IsStdInt32(field) ||
|
||||||
|
gogoproto.IsStdUInt32(field) ||
|
||||||
|
gogoproto.IsStdBool(field) ||
|
||||||
|
gogoproto.IsStdString(field))
|
||||||
|
isBytes := gogoproto.IsStdBytes(field)
|
||||||
isTimestamp := gogoproto.IsStdTime(field)
|
isTimestamp := gogoproto.IsStdTime(field)
|
||||||
// oneof := field.OneofIndex != nil
|
// oneof := field.OneofIndex != nil
|
||||||
if !repeated {
|
if !repeated {
|
||||||
@@ -322,7 +331,7 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato
|
|||||||
}
|
}
|
||||||
p.Out()
|
p.Out()
|
||||||
p.P(`}`)
|
p.P(`}`)
|
||||||
} else if isDuration {
|
} else if isNormal {
|
||||||
if nullable {
|
if nullable {
|
||||||
p.generateNullableField(fieldname, verbose)
|
p.generateNullableField(fieldname, verbose)
|
||||||
} else {
|
} else {
|
||||||
@@ -336,6 +345,32 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato
|
|||||||
}
|
}
|
||||||
p.Out()
|
p.Out()
|
||||||
p.P(`}`)
|
p.P(`}`)
|
||||||
|
} else if isBytes {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if that1.`, fieldname, ` == nil {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`if this.`, fieldname, ` != nil {`)
|
||||||
|
p.In()
|
||||||
|
if verbose {
|
||||||
|
p.P(`return `, p.fmtPkg.Use(), `.Errorf("this.`, fieldname, ` != nil && that1.`, fieldname, ` == nil")`)
|
||||||
|
} else {
|
||||||
|
p.P(`return false`)
|
||||||
|
}
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
|
p.Out()
|
||||||
|
p.P(`} else if !`, p.bytesPkg.Use(), `.Equal(*this.`, fieldname, `, *that1.`, fieldname, `) {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `, that1.`, fieldname, `) {`)
|
||||||
|
}
|
||||||
|
p.In()
|
||||||
|
if verbose {
|
||||||
|
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", this.`, fieldname, `, that1.`, fieldname, `)`)
|
||||||
|
} else {
|
||||||
|
p.P(`return false`)
|
||||||
|
}
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
} else {
|
} else {
|
||||||
if field.IsMessage() || p.IsGroup(field) {
|
if field.IsMessage() || p.IsGroup(field) {
|
||||||
if nullable {
|
if nullable {
|
||||||
@@ -387,12 +422,18 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato
|
|||||||
} else {
|
} else {
|
||||||
p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`)
|
p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`)
|
||||||
}
|
}
|
||||||
} else if isDuration {
|
} else if isNormal {
|
||||||
if nullable {
|
if nullable {
|
||||||
p.P(`if dthis, dthat := this.`, fieldname, `[i], that1.`, fieldname, `[i]; (dthis != nil && dthat != nil && *dthis != *dthat) || (dthis != nil && dthat == nil) || (dthis == nil && dthat != nil) {`)
|
p.P(`if dthis, dthat := this.`, fieldname, `[i], that1.`, fieldname, `[i]; (dthis != nil && dthat != nil && *dthis != *dthat) || (dthis != nil && dthat == nil) || (dthis == nil && dthat != nil) {`)
|
||||||
} else {
|
} else {
|
||||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||||
}
|
}
|
||||||
|
} else if isBytes {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if !`, p.bytesPkg.Use(), `.Equal(*this.`, fieldname, `[i], *that1.`, fieldname, `[i]) {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `[i], that1.`, fieldname, `[i]) {`)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if p.IsMap(field) {
|
if p.IsMap(field) {
|
||||||
m := p.GoMapType(nil, field)
|
m := p.GoMapType(nil, field)
|
||||||
@@ -401,6 +442,16 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato
|
|||||||
nullable, valuegoTyp, valuegoAliasTyp = generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp)
|
nullable, valuegoTyp, valuegoAliasTyp = generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp)
|
||||||
|
|
||||||
mapValue := m.ValueAliasField
|
mapValue := m.ValueAliasField
|
||||||
|
mapValueNormal := (gogoproto.IsStdDuration(mapValue) ||
|
||||||
|
gogoproto.IsStdDouble(mapValue) ||
|
||||||
|
gogoproto.IsStdFloat(mapValue) ||
|
||||||
|
gogoproto.IsStdInt64(mapValue) ||
|
||||||
|
gogoproto.IsStdUInt64(mapValue) ||
|
||||||
|
gogoproto.IsStdInt32(mapValue) ||
|
||||||
|
gogoproto.IsStdUInt32(mapValue) ||
|
||||||
|
gogoproto.IsStdBool(mapValue) ||
|
||||||
|
gogoproto.IsStdString(mapValue))
|
||||||
|
mapValueBytes := gogoproto.IsStdBytes(mapValue)
|
||||||
if mapValue.IsMessage() || p.IsGroup(mapValue) {
|
if mapValue.IsMessage() || p.IsGroup(mapValue) {
|
||||||
if nullable && valuegoTyp == valuegoAliasTyp {
|
if nullable && valuegoTyp == valuegoAliasTyp {
|
||||||
p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`)
|
p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`)
|
||||||
@@ -408,14 +459,26 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato
|
|||||||
// Equal() has a pointer receiver, but map value is a value type
|
// Equal() has a pointer receiver, but map value is a value type
|
||||||
a := `this.` + fieldname + `[i]`
|
a := `this.` + fieldname + `[i]`
|
||||||
b := `that1.` + fieldname + `[i]`
|
b := `that1.` + fieldname + `[i]`
|
||||||
if valuegoTyp != valuegoAliasTyp {
|
if !mapValueNormal && !mapValueBytes && valuegoTyp != valuegoAliasTyp {
|
||||||
// cast back to the type that has the generated methods on it
|
// cast back to the type that has the generated methods on it
|
||||||
a = `(` + valuegoTyp + `)(` + a + `)`
|
a = `(` + valuegoTyp + `)(` + a + `)`
|
||||||
b = `(` + valuegoTyp + `)(` + b + `)`
|
b = `(` + valuegoTyp + `)(` + b + `)`
|
||||||
}
|
}
|
||||||
p.P(`a := `, a)
|
p.P(`a := `, a)
|
||||||
p.P(`b := `, b)
|
p.P(`b := `, b)
|
||||||
if nullable {
|
if mapValueNormal {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if *a != *b {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if a != b {`)
|
||||||
|
}
|
||||||
|
} else if mapValueBytes {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if !`, p.bytesPkg.Use(), `.Equal(*a, *b) {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if !`, p.bytesPkg.Use(), `.Equal(a, b) {`)
|
||||||
|
}
|
||||||
|
} else if nullable {
|
||||||
p.P(`if !a.Equal(b) {`)
|
p.P(`if !a.Equal(b) {`)
|
||||||
} else {
|
} else {
|
||||||
p.P(`if !(&a).Equal(&b) {`)
|
p.P(`if !(&a).Equal(&b) {`)
|
||||||
|
|||||||
+2
-2
@@ -157,7 +157,7 @@ func (p *gostring) Generate(file *generator.FileDescriptor) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
p.atleastOne = true
|
p.atleastOne = true
|
||||||
packageName := file.PackageName()
|
packageName := file.GoPackageName()
|
||||||
|
|
||||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||||
p.P(`func (this *`, ccTypeName, `) GoString() string {`)
|
p.P(`func (this *`, ccTypeName, `) GoString() string {`)
|
||||||
@@ -225,7 +225,7 @@ func (p *gostring) Generate(file *generator.FileDescriptor) {
|
|||||||
p.P(`s = append(s, "`, fieldname, `: " + `, mapName, `+ ",\n")`)
|
p.P(`s = append(s, "`, fieldname, `: " + `, mapName, `+ ",\n")`)
|
||||||
p.Out()
|
p.Out()
|
||||||
p.P(`}`)
|
p.P(`}`)
|
||||||
} else if (field.IsMessage() && !gogoproto.IsCustomType(field) && !gogoproto.IsStdTime(field) && !gogoproto.IsStdDuration(field)) || p.IsGroup(field) {
|
} else if (field.IsMessage() && !gogoproto.IsCustomType(field) && !gogoproto.IsStdType(field)) || p.IsGroup(field) {
|
||||||
if nullable || repeated {
|
if nullable || repeated {
|
||||||
p.P(`if this.`, fieldname, ` != nil {`)
|
p.P(`if this.`, fieldname, ` != nil {`)
|
||||||
p.In()
|
p.In()
|
||||||
|
|||||||
+159
-7
@@ -313,12 +313,39 @@ func (p *marshalto) mapField(numGen NumGen, field *descriptor.FieldDescriptorPro
|
|||||||
case descriptor.FieldDescriptorProto_TYPE_SINT64:
|
case descriptor.FieldDescriptorProto_TYPE_SINT64:
|
||||||
p.callVarint(`(uint64(`, varName, `) << 1) ^ uint64((`, varName, ` >> 63))`)
|
p.callVarint(`(uint64(`, varName, `) << 1) ^ uint64((`, varName, ` >> 63))`)
|
||||||
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
|
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
|
||||||
if gogoproto.IsStdTime(field) {
|
if gogoproto.IsStdTime(kvField) {
|
||||||
p.callVarint(p.typesPkg.Use(), `.SizeOfStdTime(*`, varName, `)`)
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdTime(*`, varName, `)`)
|
||||||
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdTimeMarshalTo(*`, varName, `, dAtA[i:])`)
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdTimeMarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
} else if gogoproto.IsStdDuration(field) {
|
} else if gogoproto.IsStdDuration(kvField) {
|
||||||
p.callVarint(p.typesPkg.Use(), `.SizeOfStdDuration(*`, varName, `)`)
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdDuration(*`, varName, `)`)
|
||||||
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdDurationMarshalTo(*`, varName, `, dAtA[i:])`)
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdDurationMarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdDouble(kvField) {
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdDouble(*`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdDoubleMarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdFloat(kvField) {
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdFloat(*`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdFloatMarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdInt64(kvField) {
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt64(*`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdInt64MarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdUInt64(kvField) {
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt64(*`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdUInt64MarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdInt32(kvField) {
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt32(*`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdInt32MarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdUInt32(kvField) {
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt32(*`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdUInt32MarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdBool(kvField) {
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdBool(*`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdBoolMarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdString(kvField) {
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdString(*`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdStringMarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdBytes(kvField) {
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdBytes(*`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdBytesMarshalTo(*`, varName, `, dAtA[i:])`)
|
||||||
} else if protoSizer {
|
} else if protoSizer {
|
||||||
p.callVarint(varName, `.ProtoSize()`)
|
p.callVarint(varName, `.ProtoSize()`)
|
||||||
p.P(`n`, numGen.Next(), `, err := `, varName, `.MarshalTo(dAtA[i:])`)
|
p.P(`n`, numGen.Next(), `, err := `, varName, `.MarshalTo(dAtA[i:])`)
|
||||||
@@ -781,8 +808,7 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi
|
|||||||
sum = append(sum, `soz`+p.localName+`(uint64(v))`)
|
sum = append(sum, `soz`+p.localName+`(uint64(v))`)
|
||||||
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
|
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
|
||||||
if valuegoTyp != valuegoAliasTyp &&
|
if valuegoTyp != valuegoAliasTyp &&
|
||||||
!gogoproto.IsStdTime(field) &&
|
!gogoproto.IsStdType(m.ValueAliasField) {
|
||||||
!gogoproto.IsStdDuration(field) {
|
|
||||||
if nullable {
|
if nullable {
|
||||||
// cast back to the type that has the generated methods on it
|
// cast back to the type that has the generated methods on it
|
||||||
accessor = `((` + valuegoTyp + `)(` + accessor + `))`
|
accessor = `((` + valuegoTyp + `)(` + accessor + `))`
|
||||||
@@ -795,10 +821,28 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi
|
|||||||
p.P(`msgSize := 0`)
|
p.P(`msgSize := 0`)
|
||||||
p.P(`if `, accessor, ` != nil {`)
|
p.P(`if `, accessor, ` != nil {`)
|
||||||
p.In()
|
p.In()
|
||||||
if gogoproto.IsStdTime(field) {
|
if gogoproto.IsStdTime(m.ValueAliasField) {
|
||||||
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdTime(*`, accessor, `)`)
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdTime(*`, accessor, `)`)
|
||||||
} else if gogoproto.IsStdDuration(field) {
|
} else if gogoproto.IsStdDuration(m.ValueAliasField) {
|
||||||
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdDuration(*`, accessor, `)`)
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdDuration(*`, accessor, `)`)
|
||||||
|
} else if gogoproto.IsStdDouble(m.ValueAliasField) {
|
||||||
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdDouble(*`, accessor, `)`)
|
||||||
|
} else if gogoproto.IsStdFloat(m.ValueAliasField) {
|
||||||
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdFloat(*`, accessor, `)`)
|
||||||
|
} else if gogoproto.IsStdInt64(m.ValueAliasField) {
|
||||||
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdInt64(*`, accessor, `)`)
|
||||||
|
} else if gogoproto.IsStdUInt64(m.ValueAliasField) {
|
||||||
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdUInt64(*`, accessor, `)`)
|
||||||
|
} else if gogoproto.IsStdInt32(m.ValueAliasField) {
|
||||||
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdInt32(*`, accessor, `)`)
|
||||||
|
} else if gogoproto.IsStdUInt32(m.ValueAliasField) {
|
||||||
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdUInt32(*`, accessor, `)`)
|
||||||
|
} else if gogoproto.IsStdBool(m.ValueAliasField) {
|
||||||
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdBool(*`, accessor, `)`)
|
||||||
|
} else if gogoproto.IsStdString(m.ValueAliasField) {
|
||||||
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdString(*`, accessor, `)`)
|
||||||
|
} else if gogoproto.IsStdBytes(m.ValueAliasField) {
|
||||||
|
p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdBytes(*`, accessor, `)`)
|
||||||
} else if protoSizer {
|
} else if protoSizer {
|
||||||
p.P(`msgSize = `, accessor, `.ProtoSize()`)
|
p.P(`msgSize = `, accessor, `.ProtoSize()`)
|
||||||
} else {
|
} else {
|
||||||
@@ -828,7 +872,7 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi
|
|||||||
p.In()
|
p.In()
|
||||||
}
|
}
|
||||||
p.encodeKey(2, wireToType(valuewire))
|
p.encodeKey(2, wireToType(valuewire))
|
||||||
p.mapField(numGen, field, m.ValueField, accessor, protoSizer)
|
p.mapField(numGen, field, m.ValueAliasField, accessor, protoSizer)
|
||||||
if nullableMsg || plainBytes {
|
if nullableMsg || plainBytes {
|
||||||
p.Out()
|
p.Out()
|
||||||
p.P(`}`)
|
p.P(`}`)
|
||||||
@@ -852,6 +896,60 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi
|
|||||||
}
|
}
|
||||||
p.callVarint(p.typesPkg.Use(), `.SizeOfStdDuration(`, varName, `)`)
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdDuration(`, varName, `)`)
|
||||||
p.P(`n, err := `, p.typesPkg.Use(), `.StdDurationMarshalTo(`, varName, `, dAtA[i:])`)
|
p.P(`n, err := `, p.typesPkg.Use(), `.StdDurationMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdDouble(`, varName, `)`)
|
||||||
|
p.P(`n, err := `, p.typesPkg.Use(), `.StdDoubleMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdFloat(`, varName, `)`)
|
||||||
|
p.P(`n, err := `, p.typesPkg.Use(), `.StdFloatMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt64(`, varName, `)`)
|
||||||
|
p.P(`n, err := `, p.typesPkg.Use(), `.StdInt64MarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt64(`, varName, `)`)
|
||||||
|
p.P(`n, err := `, p.typesPkg.Use(), `.StdUInt64MarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt32(`, varName, `)`)
|
||||||
|
p.P(`n, err := `, p.typesPkg.Use(), `.StdInt32MarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt32(`, varName, `)`)
|
||||||
|
p.P(`n, err := `, p.typesPkg.Use(), `.StdUInt32MarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdBool(`, varName, `)`)
|
||||||
|
p.P(`n, err := `, p.typesPkg.Use(), `.StdBoolMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdString(`, varName, `)`)
|
||||||
|
p.P(`n, err := `, p.typesPkg.Use(), `.StdStringMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdBytes(`, varName, `)`)
|
||||||
|
p.P(`n, err := `, p.typesPkg.Use(), `.StdBytesMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
} else if protoSizer {
|
} else if protoSizer {
|
||||||
p.callVarint(varName, ".ProtoSize()")
|
p.callVarint(varName, ".ProtoSize()")
|
||||||
p.P(`n, err := `, varName, `.MarshalTo(dAtA[i:])`)
|
p.P(`n, err := `, varName, `.MarshalTo(dAtA[i:])`)
|
||||||
@@ -882,6 +980,60 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi
|
|||||||
}
|
}
|
||||||
p.callVarint(p.typesPkg.Use(), `.SizeOfStdDuration(`, varName, `)`)
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdDuration(`, varName, `)`)
|
||||||
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdDurationMarshalTo(`, varName, `, dAtA[i:])`)
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdDurationMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdDouble(`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdDoubleMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdFloat(`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdFloatMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt64(`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdInt64MarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt64(`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdUInt64MarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt32(`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdInt32MarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt32(`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdUInt32MarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdBool(`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdBoolMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdString(`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdStringMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
varName = "*" + varName
|
||||||
|
}
|
||||||
|
p.callVarint(p.typesPkg.Use(), `.SizeOfStdBytes(`, varName, `)`)
|
||||||
|
p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdBytesMarshalTo(`, varName, `, dAtA[i:])`)
|
||||||
} else if protoSizer {
|
} else if protoSizer {
|
||||||
p.callVarint(varName, `.ProtoSize()`)
|
p.callVarint(varName, `.ProtoSize()`)
|
||||||
p.P(`n`, numGen.Next(), `, err := `, varName, `.MarshalTo(dAtA[i:])`)
|
p.P(`n`, numGen.Next(), `, err := `, varName, `.MarshalTo(dAtA[i:])`)
|
||||||
|
|||||||
+33
-13
@@ -182,7 +182,7 @@ func negative(fieldType descriptor.FieldDescriptorProto_Type) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *plugin) getFuncName(goTypName string) string {
|
func (p *plugin) getFuncName(goTypName string, field *descriptor.FieldDescriptorProto) string {
|
||||||
funcName := "NewPopulated" + goTypName
|
funcName := "NewPopulated" + goTypName
|
||||||
goTypNames := strings.Split(goTypName, ".")
|
goTypNames := strings.Split(goTypName, ".")
|
||||||
if len(goTypNames) == 2 {
|
if len(goTypNames) == 2 {
|
||||||
@@ -190,23 +190,43 @@ func (p *plugin) getFuncName(goTypName string) string {
|
|||||||
} else if len(goTypNames) != 1 {
|
} else if len(goTypNames) != 1 {
|
||||||
panic(fmt.Errorf("unreachable: too many dots in %v", goTypName))
|
panic(fmt.Errorf("unreachable: too many dots in %v", goTypName))
|
||||||
}
|
}
|
||||||
switch funcName {
|
if field != nil {
|
||||||
case "time.NewPopulatedTime":
|
switch {
|
||||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdTime"
|
case gogoproto.IsStdTime(field):
|
||||||
case "time.NewPopulatedDuration":
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdTime"
|
||||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdDuration"
|
case gogoproto.IsStdDuration(field):
|
||||||
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdDuration"
|
||||||
|
case gogoproto.IsStdDouble(field):
|
||||||
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdDouble"
|
||||||
|
case gogoproto.IsStdFloat(field):
|
||||||
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdFloat"
|
||||||
|
case gogoproto.IsStdInt64(field):
|
||||||
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdInt64"
|
||||||
|
case gogoproto.IsStdUInt64(field):
|
||||||
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdUInt64"
|
||||||
|
case gogoproto.IsStdInt32(field):
|
||||||
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdInt32"
|
||||||
|
case gogoproto.IsStdUInt32(field):
|
||||||
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdUInt32"
|
||||||
|
case gogoproto.IsStdBool(field):
|
||||||
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdBool"
|
||||||
|
case gogoproto.IsStdString(field):
|
||||||
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdString"
|
||||||
|
case gogoproto.IsStdBytes(field):
|
||||||
|
funcName = p.typesPkg.Use() + ".NewPopulatedStdBytes"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return funcName
|
return funcName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *plugin) getFuncCall(goTypName string) string {
|
func (p *plugin) getFuncCall(goTypName string, field *descriptor.FieldDescriptorProto) string {
|
||||||
funcName := p.getFuncName(goTypName)
|
funcName := p.getFuncName(goTypName, field)
|
||||||
funcCall := funcName + "(r, easy)"
|
funcCall := funcName + "(r, easy)"
|
||||||
return funcCall
|
return funcCall
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *plugin) getCustomFuncCall(goTypName string) string {
|
func (p *plugin) getCustomFuncCall(goTypName string) string {
|
||||||
funcName := p.getFuncName(goTypName)
|
funcName := p.getFuncName(goTypName, nil)
|
||||||
funcCall := funcName + "(r)"
|
funcCall := funcName + "(r)"
|
||||||
return funcCall
|
return funcCall
|
||||||
}
|
}
|
||||||
@@ -259,13 +279,13 @@ func (p *plugin) GenerateField(file *generator.FileDescriptor, message *generato
|
|||||||
if m.ValueField.IsMessage() || p.IsGroup(field) ||
|
if m.ValueField.IsMessage() || p.IsGroup(field) ||
|
||||||
(m.ValueField.IsBytes() && gogoproto.IsCustomType(field)) {
|
(m.ValueField.IsBytes() && gogoproto.IsCustomType(field)) {
|
||||||
s := `this.` + fieldname + `[` + keyval + `] = `
|
s := `this.` + fieldname + `[` + keyval + `] = `
|
||||||
if gogoproto.IsStdTime(field) || gogoproto.IsStdDuration(field) {
|
if gogoproto.IsStdType(field) {
|
||||||
valuegoTyp = valuegoAliasTyp
|
valuegoTyp = valuegoAliasTyp
|
||||||
}
|
}
|
||||||
funcCall := p.getCustomFuncCall(goTypName)
|
funcCall := p.getCustomFuncCall(goTypName)
|
||||||
if !gogoproto.IsCustomType(field) {
|
if !gogoproto.IsCustomType(field) {
|
||||||
goTypName = generator.GoTypeToName(valuegoTyp)
|
goTypName = generator.GoTypeToName(valuegoTyp)
|
||||||
funcCall = p.getFuncCall(goTypName)
|
funcCall = p.getFuncCall(goTypName, m.ValueAliasField)
|
||||||
}
|
}
|
||||||
if !nullable {
|
if !nullable {
|
||||||
funcCall = `*` + funcCall
|
funcCall = `*` + funcCall
|
||||||
@@ -322,7 +342,7 @@ func (p *plugin) GenerateField(file *generator.FileDescriptor, message *generato
|
|||||||
p.P(`this.`, fieldname, ` = *`, p.varGen.Current())
|
p.P(`this.`, fieldname, ` = *`, p.varGen.Current())
|
||||||
}
|
}
|
||||||
} else if field.IsMessage() || p.IsGroup(field) {
|
} else if field.IsMessage() || p.IsGroup(field) {
|
||||||
funcCall := p.getFuncCall(goTypName)
|
funcCall := p.getFuncCall(goTypName, field)
|
||||||
if field.IsRepeated() {
|
if field.IsRepeated() {
|
||||||
p.P(p.varGen.Next(), ` := r.Intn(5)`)
|
p.P(p.varGen.Next(), ` := r.Intn(5)`)
|
||||||
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
||||||
@@ -534,7 +554,7 @@ func (p *plugin) Generate(file *generator.FileDescriptor) {
|
|||||||
p.P(`func NewPopulated`, ccTypeName, `(r randy`, p.localName, `, easy bool) *`, ccTypeName, ` {`)
|
p.P(`func NewPopulated`, ccTypeName, `(r randy`, p.localName, `, easy bool) *`, ccTypeName, ` {`)
|
||||||
p.In()
|
p.In()
|
||||||
p.P(`this := &`, ccTypeName, `{}`)
|
p.P(`this := &`, ccTypeName, `{}`)
|
||||||
if gogoproto.IsUnion(message.File(), message.DescriptorProto) && len(message.Field) > 0 {
|
if gogoproto.IsUnion(message.File().FileDescriptorProto, message.DescriptorProto) && len(message.Field) > 0 {
|
||||||
p.P(`fieldNum := r.Intn(`, fmt.Sprintf("%d", ranTotal), `)`)
|
p.P(`fieldNum := r.Intn(`, fmt.Sprintf("%d", ranTotal), `)`)
|
||||||
p.P(`switch fieldNum {`)
|
p.P(`switch fieldNum {`)
|
||||||
k := 0
|
k := 0
|
||||||
|
|||||||
+38
-11
@@ -69,6 +69,9 @@ The following message:
|
|||||||
given to the size plugin, will generate the following code:
|
given to the size plugin, will generate the following code:
|
||||||
|
|
||||||
func (m *B) Size() (n int) {
|
func (m *B) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
l = m.A.Size()
|
l = m.A.Size()
|
||||||
@@ -203,18 +206,32 @@ func (p *size) sizeZigZag() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *size) std(field *descriptor.FieldDescriptorProto, name string) (string, bool) {
|
func (p *size) std(field *descriptor.FieldDescriptorProto, name string) (string, bool) {
|
||||||
|
ptr := ""
|
||||||
|
if gogoproto.IsNullable(field) {
|
||||||
|
ptr = "*"
|
||||||
|
}
|
||||||
if gogoproto.IsStdTime(field) {
|
if gogoproto.IsStdTime(field) {
|
||||||
if gogoproto.IsNullable(field) {
|
return p.typesPkg.Use() + `.SizeOfStdTime(` + ptr + name + `)`, true
|
||||||
return p.typesPkg.Use() + `.SizeOfStdTime(*` + name + `)`, true
|
|
||||||
} else {
|
|
||||||
return p.typesPkg.Use() + `.SizeOfStdTime(` + name + `)`, true
|
|
||||||
}
|
|
||||||
} else if gogoproto.IsStdDuration(field) {
|
} else if gogoproto.IsStdDuration(field) {
|
||||||
if gogoproto.IsNullable(field) {
|
return p.typesPkg.Use() + `.SizeOfStdDuration(` + ptr + name + `)`, true
|
||||||
return p.typesPkg.Use() + `.SizeOfStdDuration(*` + name + `)`, true
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
} else {
|
return p.typesPkg.Use() + `.SizeOfStdDouble(` + ptr + name + `)`, true
|
||||||
return p.typesPkg.Use() + `.SizeOfStdDuration(` + name + `)`, true
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
}
|
return p.typesPkg.Use() + `.SizeOfStdFloat(` + ptr + name + `)`, true
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
return p.typesPkg.Use() + `.SizeOfStdInt64(` + ptr + name + `)`, true
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
return p.typesPkg.Use() + `.SizeOfStdUInt64(` + ptr + name + `)`, true
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
return p.typesPkg.Use() + `.SizeOfStdInt32(` + ptr + name + `)`, true
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
return p.typesPkg.Use() + `.SizeOfStdUInt32(` + ptr + name + `)`, true
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
return p.typesPkg.Use() + `.SizeOfStdBool(` + ptr + name + `)`, true
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
return p.typesPkg.Use() + `.SizeOfStdString(` + ptr + name + `)`, true
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
return p.typesPkg.Use() + `.SizeOfStdBytes(` + ptr + name + `)`, true
|
||||||
}
|
}
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
@@ -444,7 +461,7 @@ func (p *size) generateField(proto3 bool, file *generator.FileDescriptor, messag
|
|||||||
sum = append(sum, strconv.Itoa(valueKeySize))
|
sum = append(sum, strconv.Itoa(valueKeySize))
|
||||||
sum = append(sum, `soz`+p.localName+`(uint64(v))`)
|
sum = append(sum, `soz`+p.localName+`(uint64(v))`)
|
||||||
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
|
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
|
||||||
stdSizeCall, stdOk := p.std(field, "v")
|
stdSizeCall, stdOk := p.std(m.ValueAliasField, "v")
|
||||||
if nullable {
|
if nullable {
|
||||||
p.P(`l = 0`)
|
p.P(`l = 0`)
|
||||||
p.P(`if v != nil {`)
|
p.P(`if v != nil {`)
|
||||||
@@ -595,6 +612,11 @@ func (p *size) Generate(file *generator.FileDescriptor) {
|
|||||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||||
p.P(`func (m *`, ccTypeName, `) `, sizeName, `() (n int) {`)
|
p.P(`func (m *`, ccTypeName, `) `, sizeName, `() (n int) {`)
|
||||||
p.In()
|
p.In()
|
||||||
|
p.P(`if m == nil {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`return 0`)
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
p.P(`var l int`)
|
p.P(`var l int`)
|
||||||
p.P(`_ = l`)
|
p.P(`_ = l`)
|
||||||
oneofs := make(map[string]struct{})
|
oneofs := make(map[string]struct{})
|
||||||
@@ -650,6 +672,11 @@ func (p *size) Generate(file *generator.FileDescriptor) {
|
|||||||
ccTypeName := p.OneOfTypeName(message, f)
|
ccTypeName := p.OneOfTypeName(message, f)
|
||||||
p.P(`func (m *`, ccTypeName, `) `, sizeName, `() (n int) {`)
|
p.P(`func (m *`, ccTypeName, `) `, sizeName, `() (n int) {`)
|
||||||
p.In()
|
p.In()
|
||||||
|
p.P(`if m == nil {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`return 0`)
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
p.P(`var l int`)
|
p.P(`var l int`)
|
||||||
p.P(`_ = l`)
|
p.P(`_ = l`)
|
||||||
vanity.TurnOffNullableForNativeTypes(f)
|
vanity.TurnOffNullableForNativeTypes(f)
|
||||||
|
|||||||
+1
-1
@@ -184,7 +184,7 @@ func (p *union) Generate(file *generator.FileDescriptor) {
|
|||||||
goTyp, _ := p.GoType(message, field)
|
goTyp, _ := p.GoType(message, field)
|
||||||
obj := p.ObjectNamed(field.GetTypeName()).(*generator.Descriptor)
|
obj := p.ObjectNamed(field.GetTypeName()).(*generator.Descriptor)
|
||||||
|
|
||||||
if gogoproto.IsUnion(obj.File(), obj.DescriptorProto) {
|
if gogoproto.IsUnion(obj.File().FileDescriptorProto, obj.DescriptorProto) {
|
||||||
p.P(`this.`, fieldname, ` = new(`, generator.GoTypeToName(goTyp), `)`)
|
p.P(`this.`, fieldname, ` = new(`, generator.GoTypeToName(goTyp), `)`)
|
||||||
p.P(`if set := this.`, fieldname, `.SetValue(value); set {`)
|
p.P(`if set := this.`, fieldname, `.SetValue(value); set {`)
|
||||||
p.In()
|
p.In()
|
||||||
|
|||||||
+301
-3
@@ -280,6 +280,24 @@ func (p *unmarshal) declareMapField(varName string, nullable bool, customType bo
|
|||||||
p.P(varName, ` := new(time.Time)`)
|
p.P(varName, ` := new(time.Time)`)
|
||||||
} else if gogoproto.IsStdDuration(field) {
|
} else if gogoproto.IsStdDuration(field) {
|
||||||
p.P(varName, ` := new(time.Duration)`)
|
p.P(varName, ` := new(time.Duration)`)
|
||||||
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
|
p.P(varName, ` := new(float64)`)
|
||||||
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
|
p.P(varName, ` := new(float32)`)
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
p.P(varName, ` := new(int64)`)
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
p.P(varName, ` := new(uint64)`)
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
p.P(varName, ` := new(int32)`)
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
p.P(varName, ` := new(uint32)`)
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
p.P(varName, ` := new(bool)`)
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
p.P(varName, ` := new(string)`)
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
p.P(varName, ` := new([]byte)`)
|
||||||
} else {
|
} else {
|
||||||
desc := p.ObjectNamed(field.GetTypeName())
|
desc := p.ObjectNamed(field.GetTypeName())
|
||||||
msgname := p.TypeName(desc)
|
msgname := p.TypeName(desc)
|
||||||
@@ -383,6 +401,24 @@ func (p *unmarshal) mapField(varName string, customType bool, field *descriptor.
|
|||||||
p.P(`if err := `, p.typesPkg.Use(), `.StdTimeUnmarshal(`, varName, `, `, buf, `); err != nil {`)
|
p.P(`if err := `, p.typesPkg.Use(), `.StdTimeUnmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
} else if gogoproto.IsStdDuration(field) {
|
} else if gogoproto.IsStdDuration(field) {
|
||||||
p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(`, varName, `, `, buf, `); err != nil {`)
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(`, varName, `, `, buf, `); err != nil {`)
|
||||||
} else {
|
} else {
|
||||||
desc := p.ObjectNamed(field.GetTypeName())
|
desc := p.ObjectNamed(field.GetTypeName())
|
||||||
msgname := p.TypeName(desc)
|
msgname := p.TypeName(desc)
|
||||||
@@ -648,6 +684,78 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
|
|||||||
p.P(`v := time.Duration(0)`)
|
p.P(`v := time.Duration(0)`)
|
||||||
p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(&v, `, buf, `); err != nil {`)
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(&v, `, buf, `); err != nil {`)
|
||||||
}
|
}
|
||||||
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`v := new(float64)`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(v, `, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`v := 0`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(&v, `, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`v := new(float32)`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(v, `, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`v := 0`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(&v, `, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`v := new(int64)`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(v, `, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`v := 0`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(&v, `, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`v := new(uint64)`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(v, `, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`v := 0`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(&v, `, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`v := new(int32)`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(v, `, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`v := 0`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(&v, `, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`v := new(uint32)`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(v, `, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`v := 0`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(&v, `, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`v := new(bool)`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(v, `, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`v := false`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(&v, `, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`v := new(string)`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(v, `, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`v := ""`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(&v, `, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`v := new([]byte)`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(v, `, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`var v []byte`)
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(&v, `, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p.P(`v := &`, msgname, `{}`)
|
p.P(`v := &`, msgname, `{}`)
|
||||||
p.P(`if err := v.Unmarshal(`, buf, `); err != nil {`)
|
p.P(`if err := v.Unmarshal(`, buf, `); err != nil {`)
|
||||||
@@ -679,7 +787,7 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
|
|||||||
}
|
}
|
||||||
|
|
||||||
nullable, valuegoTyp, valuegoAliasTyp = generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp)
|
nullable, valuegoTyp, valuegoAliasTyp = generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp)
|
||||||
if gogoproto.IsStdTime(field) || gogoproto.IsStdDuration(field) {
|
if gogoproto.IsStdType(field) {
|
||||||
valuegoTyp = valuegoAliasTyp
|
valuegoTyp = valuegoAliasTyp
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,6 +870,60 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
|
|||||||
} else {
|
} else {
|
||||||
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, time.Duration(0))`)
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, time.Duration(0))`)
|
||||||
}
|
}
|
||||||
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(float64))`)
|
||||||
|
} else {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(float32))`)
|
||||||
|
} else {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(int64))`)
|
||||||
|
} else {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(uint64))`)
|
||||||
|
} else {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(int32))`)
|
||||||
|
} else {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(uint32))`)
|
||||||
|
} else {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(bool))`)
|
||||||
|
} else {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, false)`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(string))`)
|
||||||
|
} else {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, "")`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new([]byte))`)
|
||||||
|
} else {
|
||||||
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, []byte{})`)
|
||||||
|
}
|
||||||
} else if nullable && !gogoproto.IsCustomType(field) {
|
} else if nullable && !gogoproto.IsCustomType(field) {
|
||||||
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, &`, msgname, `{})`)
|
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, &`, msgname, `{})`)
|
||||||
} else {
|
} else {
|
||||||
@@ -784,6 +946,60 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
|
|||||||
} else {
|
} else {
|
||||||
p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
||||||
}
|
}
|
||||||
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(`, varName, `,`, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(`, varName, `,`, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(`, varName, `,`, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(`, varName, `,`, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(`, varName, `,`, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(`, varName, `,`, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(`, varName, `,`, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(`, varName, `,`, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
if nullable {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(`, varName, `,`, buf, `); err != nil {`)
|
||||||
|
} else {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(&(`, varName, `),`, buf, `); err != nil {`)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p.P(`if err := `, varName, `.Unmarshal(`, buf, `); err != nil {`)
|
p.P(`if err := `, varName, `.Unmarshal(`, buf, `); err != nil {`)
|
||||||
}
|
}
|
||||||
@@ -798,6 +1014,24 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
|
|||||||
p.P(`m.`, fieldname, ` = new(time.Time)`)
|
p.P(`m.`, fieldname, ` = new(time.Time)`)
|
||||||
} else if gogoproto.IsStdDuration(field) {
|
} else if gogoproto.IsStdDuration(field) {
|
||||||
p.P(`m.`, fieldname, ` = new(time.Duration)`)
|
p.P(`m.`, fieldname, ` = new(time.Duration)`)
|
||||||
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
|
p.P(`m.`, fieldname, ` = new(float64)`)
|
||||||
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
|
p.P(`m.`, fieldname, ` = new(float32)`)
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
p.P(`m.`, fieldname, ` = new(int64)`)
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
p.P(`m.`, fieldname, ` = new(uint64)`)
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
p.P(`m.`, fieldname, ` = new(int32)`)
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
p.P(`m.`, fieldname, ` = new(uint32)`)
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
p.P(`m.`, fieldname, ` = new(bool)`)
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
p.P(`m.`, fieldname, ` = new(string)`)
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
p.P(`m.`, fieldname, ` = new([]byte)`)
|
||||||
} else {
|
} else {
|
||||||
goType, _ := p.GoType(nil, field)
|
goType, _ := p.GoType(nil, field)
|
||||||
// remove the star from the type
|
// remove the star from the type
|
||||||
@@ -809,6 +1043,24 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
|
|||||||
p.P(`if err := `, p.typesPkg.Use(), `.StdTimeUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
p.P(`if err := `, p.typesPkg.Use(), `.StdTimeUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
} else if gogoproto.IsStdDuration(field) {
|
} else if gogoproto.IsStdDuration(field) {
|
||||||
p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
} else {
|
} else {
|
||||||
p.P(`if err := m.`, fieldname, `.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {`)
|
p.P(`if err := m.`, fieldname, `.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
}
|
}
|
||||||
@@ -821,6 +1073,24 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
|
|||||||
p.P(`if err := `, p.typesPkg.Use(), `.StdTimeUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
p.P(`if err := `, p.typesPkg.Use(), `.StdTimeUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
} else if gogoproto.IsStdDuration(field) {
|
} else if gogoproto.IsStdDuration(field) {
|
||||||
p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdDouble(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdFloat(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdInt64(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdUInt64(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdInt32(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdUInt32(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdBool(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdString(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
|
} else if gogoproto.IsStdBytes(field) {
|
||||||
|
p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
} else {
|
} else {
|
||||||
p.P(`if err := m.`, fieldname, `.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {`)
|
p.P(`if err := m.`, fieldname, `.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {`)
|
||||||
}
|
}
|
||||||
@@ -1099,6 +1369,34 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) {
|
|||||||
p.P(`return `, p.ioPkg.Use(), `.ErrUnexpectedEOF`)
|
p.P(`return `, p.ioPkg.Use(), `.ErrUnexpectedEOF`)
|
||||||
p.Out()
|
p.Out()
|
||||||
p.P(`}`)
|
p.P(`}`)
|
||||||
|
|
||||||
|
p.P(`var elementCount int`)
|
||||||
|
switch *field.Type {
|
||||||
|
case descriptor.FieldDescriptorProto_TYPE_DOUBLE, descriptor.FieldDescriptorProto_TYPE_FIXED64, descriptor.FieldDescriptorProto_TYPE_SFIXED64:
|
||||||
|
p.P(`elementCount = packedLen/`, 8)
|
||||||
|
case descriptor.FieldDescriptorProto_TYPE_FLOAT, descriptor.FieldDescriptorProto_TYPE_FIXED32, descriptor.FieldDescriptorProto_TYPE_SFIXED32:
|
||||||
|
p.P(`elementCount = packedLen/`, 4)
|
||||||
|
case descriptor.FieldDescriptorProto_TYPE_INT64, descriptor.FieldDescriptorProto_TYPE_UINT64, descriptor.FieldDescriptorProto_TYPE_INT32, descriptor.FieldDescriptorProto_TYPE_UINT32, descriptor.FieldDescriptorProto_TYPE_SINT32, descriptor.FieldDescriptorProto_TYPE_SINT64:
|
||||||
|
p.P(`var count int`)
|
||||||
|
p.P(`for _, integer := range dAtA {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`if integer < 128 {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`count++`)
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
|
p.P(`elementCount = count`)
|
||||||
|
case descriptor.FieldDescriptorProto_TYPE_BOOL:
|
||||||
|
p.P(`elementCount = packedLen`)
|
||||||
|
}
|
||||||
|
p.P(`if elementCount != 0 && len(m.`, fieldname, `) == 0 {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`m.`, fieldname, ` = make([]`, p.noStarOrSliceType(message, field), `, 0, elementCount)`)
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
|
|
||||||
p.P(`for iNdEx < postIndex {`)
|
p.P(`for iNdEx < postIndex {`)
|
||||||
p.In()
|
p.In()
|
||||||
p.field(file, message, field, fieldname, false)
|
p.field(file, message, field, fieldname, false)
|
||||||
@@ -1124,7 +1422,7 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
panic("field is required, but no bit registered")
|
panic("field is required, but no bit registered")
|
||||||
}
|
}
|
||||||
p.P(`hasFields[`, strconv.Itoa(int(fieldBit/64)), `] |= uint64(`, fmt.Sprintf("0x%08x", 1<<(fieldBit%64)), `)`)
|
p.P(`hasFields[`, strconv.Itoa(int(fieldBit/64)), `] |= uint64(`, fmt.Sprintf("0x%08x", uint64(1)<<(fieldBit%64)), `)`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.Out()
|
p.Out()
|
||||||
@@ -1213,7 +1511,7 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) {
|
|||||||
panic("field is required, but no bit registered")
|
panic("field is required, but no bit registered")
|
||||||
}
|
}
|
||||||
|
|
||||||
p.P(`if hasFields[`, strconv.Itoa(int(fieldBit/64)), `] & uint64(`, fmt.Sprintf("0x%08x", 1<<(fieldBit%64)), `) == 0 {`)
|
p.P(`if hasFields[`, strconv.Itoa(int(fieldBit/64)), `] & uint64(`, fmt.Sprintf("0x%08x", uint64(1)<<(fieldBit%64)), `) == 0 {`)
|
||||||
p.In()
|
p.In()
|
||||||
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
||||||
p.P(`return new(`, protoPkg.Use(), `.RequiredNotSetError)`)
|
p.P(`return new(`, protoPkg.Use(), `.RequiredNotSetError)`)
|
||||||
|
|||||||
+2
-2
@@ -38,6 +38,6 @@ test: install generate-test-pbs
|
|||||||
|
|
||||||
generate-test-pbs:
|
generate-test-pbs:
|
||||||
make install
|
make install
|
||||||
make -C testdata
|
make -C test_proto
|
||||||
protoc-min-version --version="3.0.0" --proto_path=.:../../../../:../protobuf --gogo_out=Mtestdata/test.proto=github.com/gogo/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. proto3_proto/proto3.proto
|
make -C proto3_proto
|
||||||
make
|
make
|
||||||
|
|||||||
+35
-11
@@ -35,22 +35,39 @@
|
|||||||
package proto
|
package proto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Clone returns a deep copy of a protocol buffer.
|
// Clone returns a deep copy of a protocol buffer.
|
||||||
func Clone(pb Message) Message {
|
func Clone(src Message) Message {
|
||||||
in := reflect.ValueOf(pb)
|
in := reflect.ValueOf(src)
|
||||||
if in.IsNil() {
|
if in.IsNil() {
|
||||||
return pb
|
return src
|
||||||
}
|
}
|
||||||
|
|
||||||
out := reflect.New(in.Type().Elem())
|
out := reflect.New(in.Type().Elem())
|
||||||
// out is empty so a merge is a deep copy.
|
dst := out.Interface().(Message)
|
||||||
mergeStruct(out.Elem(), in.Elem())
|
Merge(dst, src)
|
||||||
return out.Interface().(Message)
|
return dst
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merger is the interface representing objects that can merge messages of the same type.
|
||||||
|
type Merger interface {
|
||||||
|
// Merge merges src into this message.
|
||||||
|
// Required and optional fields that are set in src will be set to that value in dst.
|
||||||
|
// Elements of repeated fields will be appended.
|
||||||
|
//
|
||||||
|
// Merge may panic if called with a different argument type than the receiver.
|
||||||
|
Merge(src Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
// generatedMerger is the custom merge method that generated protos will have.
|
||||||
|
// We must add this method since a generate Merge method will conflict with
|
||||||
|
// many existing protos that have a Merge data field already defined.
|
||||||
|
type generatedMerger interface {
|
||||||
|
XXX_Merge(src Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge merges src into dst.
|
// Merge merges src into dst.
|
||||||
@@ -58,17 +75,24 @@ func Clone(pb Message) Message {
|
|||||||
// Elements of repeated fields will be appended.
|
// Elements of repeated fields will be appended.
|
||||||
// Merge panics if src and dst are not the same type, or if dst is nil.
|
// Merge panics if src and dst are not the same type, or if dst is nil.
|
||||||
func Merge(dst, src Message) {
|
func Merge(dst, src Message) {
|
||||||
|
if m, ok := dst.(Merger); ok {
|
||||||
|
m.Merge(src)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
in := reflect.ValueOf(src)
|
in := reflect.ValueOf(src)
|
||||||
out := reflect.ValueOf(dst)
|
out := reflect.ValueOf(dst)
|
||||||
if out.IsNil() {
|
if out.IsNil() {
|
||||||
panic("proto: nil destination")
|
panic("proto: nil destination")
|
||||||
}
|
}
|
||||||
if in.Type() != out.Type() {
|
if in.Type() != out.Type() {
|
||||||
// Explicit test prior to mergeStruct so that mistyped nils will fail
|
panic(fmt.Sprintf("proto.Merge(%T, %T) type mismatch", dst, src))
|
||||||
panic("proto: type mismatch")
|
|
||||||
}
|
}
|
||||||
if in.IsNil() {
|
if in.IsNil() {
|
||||||
// Merging nil into non-nil is a quiet no-op
|
return // Merge from nil src is a noop
|
||||||
|
}
|
||||||
|
if m, ok := dst.(generatedMerger); ok {
|
||||||
|
m.XXX_Merge(src)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mergeStruct(out.Elem(), in.Elem())
|
mergeStruct(out.Elem(), in.Elem())
|
||||||
@@ -89,7 +113,7 @@ func mergeStruct(out, in reflect.Value) {
|
|||||||
bIn := emIn.GetExtensions()
|
bIn := emIn.GetExtensions()
|
||||||
bOut := emOut.GetExtensions()
|
bOut := emOut.GetExtensions()
|
||||||
*bOut = append(*bOut, *bIn...)
|
*bOut = append(*bOut, *bIn...)
|
||||||
} else if emIn, ok := extendable(in.Addr().Interface()); ok {
|
} else if emIn, err := extendable(in.Addr().Interface()); err == nil {
|
||||||
emOut, _ := extendable(out.Addr().Interface())
|
emOut, _ := extendable(out.Addr().Interface())
|
||||||
mIn, muIn := emIn.extensionsRead()
|
mIn, muIn := emIn.extensionsRead()
|
||||||
if mIn != nil {
|
if mIn != nil {
|
||||||
|
|||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
// Protocol Buffers for Go with Gadgets
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
|
||||||
|
// http://github.com/gogo/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
package proto
|
||||||
|
|
||||||
|
import "reflect"
|
||||||
|
|
||||||
|
type custom interface {
|
||||||
|
Marshal() ([]byte, error)
|
||||||
|
Unmarshal(data []byte) error
|
||||||
|
Size() int
|
||||||
|
}
|
||||||
|
|
||||||
|
var customType = reflect.TypeOf((*custom)(nil)).Elem()
|
||||||
+63
-613
@@ -39,8 +39,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// errOverflow is returned when an integer is too large to be represented.
|
// errOverflow is returned when an integer is too large to be represented.
|
||||||
@@ -50,10 +48,6 @@ var errOverflow = errors.New("proto: integer overflow")
|
|||||||
// wire type is encountered. It does not get returned to user code.
|
// wire type is encountered. It does not get returned to user code.
|
||||||
var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof")
|
var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof")
|
||||||
|
|
||||||
// The fundamental decoders that interpret bytes on the wire.
|
|
||||||
// Those that take integer types all return uint64 and are
|
|
||||||
// therefore of type valueDecoder.
|
|
||||||
|
|
||||||
// DecodeVarint reads a varint-encoded integer from the slice.
|
// DecodeVarint reads a varint-encoded integer from the slice.
|
||||||
// It returns the integer and the number of bytes consumed, or
|
// It returns the integer and the number of bytes consumed, or
|
||||||
// zero if there is not enough.
|
// zero if there is not enough.
|
||||||
@@ -267,9 +261,6 @@ func (p *Buffer) DecodeZigzag32() (x uint64, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are not ValueDecoders: they produce an array of bytes or a string.
|
|
||||||
// bytes, embedded messages
|
|
||||||
|
|
||||||
// DecodeRawBytes reads a count-delimited byte buffer from the Buffer.
|
// DecodeRawBytes reads a count-delimited byte buffer from the Buffer.
|
||||||
// This is the format used for the bytes protocol buffer
|
// This is the format used for the bytes protocol buffer
|
||||||
// type and for embedded messages.
|
// type and for embedded messages.
|
||||||
@@ -311,81 +302,29 @@ func (p *Buffer) DecodeStringBytes() (s string, err error) {
|
|||||||
return string(buf), nil
|
return string(buf), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip the next item in the buffer. Its wire type is decoded and presented as an argument.
|
|
||||||
// If the protocol buffer has extensions, and the field matches, add it as an extension.
|
|
||||||
// Otherwise, if the XXX_unrecognized field exists, append the skipped data there.
|
|
||||||
func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error {
|
|
||||||
oi := o.index
|
|
||||||
|
|
||||||
err := o.skip(t, tag, wire)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !unrecField.IsValid() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr := structPointer_Bytes(base, unrecField)
|
|
||||||
|
|
||||||
// Add the skipped field to struct field
|
|
||||||
obuf := o.buf
|
|
||||||
|
|
||||||
o.buf = *ptr
|
|
||||||
o.EncodeVarint(uint64(tag<<3 | wire))
|
|
||||||
*ptr = append(o.buf, obuf[oi:o.index]...)
|
|
||||||
|
|
||||||
o.buf = obuf
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip the next item in the buffer. Its wire type is decoded and presented as an argument.
|
|
||||||
func (o *Buffer) skip(t reflect.Type, tag, wire int) error {
|
|
||||||
|
|
||||||
var u uint64
|
|
||||||
var err error
|
|
||||||
|
|
||||||
switch wire {
|
|
||||||
case WireVarint:
|
|
||||||
_, err = o.DecodeVarint()
|
|
||||||
case WireFixed64:
|
|
||||||
_, err = o.DecodeFixed64()
|
|
||||||
case WireBytes:
|
|
||||||
_, err = o.DecodeRawBytes(false)
|
|
||||||
case WireFixed32:
|
|
||||||
_, err = o.DecodeFixed32()
|
|
||||||
case WireStartGroup:
|
|
||||||
for {
|
|
||||||
u, err = o.DecodeVarint()
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
fwire := int(u & 0x7)
|
|
||||||
if fwire == WireEndGroup {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
ftag := int(u >> 3)
|
|
||||||
err = o.skip(t, ftag, fwire)
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshaler is the interface representing objects that can
|
// Unmarshaler is the interface representing objects that can
|
||||||
// unmarshal themselves. The method should reset the receiver before
|
// unmarshal themselves. The argument points to data that may be
|
||||||
// decoding starts. The argument points to data that may be
|
|
||||||
// overwritten, so implementations should not keep references to the
|
// overwritten, so implementations should not keep references to the
|
||||||
// buffer.
|
// buffer.
|
||||||
|
// Unmarshal implementations should not clear the receiver.
|
||||||
|
// Any unmarshaled data should be merged into the receiver.
|
||||||
|
// Callers of Unmarshal that do not want to retain existing data
|
||||||
|
// should Reset the receiver before calling Unmarshal.
|
||||||
type Unmarshaler interface {
|
type Unmarshaler interface {
|
||||||
Unmarshal([]byte) error
|
Unmarshal([]byte) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newUnmarshaler is the interface representing objects that can
|
||||||
|
// unmarshal themselves. The semantics are identical to Unmarshaler.
|
||||||
|
//
|
||||||
|
// This exists to support protoc-gen-go generated messages.
|
||||||
|
// The proto package will stop type-asserting to this interface in the future.
|
||||||
|
//
|
||||||
|
// DO NOT DEPEND ON THIS.
|
||||||
|
type newUnmarshaler interface {
|
||||||
|
XXX_Unmarshal([]byte) error
|
||||||
|
}
|
||||||
|
|
||||||
// Unmarshal parses the protocol buffer representation in buf and places the
|
// Unmarshal parses the protocol buffer representation in buf and places the
|
||||||
// decoded result in pb. If the struct underlying pb does not match
|
// decoded result in pb. If the struct underlying pb does not match
|
||||||
// the data in buf, the results can be unpredictable.
|
// the data in buf, the results can be unpredictable.
|
||||||
@@ -395,7 +334,13 @@ type Unmarshaler interface {
|
|||||||
// to preserve and append to existing data.
|
// to preserve and append to existing data.
|
||||||
func Unmarshal(buf []byte, pb Message) error {
|
func Unmarshal(buf []byte, pb Message) error {
|
||||||
pb.Reset()
|
pb.Reset()
|
||||||
return UnmarshalMerge(buf, pb)
|
if u, ok := pb.(newUnmarshaler); ok {
|
||||||
|
return u.XXX_Unmarshal(buf)
|
||||||
|
}
|
||||||
|
if u, ok := pb.(Unmarshaler); ok {
|
||||||
|
return u.Unmarshal(buf)
|
||||||
|
}
|
||||||
|
return NewBuffer(buf).Unmarshal(pb)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalMerge parses the protocol buffer representation in buf and
|
// UnmarshalMerge parses the protocol buffer representation in buf and
|
||||||
@@ -405,8 +350,16 @@ func Unmarshal(buf []byte, pb Message) error {
|
|||||||
// UnmarshalMerge merges into existing data in pb.
|
// UnmarshalMerge merges into existing data in pb.
|
||||||
// Most code should use Unmarshal instead.
|
// Most code should use Unmarshal instead.
|
||||||
func UnmarshalMerge(buf []byte, pb Message) error {
|
func UnmarshalMerge(buf []byte, pb Message) error {
|
||||||
// If the object can unmarshal itself, let it.
|
if u, ok := pb.(newUnmarshaler); ok {
|
||||||
|
return u.XXX_Unmarshal(buf)
|
||||||
|
}
|
||||||
if u, ok := pb.(Unmarshaler); ok {
|
if u, ok := pb.(Unmarshaler); ok {
|
||||||
|
// NOTE: The history of proto have unfortunately been inconsistent
|
||||||
|
// whether Unmarshaler should or should not implicitly clear itself.
|
||||||
|
// Some implementations do, most do not.
|
||||||
|
// Thus, calling this here may or may not do what people want.
|
||||||
|
//
|
||||||
|
// See https://github.com/golang/protobuf/issues/424
|
||||||
return u.Unmarshal(buf)
|
return u.Unmarshal(buf)
|
||||||
}
|
}
|
||||||
return NewBuffer(buf).Unmarshal(pb)
|
return NewBuffer(buf).Unmarshal(pb)
|
||||||
@@ -422,12 +375,17 @@ func (p *Buffer) DecodeMessage(pb Message) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DecodeGroup reads a tag-delimited group from the Buffer.
|
// DecodeGroup reads a tag-delimited group from the Buffer.
|
||||||
|
// StartGroup tag is already consumed. This function consumes
|
||||||
|
// EndGroup tag.
|
||||||
func (p *Buffer) DecodeGroup(pb Message) error {
|
func (p *Buffer) DecodeGroup(pb Message) error {
|
||||||
typ, base, err := getbase(pb)
|
b := p.buf[p.index:]
|
||||||
if err != nil {
|
x, y := findEndGroup(b)
|
||||||
return err
|
if x < 0 {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base)
|
err := Unmarshal(b[:x], pb)
|
||||||
|
p.index += y
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal parses the protocol buffer representation in the
|
// Unmarshal parses the protocol buffer representation in the
|
||||||
@@ -438,541 +396,33 @@ func (p *Buffer) DecodeGroup(pb Message) error {
|
|||||||
// Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal.
|
// Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal.
|
||||||
func (p *Buffer) Unmarshal(pb Message) error {
|
func (p *Buffer) Unmarshal(pb Message) error {
|
||||||
// If the object can unmarshal itself, let it.
|
// If the object can unmarshal itself, let it.
|
||||||
|
if u, ok := pb.(newUnmarshaler); ok {
|
||||||
|
err := u.XXX_Unmarshal(p.buf[p.index:])
|
||||||
|
p.index = len(p.buf)
|
||||||
|
return err
|
||||||
|
}
|
||||||
if u, ok := pb.(Unmarshaler); ok {
|
if u, ok := pb.(Unmarshaler); ok {
|
||||||
|
// NOTE: The history of proto have unfortunately been inconsistent
|
||||||
|
// whether Unmarshaler should or should not implicitly clear itself.
|
||||||
|
// Some implementations do, most do not.
|
||||||
|
// Thus, calling this here may or may not do what people want.
|
||||||
|
//
|
||||||
|
// See https://github.com/golang/protobuf/issues/424
|
||||||
err := u.Unmarshal(p.buf[p.index:])
|
err := u.Unmarshal(p.buf[p.index:])
|
||||||
p.index = len(p.buf)
|
p.index = len(p.buf)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
typ, base, err := getbase(pb)
|
// Slow workaround for messages that aren't Unmarshalers.
|
||||||
if err != nil {
|
// This includes some hand-coded .pb.go files and
|
||||||
return err
|
// bootstrap protos.
|
||||||
}
|
// TODO: fix all of those and then add Unmarshal to
|
||||||
|
// the Message interface. Then:
|
||||||
err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base)
|
// The cast above and code below can be deleted.
|
||||||
|
// The old unmarshaler can be deleted.
|
||||||
if collectStats {
|
// Clients can call Unmarshal directly (can already do that, actually).
|
||||||
stats.Decode++
|
var info InternalMessageInfo
|
||||||
}
|
err := info.Unmarshal(pb, p.buf[p.index:])
|
||||||
|
p.index = len(p.buf)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// unmarshalType does the work of unmarshaling a structure.
|
|
||||||
func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error {
|
|
||||||
var state errorState
|
|
||||||
required, reqFields := prop.reqCount, uint64(0)
|
|
||||||
|
|
||||||
var err error
|
|
||||||
for err == nil && o.index < len(o.buf) {
|
|
||||||
oi := o.index
|
|
||||||
var u uint64
|
|
||||||
u, err = o.DecodeVarint()
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
wire := int(u & 0x7)
|
|
||||||
if wire == WireEndGroup {
|
|
||||||
if is_group {
|
|
||||||
if required > 0 {
|
|
||||||
// Not enough information to determine the exact field.
|
|
||||||
// (See below.)
|
|
||||||
return &RequiredNotSetError{"{Unknown}"}
|
|
||||||
}
|
|
||||||
return nil // input is satisfied
|
|
||||||
}
|
|
||||||
return fmt.Errorf("proto: %s: wiretype end group for non-group", st)
|
|
||||||
}
|
|
||||||
tag := int(u >> 3)
|
|
||||||
if tag <= 0 {
|
|
||||||
return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire)
|
|
||||||
}
|
|
||||||
fieldnum, ok := prop.decoderTags.get(tag)
|
|
||||||
if !ok {
|
|
||||||
// Maybe it's an extension?
|
|
||||||
if prop.extendable {
|
|
||||||
if e, eok := structPointer_Interface(base, st).(extensionsBytes); eok {
|
|
||||||
if isExtensionField(e, int32(tag)) {
|
|
||||||
if err = o.skip(st, tag, wire); err == nil {
|
|
||||||
ext := e.GetExtensions()
|
|
||||||
*ext = append(*ext, o.buf[oi:o.index]...)
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
} else if e, _ := extendable(structPointer_Interface(base, st)); isExtensionField(e, int32(tag)) {
|
|
||||||
if err = o.skip(st, tag, wire); err == nil {
|
|
||||||
extmap := e.extensionsWrite()
|
|
||||||
ext := extmap[int32(tag)] // may be missing
|
|
||||||
ext.enc = append(ext.enc, o.buf[oi:o.index]...)
|
|
||||||
extmap[int32(tag)] = ext
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Maybe it's a oneof?
|
|
||||||
if prop.oneofUnmarshaler != nil {
|
|
||||||
m := structPointer_Interface(base, st).(Message)
|
|
||||||
// First return value indicates whether tag is a oneof field.
|
|
||||||
ok, err = prop.oneofUnmarshaler(m, tag, wire, o)
|
|
||||||
if err == ErrInternalBadWireType {
|
|
||||||
// Map the error to something more descriptive.
|
|
||||||
// Do the formatting here to save generated code space.
|
|
||||||
err = fmt.Errorf("bad wiretype for oneof field in %T", m)
|
|
||||||
}
|
|
||||||
if ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = o.skipAndSave(st, tag, wire, base, prop.unrecField)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
p := prop.Prop[fieldnum]
|
|
||||||
|
|
||||||
if p.dec == nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
dec := p.dec
|
|
||||||
if wire != WireStartGroup && wire != p.WireType {
|
|
||||||
if wire == WireBytes && p.packedDec != nil {
|
|
||||||
// a packable field
|
|
||||||
dec = p.packedDec
|
|
||||||
} else {
|
|
||||||
err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
decErr := dec(o, p, base)
|
|
||||||
if decErr != nil && !state.shouldContinue(decErr, p) {
|
|
||||||
err = decErr
|
|
||||||
}
|
|
||||||
if err == nil && p.Required {
|
|
||||||
// Successfully decoded a required field.
|
|
||||||
if tag <= 64 {
|
|
||||||
// use bitmap for fields 1-64 to catch field reuse.
|
|
||||||
var mask uint64 = 1 << uint64(tag-1)
|
|
||||||
if reqFields&mask == 0 {
|
|
||||||
// new required field
|
|
||||||
reqFields |= mask
|
|
||||||
required--
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// This is imprecise. It can be fooled by a required field
|
|
||||||
// with a tag > 64 that is encoded twice; that's very rare.
|
|
||||||
// A fully correct implementation would require allocating
|
|
||||||
// a data structure, which we would like to avoid.
|
|
||||||
required--
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err == nil {
|
|
||||||
if is_group {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
if state.err != nil {
|
|
||||||
return state.err
|
|
||||||
}
|
|
||||||
if required > 0 {
|
|
||||||
// Not enough information to determine the exact field. If we use extra
|
|
||||||
// CPU, we could determine the field only if the missing required field
|
|
||||||
// has a tag <= 64 and we check reqFields.
|
|
||||||
return &RequiredNotSetError{"{Unknown}"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Individual type decoders
|
|
||||||
// For each,
|
|
||||||
// u is the decoded value,
|
|
||||||
// v is a pointer to the field (pointer) in the struct
|
|
||||||
|
|
||||||
// Sizes of the pools to allocate inside the Buffer.
|
|
||||||
// The goal is modest amortization and allocation
|
|
||||||
// on at least 16-byte boundaries.
|
|
||||||
const (
|
|
||||||
boolPoolSize = 16
|
|
||||||
uint32PoolSize = 8
|
|
||||||
uint64PoolSize = 4
|
|
||||||
)
|
|
||||||
|
|
||||||
// Decode a bool.
|
|
||||||
func (o *Buffer) dec_bool(p *Properties, base structPointer) error {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if len(o.bools) == 0 {
|
|
||||||
o.bools = make([]bool, boolPoolSize)
|
|
||||||
}
|
|
||||||
o.bools[0] = u != 0
|
|
||||||
*structPointer_Bool(base, p.field) = &o.bools[0]
|
|
||||||
o.bools = o.bools[1:]
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*structPointer_BoolVal(base, p.field) = u != 0
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode an int32.
|
|
||||||
func (o *Buffer) dec_int32(p *Properties, base structPointer) error {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
word32_Set(structPointer_Word32(base, p.field), o, uint32(u))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode an int64.
|
|
||||||
func (o *Buffer) dec_int64(p *Properties, base structPointer) error {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
word64_Set(structPointer_Word64(base, p.field), o, u)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
word64Val_Set(structPointer_Word64Val(base, p.field), o, u)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a string.
|
|
||||||
func (o *Buffer) dec_string(p *Properties, base structPointer) error {
|
|
||||||
s, err := o.DecodeStringBytes()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*structPointer_String(base, p.field) = &s
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error {
|
|
||||||
s, err := o.DecodeStringBytes()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*structPointer_StringVal(base, p.field) = s
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of bytes ([]byte).
|
|
||||||
func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error {
|
|
||||||
b, err := o.DecodeRawBytes(true)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*structPointer_Bytes(base, p.field) = b
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of bools ([]bool).
|
|
||||||
func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
v := structPointer_BoolSlice(base, p.field)
|
|
||||||
*v = append(*v, u != 0)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of bools ([]bool) in packed format.
|
|
||||||
func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error {
|
|
||||||
v := structPointer_BoolSlice(base, p.field)
|
|
||||||
|
|
||||||
nn, err := o.DecodeVarint()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
nb := int(nn) // number of bytes of encoded bools
|
|
||||||
fin := o.index + nb
|
|
||||||
if fin < o.index {
|
|
||||||
return errOverflow
|
|
||||||
}
|
|
||||||
|
|
||||||
y := *v
|
|
||||||
for o.index < fin {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
y = append(y, u != 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
*v = y
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of int32s ([]int32).
|
|
||||||
func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
structPointer_Word32Slice(base, p.field).Append(uint32(u))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of int32s ([]int32) in packed format.
|
|
||||||
func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error {
|
|
||||||
v := structPointer_Word32Slice(base, p.field)
|
|
||||||
|
|
||||||
nn, err := o.DecodeVarint()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
nb := int(nn) // number of bytes of encoded int32s
|
|
||||||
|
|
||||||
fin := o.index + nb
|
|
||||||
if fin < o.index {
|
|
||||||
return errOverflow
|
|
||||||
}
|
|
||||||
for o.index < fin {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
v.Append(uint32(u))
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of int64s ([]int64).
|
|
||||||
func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
structPointer_Word64Slice(base, p.field).Append(u)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of int64s ([]int64) in packed format.
|
|
||||||
func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error {
|
|
||||||
v := structPointer_Word64Slice(base, p.field)
|
|
||||||
|
|
||||||
nn, err := o.DecodeVarint()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
nb := int(nn) // number of bytes of encoded int64s
|
|
||||||
|
|
||||||
fin := o.index + nb
|
|
||||||
if fin < o.index {
|
|
||||||
return errOverflow
|
|
||||||
}
|
|
||||||
for o.index < fin {
|
|
||||||
u, err := p.valDec(o)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
v.Append(u)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of strings ([]string).
|
|
||||||
func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error {
|
|
||||||
s, err := o.DecodeStringBytes()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
v := structPointer_StringSlice(base, p.field)
|
|
||||||
*v = append(*v, s)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of slice of bytes ([][]byte).
|
|
||||||
func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error {
|
|
||||||
b, err := o.DecodeRawBytes(true)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
v := structPointer_BytesSlice(base, p.field)
|
|
||||||
*v = append(*v, b)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a map field.
|
|
||||||
func (o *Buffer) dec_new_map(p *Properties, base structPointer) error {
|
|
||||||
raw, err := o.DecodeRawBytes(false)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
oi := o.index // index at the end of this map entry
|
|
||||||
o.index -= len(raw) // move buffer back to start of map entry
|
|
||||||
|
|
||||||
mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V
|
|
||||||
if mptr.Elem().IsNil() {
|
|
||||||
mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem()))
|
|
||||||
}
|
|
||||||
v := mptr.Elem() // map[K]V
|
|
||||||
|
|
||||||
// Prepare addressable doubly-indirect placeholders for the key and value types.
|
|
||||||
// See enc_new_map for why.
|
|
||||||
keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K
|
|
||||||
keybase := toStructPointer(keyptr.Addr()) // **K
|
|
||||||
|
|
||||||
var valbase structPointer
|
|
||||||
var valptr reflect.Value
|
|
||||||
switch p.mtype.Elem().Kind() {
|
|
||||||
case reflect.Slice:
|
|
||||||
// []byte
|
|
||||||
var dummy []byte
|
|
||||||
valptr = reflect.ValueOf(&dummy) // *[]byte
|
|
||||||
valbase = toStructPointer(valptr) // *[]byte
|
|
||||||
case reflect.Ptr:
|
|
||||||
// message; valptr is **Msg; need to allocate the intermediate pointer
|
|
||||||
valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V
|
|
||||||
valptr.Set(reflect.New(valptr.Type().Elem()))
|
|
||||||
valbase = toStructPointer(valptr)
|
|
||||||
default:
|
|
||||||
// everything else
|
|
||||||
valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V
|
|
||||||
valbase = toStructPointer(valptr.Addr()) // **V
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode.
|
|
||||||
// This parses a restricted wire format, namely the encoding of a message
|
|
||||||
// with two fields. See enc_new_map for the format.
|
|
||||||
for o.index < oi {
|
|
||||||
// tagcode for key and value properties are always a single byte
|
|
||||||
// because they have tags 1 and 2.
|
|
||||||
tagcode := o.buf[o.index]
|
|
||||||
o.index++
|
|
||||||
switch tagcode {
|
|
||||||
case p.mkeyprop.tagcode[0]:
|
|
||||||
if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
case p.mvalprop.tagcode[0]:
|
|
||||||
if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
// TODO: Should we silently skip this instead?
|
|
||||||
return fmt.Errorf("proto: bad map data tag %d", raw[0])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
keyelem, valelem := keyptr.Elem(), valptr.Elem()
|
|
||||||
if !keyelem.IsValid() {
|
|
||||||
keyelem = reflect.Zero(p.mtype.Key())
|
|
||||||
}
|
|
||||||
if !valelem.IsValid() {
|
|
||||||
valelem = reflect.Zero(p.mtype.Elem())
|
|
||||||
}
|
|
||||||
|
|
||||||
v.SetMapIndex(keyelem, valelem)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a group.
|
|
||||||
func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error {
|
|
||||||
bas := structPointer_GetStructPointer(base, p.field)
|
|
||||||
if structPointer_IsNil(bas) {
|
|
||||||
// allocate new nested message
|
|
||||||
bas = toStructPointer(reflect.New(p.stype))
|
|
||||||
structPointer_SetStructPointer(base, p.field, bas)
|
|
||||||
}
|
|
||||||
return o.unmarshalType(p.stype, p.sprop, true, bas)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode an embedded message.
|
|
||||||
func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) {
|
|
||||||
raw, e := o.DecodeRawBytes(false)
|
|
||||||
if e != nil {
|
|
||||||
return e
|
|
||||||
}
|
|
||||||
|
|
||||||
bas := structPointer_GetStructPointer(base, p.field)
|
|
||||||
if structPointer_IsNil(bas) {
|
|
||||||
// allocate new nested message
|
|
||||||
bas = toStructPointer(reflect.New(p.stype))
|
|
||||||
structPointer_SetStructPointer(base, p.field, bas)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the object can unmarshal itself, let it.
|
|
||||||
if p.isUnmarshaler {
|
|
||||||
iv := structPointer_Interface(bas, p.stype)
|
|
||||||
return iv.(Unmarshaler).Unmarshal(raw)
|
|
||||||
}
|
|
||||||
|
|
||||||
obuf := o.buf
|
|
||||||
oi := o.index
|
|
||||||
o.buf = raw
|
|
||||||
o.index = 0
|
|
||||||
|
|
||||||
err = o.unmarshalType(p.stype, p.sprop, false, bas)
|
|
||||||
o.buf = obuf
|
|
||||||
o.index = oi
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of embedded messages.
|
|
||||||
func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error {
|
|
||||||
return o.dec_slice_struct(p, false, base)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of embedded groups.
|
|
||||||
func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error {
|
|
||||||
return o.dec_slice_struct(p, true, base)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of structs ([]*struct).
|
|
||||||
func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error {
|
|
||||||
v := reflect.New(p.stype)
|
|
||||||
bas := toStructPointer(v)
|
|
||||||
structPointer_StructPointerSlice(base, p.field).Append(bas)
|
|
||||||
|
|
||||||
if is_group {
|
|
||||||
err := o.unmarshalType(p.stype, p.sprop, is_group, bas)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
raw, err := o.DecodeRawBytes(false)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the object can unmarshal itself, let it.
|
|
||||||
if p.isUnmarshaler {
|
|
||||||
iv := v.Interface()
|
|
||||||
return iv.(Unmarshaler).Unmarshal(raw)
|
|
||||||
}
|
|
||||||
|
|
||||||
obuf := o.buf
|
|
||||||
oi := o.index
|
|
||||||
o.buf = raw
|
|
||||||
o.index = 0
|
|
||||||
|
|
||||||
err = o.unmarshalType(p.stype, p.sprop, is_group, bas)
|
|
||||||
|
|
||||||
o.buf = obuf
|
|
||||||
o.index = oi
|
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
-172
@@ -1,172 +0,0 @@
|
|||||||
// Protocol Buffers for Go with Gadgets
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
|
||||||
// http://github.com/gogo/protobuf
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
package proto
|
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Decode a reference to a struct pointer.
|
|
||||||
func (o *Buffer) dec_ref_struct_message(p *Properties, base structPointer) (err error) {
|
|
||||||
raw, e := o.DecodeRawBytes(false)
|
|
||||||
if e != nil {
|
|
||||||
return e
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the object can unmarshal itself, let it.
|
|
||||||
if p.isUnmarshaler {
|
|
||||||
panic("not supported, since this is a pointer receiver")
|
|
||||||
}
|
|
||||||
|
|
||||||
obuf := o.buf
|
|
||||||
oi := o.index
|
|
||||||
o.buf = raw
|
|
||||||
o.index = 0
|
|
||||||
|
|
||||||
bas := structPointer_FieldPointer(base, p.field)
|
|
||||||
|
|
||||||
err = o.unmarshalType(p.stype, p.sprop, false, bas)
|
|
||||||
o.buf = obuf
|
|
||||||
o.index = oi
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of references to struct pointers ([]struct).
|
|
||||||
func (o *Buffer) dec_slice_ref_struct(p *Properties, is_group bool, base structPointer) error {
|
|
||||||
newBas := appendStructPointer(base, p.field, p.sstype)
|
|
||||||
|
|
||||||
if is_group {
|
|
||||||
panic("not supported, maybe in future, if requested.")
|
|
||||||
}
|
|
||||||
|
|
||||||
raw, err := o.DecodeRawBytes(false)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the object can unmarshal itself, let it.
|
|
||||||
if p.isUnmarshaler {
|
|
||||||
panic("not supported, since this is not a pointer receiver.")
|
|
||||||
}
|
|
||||||
|
|
||||||
obuf := o.buf
|
|
||||||
oi := o.index
|
|
||||||
o.buf = raw
|
|
||||||
o.index = 0
|
|
||||||
|
|
||||||
err = o.unmarshalType(p.stype, p.sprop, is_group, newBas)
|
|
||||||
|
|
||||||
o.buf = obuf
|
|
||||||
o.index = oi
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of references to struct pointers.
|
|
||||||
func (o *Buffer) dec_slice_ref_struct_message(p *Properties, base structPointer) error {
|
|
||||||
return o.dec_slice_ref_struct(p, false, base)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setPtrCustomType(base structPointer, f field, v interface{}) {
|
|
||||||
if v == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
structPointer_SetStructPointer(base, f, toStructPointer(reflect.ValueOf(v)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func setCustomType(base structPointer, f field, value interface{}) {
|
|
||||||
if value == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := reflect.ValueOf(value).Elem()
|
|
||||||
t := reflect.TypeOf(value).Elem()
|
|
||||||
kind := t.Kind()
|
|
||||||
switch kind {
|
|
||||||
case reflect.Slice:
|
|
||||||
slice := reflect.MakeSlice(t, v.Len(), v.Cap())
|
|
||||||
reflect.Copy(slice, v)
|
|
||||||
oldHeader := structPointer_GetSliceHeader(base, f)
|
|
||||||
oldHeader.Data = slice.Pointer()
|
|
||||||
oldHeader.Len = v.Len()
|
|
||||||
oldHeader.Cap = v.Cap()
|
|
||||||
default:
|
|
||||||
size := reflect.TypeOf(value).Elem().Size()
|
|
||||||
structPointer_Copy(toStructPointer(reflect.ValueOf(value)), structPointer_Add(base, f), int(size))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_custom_bytes(p *Properties, base structPointer) error {
|
|
||||||
b, err := o.DecodeRawBytes(true)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
i := reflect.New(p.ctype.Elem()).Interface()
|
|
||||||
custom := (i).(Unmarshaler)
|
|
||||||
if err := custom.Unmarshal(b); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
setPtrCustomType(base, p.field, custom)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_custom_ref_bytes(p *Properties, base structPointer) error {
|
|
||||||
b, err := o.DecodeRawBytes(true)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
i := reflect.New(p.ctype).Interface()
|
|
||||||
custom := (i).(Unmarshaler)
|
|
||||||
if err := custom.Unmarshal(b); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if custom != nil {
|
|
||||||
setCustomType(base, p.field, custom)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a slice of bytes ([]byte) into a slice of custom types.
|
|
||||||
func (o *Buffer) dec_custom_slice_bytes(p *Properties, base structPointer) error {
|
|
||||||
b, err := o.DecodeRawBytes(true)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
i := reflect.New(p.ctype.Elem()).Interface()
|
|
||||||
custom := (i).(Unmarshaler)
|
|
||||||
if err := custom.Unmarshal(b); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
newBas := appendStructPointer(base, p.field, p.ctype)
|
|
||||||
|
|
||||||
var zero field
|
|
||||||
setCustomType(newBas, zero, custom)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
+200
-1
@@ -35,8 +35,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type generatedDiscarder interface {
|
||||||
|
XXX_DiscardUnknown()
|
||||||
|
}
|
||||||
|
|
||||||
// DiscardUnknown recursively discards all unknown fields from this message
|
// DiscardUnknown recursively discards all unknown fields from this message
|
||||||
// and all embedded messages.
|
// and all embedded messages.
|
||||||
//
|
//
|
||||||
@@ -49,9 +55,202 @@ import (
|
|||||||
// For proto2 messages, the unknown fields of message extensions are only
|
// For proto2 messages, the unknown fields of message extensions are only
|
||||||
// discarded from messages that have been accessed via GetExtension.
|
// discarded from messages that have been accessed via GetExtension.
|
||||||
func DiscardUnknown(m Message) {
|
func DiscardUnknown(m Message) {
|
||||||
|
if m, ok := m.(generatedDiscarder); ok {
|
||||||
|
m.XXX_DiscardUnknown()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// TODO: Dynamically populate a InternalMessageInfo for legacy messages,
|
||||||
|
// but the master branch has no implementation for InternalMessageInfo,
|
||||||
|
// so it would be more work to replicate that approach.
|
||||||
discardLegacy(m)
|
discardLegacy(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DiscardUnknown recursively discards all unknown fields.
|
||||||
|
func (a *InternalMessageInfo) DiscardUnknown(m Message) {
|
||||||
|
di := atomicLoadDiscardInfo(&a.discard)
|
||||||
|
if di == nil {
|
||||||
|
di = getDiscardInfo(reflect.TypeOf(m).Elem())
|
||||||
|
atomicStoreDiscardInfo(&a.discard, di)
|
||||||
|
}
|
||||||
|
di.discard(toPointer(&m))
|
||||||
|
}
|
||||||
|
|
||||||
|
type discardInfo struct {
|
||||||
|
typ reflect.Type
|
||||||
|
|
||||||
|
initialized int32 // 0: only typ is valid, 1: everything is valid
|
||||||
|
lock sync.Mutex
|
||||||
|
|
||||||
|
fields []discardFieldInfo
|
||||||
|
unrecognized field
|
||||||
|
}
|
||||||
|
|
||||||
|
type discardFieldInfo struct {
|
||||||
|
field field // Offset of field, guaranteed to be valid
|
||||||
|
discard func(src pointer)
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
discardInfoMap = map[reflect.Type]*discardInfo{}
|
||||||
|
discardInfoLock sync.Mutex
|
||||||
|
)
|
||||||
|
|
||||||
|
func getDiscardInfo(t reflect.Type) *discardInfo {
|
||||||
|
discardInfoLock.Lock()
|
||||||
|
defer discardInfoLock.Unlock()
|
||||||
|
di := discardInfoMap[t]
|
||||||
|
if di == nil {
|
||||||
|
di = &discardInfo{typ: t}
|
||||||
|
discardInfoMap[t] = di
|
||||||
|
}
|
||||||
|
return di
|
||||||
|
}
|
||||||
|
|
||||||
|
func (di *discardInfo) discard(src pointer) {
|
||||||
|
if src.isNil() {
|
||||||
|
return // Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
|
if atomic.LoadInt32(&di.initialized) == 0 {
|
||||||
|
di.computeDiscardInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, fi := range di.fields {
|
||||||
|
sfp := src.offset(fi.field)
|
||||||
|
fi.discard(sfp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// For proto2 messages, only discard unknown fields in message extensions
|
||||||
|
// that have been accessed via GetExtension.
|
||||||
|
if em, err := extendable(src.asPointerTo(di.typ).Interface()); err == nil {
|
||||||
|
// Ignore lock since DiscardUnknown is not concurrency safe.
|
||||||
|
emm, _ := em.extensionsRead()
|
||||||
|
for _, mx := range emm {
|
||||||
|
if m, ok := mx.value.(Message); ok {
|
||||||
|
DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if di.unrecognized.IsValid() {
|
||||||
|
*src.offset(di.unrecognized).toBytes() = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (di *discardInfo) computeDiscardInfo() {
|
||||||
|
di.lock.Lock()
|
||||||
|
defer di.lock.Unlock()
|
||||||
|
if di.initialized != 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t := di.typ
|
||||||
|
n := t.NumField()
|
||||||
|
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
f := t.Field(i)
|
||||||
|
if strings.HasPrefix(f.Name, "XXX_") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
dfi := discardFieldInfo{field: toField(&f)}
|
||||||
|
tf := f.Type
|
||||||
|
|
||||||
|
// Unwrap tf to get its most basic type.
|
||||||
|
var isPointer, isSlice bool
|
||||||
|
if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
|
||||||
|
isSlice = true
|
||||||
|
tf = tf.Elem()
|
||||||
|
}
|
||||||
|
if tf.Kind() == reflect.Ptr {
|
||||||
|
isPointer = true
|
||||||
|
tf = tf.Elem()
|
||||||
|
}
|
||||||
|
if isPointer && isSlice && tf.Kind() != reflect.Struct {
|
||||||
|
panic(fmt.Sprintf("%v.%s cannot be a slice of pointers to primitive types", t, f.Name))
|
||||||
|
}
|
||||||
|
|
||||||
|
switch tf.Kind() {
|
||||||
|
case reflect.Struct:
|
||||||
|
switch {
|
||||||
|
case !isPointer:
|
||||||
|
panic(fmt.Sprintf("%v.%s cannot be a direct struct value", t, f.Name))
|
||||||
|
case isSlice: // E.g., []*pb.T
|
||||||
|
discardInfo := getDiscardInfo(tf)
|
||||||
|
dfi.discard = func(src pointer) {
|
||||||
|
sps := src.getPointerSlice()
|
||||||
|
for _, sp := range sps {
|
||||||
|
if !sp.isNil() {
|
||||||
|
discardInfo.discard(sp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., *pb.T
|
||||||
|
discardInfo := getDiscardInfo(tf)
|
||||||
|
dfi.discard = func(src pointer) {
|
||||||
|
sp := src.getPointer()
|
||||||
|
if !sp.isNil() {
|
||||||
|
discardInfo.discard(sp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Map:
|
||||||
|
switch {
|
||||||
|
case isPointer || isSlice:
|
||||||
|
panic(fmt.Sprintf("%v.%s cannot be a pointer to a map or a slice of map values", t, f.Name))
|
||||||
|
default: // E.g., map[K]V
|
||||||
|
if tf.Elem().Kind() == reflect.Ptr { // Proto struct (e.g., *T)
|
||||||
|
dfi.discard = func(src pointer) {
|
||||||
|
sm := src.asPointerTo(tf).Elem()
|
||||||
|
if sm.Len() == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, key := range sm.MapKeys() {
|
||||||
|
val := sm.MapIndex(key)
|
||||||
|
DiscardUnknown(val.Interface().(Message))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dfi.discard = func(pointer) {} // Noop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Interface:
|
||||||
|
// Must be oneof field.
|
||||||
|
switch {
|
||||||
|
case isPointer || isSlice:
|
||||||
|
panic(fmt.Sprintf("%v.%s cannot be a pointer to a interface or a slice of interface values", t, f.Name))
|
||||||
|
default: // E.g., interface{}
|
||||||
|
// TODO: Make this faster?
|
||||||
|
dfi.discard = func(src pointer) {
|
||||||
|
su := src.asPointerTo(tf).Elem()
|
||||||
|
if !su.IsNil() {
|
||||||
|
sv := su.Elem().Elem().Field(0)
|
||||||
|
if sv.Kind() == reflect.Ptr && sv.IsNil() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch sv.Type().Kind() {
|
||||||
|
case reflect.Ptr: // Proto struct (e.g., *T)
|
||||||
|
DiscardUnknown(sv.Interface().(Message))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
di.fields = append(di.fields, dfi)
|
||||||
|
}
|
||||||
|
|
||||||
|
di.unrecognized = invalidField
|
||||||
|
if f, ok := t.FieldByName("XXX_unrecognized"); ok {
|
||||||
|
if f.Type != reflect.TypeOf([]byte{}) {
|
||||||
|
panic("expected XXX_unrecognized to be of type []byte")
|
||||||
|
}
|
||||||
|
di.unrecognized = toField(&f)
|
||||||
|
}
|
||||||
|
|
||||||
|
atomic.StoreInt32(&di.initialized, 1)
|
||||||
|
}
|
||||||
|
|
||||||
func discardLegacy(m Message) {
|
func discardLegacy(m Message) {
|
||||||
v := reflect.ValueOf(m)
|
v := reflect.ValueOf(m)
|
||||||
if v.Kind() != reflect.Ptr || v.IsNil() {
|
if v.Kind() != reflect.Ptr || v.IsNil() {
|
||||||
@@ -139,7 +338,7 @@ func discardLegacy(m Message) {
|
|||||||
|
|
||||||
// For proto2 messages, only discard unknown fields in message extensions
|
// For proto2 messages, only discard unknown fields in message extensions
|
||||||
// that have been accessed via GetExtension.
|
// that have been accessed via GetExtension.
|
||||||
if em, ok := extendable(m); ok {
|
if em, err := extendable(m); err == nil {
|
||||||
// Ignore lock since discardLegacy is not concurrency safe.
|
// Ignore lock since discardLegacy is not concurrency safe.
|
||||||
emm, _ := em.extensionsRead()
|
emm, _ := em.extensionsRead()
|
||||||
for _, mx := range emm {
|
for _, mx := range emm {
|
||||||
|
|||||||
-154
@@ -47,157 +47,3 @@ func (*duration) String() string { return "duration<string>" }
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterType((*duration)(nil), "gogo.protobuf.proto.duration")
|
RegisterType((*duration)(nil), "gogo.protobuf.proto.duration")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Buffer) decDuration() (time.Duration, error) {
|
|
||||||
b, err := o.DecodeRawBytes(true)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
dproto := &duration{}
|
|
||||||
if err := Unmarshal(b, dproto); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return durationFromProto(dproto)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_duration(p *Properties, base structPointer) error {
|
|
||||||
d, err := o.decDuration()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
word64_Set(structPointer_Word64(base, p.field), o, uint64(d))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_ref_duration(p *Properties, base structPointer) error {
|
|
||||||
d, err := o.decDuration()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
word64Val_Set(structPointer_Word64Val(base, p.field), o, uint64(d))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_slice_duration(p *Properties, base structPointer) error {
|
|
||||||
d, err := o.decDuration()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
newBas := appendStructPointer(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType)))
|
|
||||||
var zero field
|
|
||||||
setPtrCustomType(newBas, zero, &d)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_slice_ref_duration(p *Properties, base structPointer) error {
|
|
||||||
d, err := o.decDuration()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
structPointer_Word64Slice(base, p.field).Append(uint64(d))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_duration(p *Properties, base structPointer) (n int) {
|
|
||||||
structp := structPointer_GetStructPointer(base, p.field)
|
|
||||||
if structPointer_IsNil(structp) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
dur := structPointer_Interface(structp, durationType).(*time.Duration)
|
|
||||||
d := durationProto(*dur)
|
|
||||||
size := Size(d)
|
|
||||||
return size + sizeVarint(uint64(size)) + len(p.tagcode)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_duration(p *Properties, base structPointer) error {
|
|
||||||
structp := structPointer_GetStructPointer(base, p.field)
|
|
||||||
if structPointer_IsNil(structp) {
|
|
||||||
return ErrNil
|
|
||||||
}
|
|
||||||
dur := structPointer_Interface(structp, durationType).(*time.Duration)
|
|
||||||
d := durationProto(*dur)
|
|
||||||
data, err := Marshal(d)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_ref_duration(p *Properties, base structPointer) (n int) {
|
|
||||||
dur := structPointer_InterfaceAt(base, p.field, durationType).(*time.Duration)
|
|
||||||
d := durationProto(*dur)
|
|
||||||
size := Size(d)
|
|
||||||
return size + sizeVarint(uint64(size)) + len(p.tagcode)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_ref_duration(p *Properties, base structPointer) error {
|
|
||||||
dur := structPointer_InterfaceAt(base, p.field, durationType).(*time.Duration)
|
|
||||||
d := durationProto(*dur)
|
|
||||||
data, err := Marshal(d)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_slice_duration(p *Properties, base structPointer) (n int) {
|
|
||||||
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))).(*[]*time.Duration)
|
|
||||||
durs := *pdurs
|
|
||||||
for i := 0; i < len(durs); i++ {
|
|
||||||
if durs[i] == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
dproto := durationProto(*durs[i])
|
|
||||||
size := Size(dproto)
|
|
||||||
n += len(p.tagcode) + size + sizeVarint(uint64(size))
|
|
||||||
}
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_slice_duration(p *Properties, base structPointer) error {
|
|
||||||
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))).(*[]*time.Duration)
|
|
||||||
durs := *pdurs
|
|
||||||
for i := 0; i < len(durs); i++ {
|
|
||||||
if durs[i] == nil {
|
|
||||||
return errRepeatedHasNil
|
|
||||||
}
|
|
||||||
dproto := durationProto(*durs[i])
|
|
||||||
data, err := Marshal(dproto)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_slice_ref_duration(p *Properties, base structPointer) (n int) {
|
|
||||||
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(durationType)).(*[]time.Duration)
|
|
||||||
durs := *pdurs
|
|
||||||
for i := 0; i < len(durs); i++ {
|
|
||||||
dproto := durationProto(durs[i])
|
|
||||||
size := Size(dproto)
|
|
||||||
n += len(p.tagcode) + size + sizeVarint(uint64(size))
|
|
||||||
}
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_slice_ref_duration(p *Properties, base structPointer) error {
|
|
||||||
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(durationType)).(*[]time.Duration)
|
|
||||||
durs := *pdurs
|
|
||||||
for i := 0; i < len(durs); i++ {
|
|
||||||
dproto := durationProto(durs[i])
|
|
||||||
data, err := Marshal(dproto)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
+24
-1183
File diff suppressed because it is too large
Load Diff
-317
@@ -3,11 +3,6 @@
|
|||||||
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
||||||
// http://github.com/gogo/protobuf
|
// http://github.com/gogo/protobuf
|
||||||
//
|
//
|
||||||
// Go support for Protocol Buffers - Google's data interchange format
|
|
||||||
//
|
|
||||||
// Copyright 2010 The Go Authors. All rights reserved.
|
|
||||||
// http://github.com/golang/protobuf/
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
@@ -18,9 +13,6 @@
|
|||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
@@ -36,315 +28,6 @@
|
|||||||
|
|
||||||
package proto
|
package proto
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewRequiredNotSetError(field string) *RequiredNotSetError {
|
func NewRequiredNotSetError(field string) *RequiredNotSetError {
|
||||||
return &RequiredNotSetError{field}
|
return &RequiredNotSetError{field}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Sizer interface {
|
|
||||||
Size() int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_ext_slice_byte(p *Properties, base structPointer) error {
|
|
||||||
s := *structPointer_Bytes(base, p.field)
|
|
||||||
if s == nil {
|
|
||||||
return ErrNil
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, s...)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_ext_slice_byte(p *Properties, base structPointer) (n int) {
|
|
||||||
s := *structPointer_Bytes(base, p.field)
|
|
||||||
if s == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
n += len(s)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode a reference to bool pointer.
|
|
||||||
func (o *Buffer) enc_ref_bool(p *Properties, base structPointer) error {
|
|
||||||
v := *structPointer_BoolVal(base, p.field)
|
|
||||||
x := 0
|
|
||||||
if v {
|
|
||||||
x = 1
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
p.valEnc(o, uint64(x))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_ref_bool(p *Properties, base structPointer) int {
|
|
||||||
return len(p.tagcode) + 1 // each bool takes exactly one byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode a reference to int32 pointer.
|
|
||||||
func (o *Buffer) enc_ref_int32(p *Properties, base structPointer) error {
|
|
||||||
v := structPointer_Word32Val(base, p.field)
|
|
||||||
x := int32(word32Val_Get(v))
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
p.valEnc(o, uint64(x))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_ref_int32(p *Properties, base structPointer) (n int) {
|
|
||||||
v := structPointer_Word32Val(base, p.field)
|
|
||||||
x := int32(word32Val_Get(v))
|
|
||||||
n += len(p.tagcode)
|
|
||||||
n += p.valSize(uint64(x))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_ref_uint32(p *Properties, base structPointer) error {
|
|
||||||
v := structPointer_Word32Val(base, p.field)
|
|
||||||
x := word32Val_Get(v)
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
p.valEnc(o, uint64(x))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_ref_uint32(p *Properties, base structPointer) (n int) {
|
|
||||||
v := structPointer_Word32Val(base, p.field)
|
|
||||||
x := word32Val_Get(v)
|
|
||||||
n += len(p.tagcode)
|
|
||||||
n += p.valSize(uint64(x))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode a reference to an int64 pointer.
|
|
||||||
func (o *Buffer) enc_ref_int64(p *Properties, base structPointer) error {
|
|
||||||
v := structPointer_Word64Val(base, p.field)
|
|
||||||
x := word64Val_Get(v)
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
p.valEnc(o, x)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_ref_int64(p *Properties, base structPointer) (n int) {
|
|
||||||
v := structPointer_Word64Val(base, p.field)
|
|
||||||
x := word64Val_Get(v)
|
|
||||||
n += len(p.tagcode)
|
|
||||||
n += p.valSize(x)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode a reference to a string pointer.
|
|
||||||
func (o *Buffer) enc_ref_string(p *Properties, base structPointer) error {
|
|
||||||
v := *structPointer_StringVal(base, p.field)
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeStringBytes(v)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_ref_string(p *Properties, base structPointer) (n int) {
|
|
||||||
v := *structPointer_StringVal(base, p.field)
|
|
||||||
n += len(p.tagcode)
|
|
||||||
n += sizeStringBytes(v)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode a reference to a message struct.
|
|
||||||
func (o *Buffer) enc_ref_struct_message(p *Properties, base structPointer) error {
|
|
||||||
var state errorState
|
|
||||||
structp := structPointer_GetRefStructPointer(base, p.field)
|
|
||||||
if structPointer_IsNil(structp) {
|
|
||||||
return ErrNil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can the object marshal itself?
|
|
||||||
if p.isMarshaler {
|
|
||||||
m := structPointer_Interface(structp, p.stype).(Marshaler)
|
|
||||||
data, err := m.Marshal()
|
|
||||||
if err != nil && !state.shouldContinue(err, nil) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
return o.enc_len_struct(p.sprop, structp, &state)
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO this is only copied, please fix this
|
|
||||||
func size_ref_struct_message(p *Properties, base structPointer) int {
|
|
||||||
structp := structPointer_GetRefStructPointer(base, p.field)
|
|
||||||
if structPointer_IsNil(structp) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can the object marshal itself?
|
|
||||||
if p.isMarshaler {
|
|
||||||
m := structPointer_Interface(structp, p.stype).(Marshaler)
|
|
||||||
data, _ := m.Marshal()
|
|
||||||
n0 := len(p.tagcode)
|
|
||||||
n1 := sizeRawBytes(data)
|
|
||||||
return n0 + n1
|
|
||||||
}
|
|
||||||
|
|
||||||
n0 := len(p.tagcode)
|
|
||||||
n1 := size_struct(p.sprop, structp)
|
|
||||||
n2 := sizeVarint(uint64(n1)) // size of encoded length
|
|
||||||
return n0 + n1 + n2
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode a slice of references to message struct pointers ([]struct).
|
|
||||||
func (o *Buffer) enc_slice_ref_struct_message(p *Properties, base structPointer) error {
|
|
||||||
var state errorState
|
|
||||||
ss := structPointer_StructRefSlice(base, p.field, p.stype.Size())
|
|
||||||
l := ss.Len()
|
|
||||||
for i := 0; i < l; i++ {
|
|
||||||
structp := ss.Index(i)
|
|
||||||
if structPointer_IsNil(structp) {
|
|
||||||
return errRepeatedHasNil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can the object marshal itself?
|
|
||||||
if p.isMarshaler {
|
|
||||||
m := structPointer_Interface(structp, p.stype).(Marshaler)
|
|
||||||
data, err := m.Marshal()
|
|
||||||
if err != nil && !state.shouldContinue(err, nil) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
err := o.enc_len_struct(p.sprop, structp, &state)
|
|
||||||
if err != nil && !state.shouldContinue(err, nil) {
|
|
||||||
if err == ErrNil {
|
|
||||||
return errRepeatedHasNil
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return state.err
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO this is only copied, please fix this
|
|
||||||
func size_slice_ref_struct_message(p *Properties, base structPointer) (n int) {
|
|
||||||
ss := structPointer_StructRefSlice(base, p.field, p.stype.Size())
|
|
||||||
l := ss.Len()
|
|
||||||
n += l * len(p.tagcode)
|
|
||||||
for i := 0; i < l; i++ {
|
|
||||||
structp := ss.Index(i)
|
|
||||||
if structPointer_IsNil(structp) {
|
|
||||||
return // return the size up to this point
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can the object marshal itself?
|
|
||||||
if p.isMarshaler {
|
|
||||||
m := structPointer_Interface(structp, p.stype).(Marshaler)
|
|
||||||
data, _ := m.Marshal()
|
|
||||||
n += len(p.tagcode)
|
|
||||||
n += sizeRawBytes(data)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
n0 := size_struct(p.sprop, structp)
|
|
||||||
n1 := sizeVarint(uint64(n0)) // size of encoded length
|
|
||||||
n += n0 + n1
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_custom_bytes(p *Properties, base structPointer) error {
|
|
||||||
i := structPointer_InterfaceRef(base, p.field, p.ctype)
|
|
||||||
if i == nil {
|
|
||||||
return ErrNil
|
|
||||||
}
|
|
||||||
custom := i.(Marshaler)
|
|
||||||
data, err := custom.Marshal()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if data == nil {
|
|
||||||
return ErrNil
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_custom_bytes(p *Properties, base structPointer) (n int) {
|
|
||||||
n += len(p.tagcode)
|
|
||||||
i := structPointer_InterfaceRef(base, p.field, p.ctype)
|
|
||||||
if i == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
custom := i.(Marshaler)
|
|
||||||
data, _ := custom.Marshal()
|
|
||||||
n += sizeRawBytes(data)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_custom_ref_bytes(p *Properties, base structPointer) error {
|
|
||||||
custom := structPointer_InterfaceAt(base, p.field, p.ctype).(Marshaler)
|
|
||||||
data, err := custom.Marshal()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if data == nil {
|
|
||||||
return ErrNil
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_custom_ref_bytes(p *Properties, base structPointer) (n int) {
|
|
||||||
n += len(p.tagcode)
|
|
||||||
i := structPointer_InterfaceAt(base, p.field, p.ctype)
|
|
||||||
if i == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
custom := i.(Marshaler)
|
|
||||||
data, _ := custom.Marshal()
|
|
||||||
n += sizeRawBytes(data)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_custom_slice_bytes(p *Properties, base structPointer) error {
|
|
||||||
inter := structPointer_InterfaceRef(base, p.field, p.ctype)
|
|
||||||
if inter == nil {
|
|
||||||
return ErrNil
|
|
||||||
}
|
|
||||||
slice := reflect.ValueOf(inter)
|
|
||||||
l := slice.Len()
|
|
||||||
for i := 0; i < l; i++ {
|
|
||||||
v := slice.Index(i)
|
|
||||||
custom := v.Interface().(Marshaler)
|
|
||||||
data, err := custom.Marshal()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_custom_slice_bytes(p *Properties, base structPointer) (n int) {
|
|
||||||
inter := structPointer_InterfaceRef(base, p.field, p.ctype)
|
|
||||||
if inter == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
slice := reflect.ValueOf(inter)
|
|
||||||
l := slice.Len()
|
|
||||||
n += l * len(p.tagcode)
|
|
||||||
for i := 0; i < l; i++ {
|
|
||||||
v := slice.Index(i)
|
|
||||||
custom := v.Interface().(Marshaler)
|
|
||||||
data, _ := custom.Marshal()
|
|
||||||
n += sizeRawBytes(data)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
+15
-15
@@ -109,15 +109,6 @@ func equalStruct(v1, v2 reflect.Value) bool {
|
|||||||
// set/unset mismatch
|
// set/unset mismatch
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
b1, ok := f1.Interface().(raw)
|
|
||||||
if ok {
|
|
||||||
b2 := f2.Interface().(raw)
|
|
||||||
// RawMessage
|
|
||||||
if !bytes.Equal(b1.Bytes(), b2.Bytes()) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
f1, f2 = f1.Elem(), f2.Elem()
|
f1, f2 = f1.Elem(), f2.Elem()
|
||||||
}
|
}
|
||||||
if !equalAny(f1, f2, sprop.Prop[i]) {
|
if !equalAny(f1, f2, sprop.Prop[i]) {
|
||||||
@@ -146,11 +137,7 @@ func equalStruct(v1, v2 reflect.Value) bool {
|
|||||||
|
|
||||||
u1 := uf.Bytes()
|
u1 := uf.Bytes()
|
||||||
u2 := v2.FieldByName("XXX_unrecognized").Bytes()
|
u2 := v2.FieldByName("XXX_unrecognized").Bytes()
|
||||||
if !bytes.Equal(u1, u2) {
|
return bytes.Equal(u1, u2)
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// v1 and v2 are known to have the same type.
|
// v1 and v2 are known to have the same type.
|
||||||
@@ -261,6 +248,15 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool {
|
|||||||
|
|
||||||
m1, m2 := e1.value, e2.value
|
m1, m2 := e1.value, e2.value
|
||||||
|
|
||||||
|
if m1 == nil && m2 == nil {
|
||||||
|
// Both have only encoded form.
|
||||||
|
if bytes.Equal(e1.enc, e2.enc) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// The bytes are different, but the extensions might still be
|
||||||
|
// equal. We need to decode them to compare.
|
||||||
|
}
|
||||||
|
|
||||||
if m1 != nil && m2 != nil {
|
if m1 != nil && m2 != nil {
|
||||||
// Both are unencoded.
|
// Both are unencoded.
|
||||||
if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) {
|
if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) {
|
||||||
@@ -276,8 +272,12 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool {
|
|||||||
desc = m[extNum]
|
desc = m[extNum]
|
||||||
}
|
}
|
||||||
if desc == nil {
|
if desc == nil {
|
||||||
|
// If both have only encoded form and the bytes are the same,
|
||||||
|
// it is handled above. We get here when the bytes are different.
|
||||||
|
// We don't know how to decode it, so just compare them as byte
|
||||||
|
// slices.
|
||||||
log.Printf("proto: don't know how to compare extension %d of %v", extNum, base)
|
log.Printf("proto: don't know how to compare extension %d of %v", extNum, base)
|
||||||
continue
|
return false
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
if m1 == nil {
|
if m1 == nil {
|
||||||
|
|||||||
+99
-188
@@ -38,6 +38,7 @@ package proto
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -69,12 +70,6 @@ type extendableProtoV1 interface {
|
|||||||
ExtensionMap() map[int32]Extension
|
ExtensionMap() map[int32]Extension
|
||||||
}
|
}
|
||||||
|
|
||||||
type extensionsBytes interface {
|
|
||||||
Message
|
|
||||||
ExtensionRangeArray() []ExtensionRange
|
|
||||||
GetExtensions() *[]byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto.
|
// extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto.
|
||||||
type extensionAdapter struct {
|
type extensionAdapter struct {
|
||||||
extendableProtoV1
|
extendableProtoV1
|
||||||
@@ -97,14 +92,31 @@ func (n notLocker) Unlock() {}
|
|||||||
// extendable returns the extendableProto interface for the given generated proto message.
|
// extendable returns the extendableProto interface for the given generated proto message.
|
||||||
// If the proto message has the old extension format, it returns a wrapper that implements
|
// If the proto message has the old extension format, it returns a wrapper that implements
|
||||||
// the extendableProto interface.
|
// the extendableProto interface.
|
||||||
func extendable(p interface{}) (extendableProto, bool) {
|
func extendable(p interface{}) (extendableProto, error) {
|
||||||
if ep, ok := p.(extendableProto); ok {
|
switch p := p.(type) {
|
||||||
return ep, ok
|
case extendableProto:
|
||||||
|
if isNilPtr(p) {
|
||||||
|
return nil, fmt.Errorf("proto: nil %T is not extendable", p)
|
||||||
|
}
|
||||||
|
return p, nil
|
||||||
|
case extendableProtoV1:
|
||||||
|
if isNilPtr(p) {
|
||||||
|
return nil, fmt.Errorf("proto: nil %T is not extendable", p)
|
||||||
|
}
|
||||||
|
return extensionAdapter{p}, nil
|
||||||
|
case extensionsBytes:
|
||||||
|
return slowExtensionAdapter{p}, nil
|
||||||
}
|
}
|
||||||
if ep, ok := p.(extendableProtoV1); ok {
|
// Don't allocate a specific error containing %T:
|
||||||
return extensionAdapter{ep}, ok
|
// this is the hot path for Clone and MarshalText.
|
||||||
}
|
return nil, errNotExtendable
|
||||||
return nil, false
|
}
|
||||||
|
|
||||||
|
var errNotExtendable = errors.New("proto: not an extendable proto.Message")
|
||||||
|
|
||||||
|
func isNilPtr(x interface{}) bool {
|
||||||
|
v := reflect.ValueOf(x)
|
||||||
|
return v.Kind() == reflect.Ptr && v.IsNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX_InternalExtensions is an internal representation of proto extensions.
|
// XXX_InternalExtensions is an internal representation of proto extensions.
|
||||||
@@ -149,16 +161,6 @@ func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Loc
|
|||||||
return e.p.extensionMap, &e.p.mu
|
return e.p.extensionMap, &e.p.mu
|
||||||
}
|
}
|
||||||
|
|
||||||
type extensionRange interface {
|
|
||||||
Message
|
|
||||||
ExtensionRangeArray() []ExtensionRange
|
|
||||||
}
|
|
||||||
|
|
||||||
var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem()
|
|
||||||
var extendableProtoV1Type = reflect.TypeOf((*extendableProtoV1)(nil)).Elem()
|
|
||||||
var extendableBytesType = reflect.TypeOf((*extensionsBytes)(nil)).Elem()
|
|
||||||
var extensionRangeType = reflect.TypeOf((*extensionRange)(nil)).Elem()
|
|
||||||
|
|
||||||
// ExtensionDesc represents an extension specification.
|
// ExtensionDesc represents an extension specification.
|
||||||
// Used in generated code from the protocol compiler.
|
// Used in generated code from the protocol compiler.
|
||||||
type ExtensionDesc struct {
|
type ExtensionDesc struct {
|
||||||
@@ -198,8 +200,8 @@ func SetRawExtension(base Message, id int32, b []byte) {
|
|||||||
*ext = append(*ext, b...)
|
*ext = append(*ext, b...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
epb, ok := extendable(base)
|
epb, err := extendable(base)
|
||||||
if !ok {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
extmap := epb.extensionsWrite()
|
extmap := epb.extensionsWrite()
|
||||||
@@ -207,7 +209,7 @@ func SetRawExtension(base Message, id int32, b []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// isExtensionField returns true iff the given field number is in an extension range.
|
// isExtensionField returns true iff the given field number is in an extension range.
|
||||||
func isExtensionField(pb extensionRange, field int32) bool {
|
func isExtensionField(pb extendableProto, field int32) bool {
|
||||||
for _, er := range pb.ExtensionRangeArray() {
|
for _, er := range pb.ExtensionRangeArray() {
|
||||||
if er.Start <= field && field <= er.End {
|
if er.Start <= field && field <= er.End {
|
||||||
return true
|
return true
|
||||||
@@ -223,8 +225,11 @@ func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error {
|
|||||||
if ea, ok := pbi.(extensionAdapter); ok {
|
if ea, ok := pbi.(extensionAdapter); ok {
|
||||||
pbi = ea.extendableProtoV1
|
pbi = ea.extendableProtoV1
|
||||||
}
|
}
|
||||||
|
if ea, ok := pbi.(slowExtensionAdapter); ok {
|
||||||
|
pbi = ea.extensionsBytes
|
||||||
|
}
|
||||||
if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b {
|
if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b {
|
||||||
return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String())
|
return fmt.Errorf("proto: bad extended type; %v does not extend %v", b, a)
|
||||||
}
|
}
|
||||||
// Check the range.
|
// Check the range.
|
||||||
if !isExtensionField(pb, extension.Field) {
|
if !isExtensionField(pb, extension.Field) {
|
||||||
@@ -269,80 +274,6 @@ func extensionProperties(ed *ExtensionDesc) *Properties {
|
|||||||
return prop
|
return prop
|
||||||
}
|
}
|
||||||
|
|
||||||
// encode encodes any unmarshaled (unencoded) extensions in e.
|
|
||||||
func encodeExtensions(e *XXX_InternalExtensions) error {
|
|
||||||
m, mu := e.extensionsRead()
|
|
||||||
if m == nil {
|
|
||||||
return nil // fast path
|
|
||||||
}
|
|
||||||
mu.Lock()
|
|
||||||
defer mu.Unlock()
|
|
||||||
return encodeExtensionsMap(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// encode encodes any unmarshaled (unencoded) extensions in e.
|
|
||||||
func encodeExtensionsMap(m map[int32]Extension) error {
|
|
||||||
for k, e := range m {
|
|
||||||
if e.value == nil || e.desc == nil {
|
|
||||||
// Extension is only in its encoded form.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't skip extensions that have an encoded form set,
|
|
||||||
// because the extension value may have been mutated after
|
|
||||||
// the last time this function was called.
|
|
||||||
|
|
||||||
et := reflect.TypeOf(e.desc.ExtensionType)
|
|
||||||
props := extensionProperties(e.desc)
|
|
||||||
|
|
||||||
p := NewBuffer(nil)
|
|
||||||
// If e.value has type T, the encoder expects a *struct{ X T }.
|
|
||||||
// Pass a *T with a zero field and hope it all works out.
|
|
||||||
x := reflect.New(et)
|
|
||||||
x.Elem().Set(reflect.ValueOf(e.value))
|
|
||||||
if err := props.enc(p, props, toStructPointer(x)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
e.enc = p.buf
|
|
||||||
m[k] = e
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func extensionsSize(e *XXX_InternalExtensions) (n int) {
|
|
||||||
m, mu := e.extensionsRead()
|
|
||||||
if m == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
mu.Lock()
|
|
||||||
defer mu.Unlock()
|
|
||||||
return extensionsMapSize(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func extensionsMapSize(m map[int32]Extension) (n int) {
|
|
||||||
for _, e := range m {
|
|
||||||
if e.value == nil || e.desc == nil {
|
|
||||||
// Extension is only in its encoded form.
|
|
||||||
n += len(e.enc)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't skip extensions that have an encoded form set,
|
|
||||||
// because the extension value may have been mutated after
|
|
||||||
// the last time this function was called.
|
|
||||||
|
|
||||||
et := reflect.TypeOf(e.desc.ExtensionType)
|
|
||||||
props := extensionProperties(e.desc)
|
|
||||||
|
|
||||||
// If e.value has type T, the encoder expects a *struct{ X T }.
|
|
||||||
// Pass a *T with a zero field and hope it all works out.
|
|
||||||
x := reflect.New(et)
|
|
||||||
x.Elem().Set(reflect.ValueOf(e.value))
|
|
||||||
n += props.size(props, toStructPointer(x))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// HasExtension returns whether the given extension is present in pb.
|
// HasExtension returns whether the given extension is present in pb.
|
||||||
func HasExtension(pb Message, extension *ExtensionDesc) bool {
|
func HasExtension(pb Message, extension *ExtensionDesc) bool {
|
||||||
if epb, doki := pb.(extensionsBytes); doki {
|
if epb, doki := pb.(extensionsBytes); doki {
|
||||||
@@ -366,8 +297,8 @@ func HasExtension(pb Message, extension *ExtensionDesc) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// TODO: Check types, field numbers, etc.?
|
// TODO: Check types, field numbers, etc.?
|
||||||
epb, ok := extendable(pb)
|
epb, err := extendable(pb)
|
||||||
if !ok {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
extmap, mu := epb.extensionsRead()
|
extmap, mu := epb.extensionsRead()
|
||||||
@@ -375,46 +306,26 @@ func HasExtension(pb Message, extension *ExtensionDesc) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
_, ok = extmap[extension.Field]
|
_, ok := extmap[extension.Field]
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int {
|
|
||||||
ext := pb.GetExtensions()
|
|
||||||
for offset < len(*ext) {
|
|
||||||
tag, n1 := DecodeVarint((*ext)[offset:])
|
|
||||||
fieldNum := int32(tag >> 3)
|
|
||||||
wireType := int(tag & 0x7)
|
|
||||||
n2, err := size((*ext)[offset+n1:], wireType)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
newOffset := offset + n1 + n2
|
|
||||||
if fieldNum == theFieldNum {
|
|
||||||
*ext = append((*ext)[:offset], (*ext)[newOffset:]...)
|
|
||||||
return offset
|
|
||||||
}
|
|
||||||
offset = newOffset
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearExtension removes the given extension from pb.
|
// ClearExtension removes the given extension from pb.
|
||||||
func ClearExtension(pb Message, extension *ExtensionDesc) {
|
func ClearExtension(pb Message, extension *ExtensionDesc) {
|
||||||
clearExtension(pb, extension.Field)
|
clearExtension(pb, extension.Field)
|
||||||
}
|
}
|
||||||
|
|
||||||
func clearExtension(pb Message, fieldNum int32) {
|
func clearExtension(pb Message, fieldNum int32) {
|
||||||
if epb, doki := pb.(extensionsBytes); doki {
|
if epb, ok := pb.(extensionsBytes); ok {
|
||||||
offset := 0
|
offset := 0
|
||||||
for offset != -1 {
|
for offset != -1 {
|
||||||
offset = deleteExtension(epb, fieldNum, offset)
|
offset = deleteExtension(epb, fieldNum, offset)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
epb, ok := extendable(pb)
|
epb, err := extendable(pb)
|
||||||
if !ok {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// TODO: Check types, field numbers, etc.?
|
// TODO: Check types, field numbers, etc.?
|
||||||
@@ -422,39 +333,33 @@ func clearExtension(pb Message, fieldNum int32) {
|
|||||||
delete(extmap, fieldNum)
|
delete(extmap, fieldNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetExtension parses and returns the given extension of pb.
|
// GetExtension retrieves a proto2 extended field from pb.
|
||||||
// If the extension is not present and has no default value it returns ErrMissingExtension.
|
//
|
||||||
|
// If the descriptor is type complete (i.e., ExtensionDesc.ExtensionType is non-nil),
|
||||||
|
// then GetExtension parses the encoded field and returns a Go value of the specified type.
|
||||||
|
// If the field is not present, then the default value is returned (if one is specified),
|
||||||
|
// otherwise ErrMissingExtension is reported.
|
||||||
|
//
|
||||||
|
// If the descriptor is not type complete (i.e., ExtensionDesc.ExtensionType is nil),
|
||||||
|
// then GetExtension returns the raw encoded bytes of the field extension.
|
||||||
func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
|
func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
|
||||||
if epb, doki := pb.(extensionsBytes); doki {
|
if epb, doki := pb.(extensionsBytes); doki {
|
||||||
ext := epb.GetExtensions()
|
ext := epb.GetExtensions()
|
||||||
o := 0
|
return decodeExtensionFromBytes(extension, *ext)
|
||||||
for o < len(*ext) {
|
|
||||||
tag, n := DecodeVarint((*ext)[o:])
|
|
||||||
fieldNum := int32(tag >> 3)
|
|
||||||
wireType := int(tag & 0x7)
|
|
||||||
l, err := size((*ext)[o+n:], wireType)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if int32(fieldNum) == extension.Field {
|
|
||||||
v, err := decodeExtension((*ext)[o:o+n+l], extension)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
o += n + l
|
|
||||||
}
|
|
||||||
return defaultExtensionValue(extension)
|
|
||||||
}
|
}
|
||||||
epb, ok := extendable(pb)
|
|
||||||
if !ok {
|
epb, err := extendable(pb)
|
||||||
return nil, errors.New("proto: not an extendable proto")
|
if err != nil {
|
||||||
}
|
|
||||||
if err := checkExtensionTypes(epb, extension); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if extension.ExtendedType != nil {
|
||||||
|
// can only check type if this is a complete descriptor
|
||||||
|
if cerr := checkExtensionTypes(epb, extension); cerr != nil {
|
||||||
|
return nil, cerr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
emap, mu := epb.extensionsRead()
|
emap, mu := epb.extensionsRead()
|
||||||
if emap == nil {
|
if emap == nil {
|
||||||
return defaultExtensionValue(extension)
|
return defaultExtensionValue(extension)
|
||||||
@@ -479,6 +384,11 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
|
|||||||
return e.value, nil
|
return e.value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if extension.ExtensionType == nil {
|
||||||
|
// incomplete descriptor
|
||||||
|
return e.enc, nil
|
||||||
|
}
|
||||||
|
|
||||||
v, err := decodeExtension(e.enc, extension)
|
v, err := decodeExtension(e.enc, extension)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -496,6 +406,11 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
|
|||||||
// defaultExtensionValue returns the default value for extension.
|
// defaultExtensionValue returns the default value for extension.
|
||||||
// If no default for an extension is defined ErrMissingExtension is returned.
|
// If no default for an extension is defined ErrMissingExtension is returned.
|
||||||
func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {
|
func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {
|
||||||
|
if extension.ExtensionType == nil {
|
||||||
|
// incomplete descriptor, so no default
|
||||||
|
return nil, ErrMissingExtension
|
||||||
|
}
|
||||||
|
|
||||||
t := reflect.TypeOf(extension.ExtensionType)
|
t := reflect.TypeOf(extension.ExtensionType)
|
||||||
props := extensionProperties(extension)
|
props := extensionProperties(extension)
|
||||||
|
|
||||||
@@ -530,31 +445,28 @@ func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {
|
|||||||
|
|
||||||
// decodeExtension decodes an extension encoded in b.
|
// decodeExtension decodes an extension encoded in b.
|
||||||
func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) {
|
func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) {
|
||||||
o := NewBuffer(b)
|
|
||||||
|
|
||||||
t := reflect.TypeOf(extension.ExtensionType)
|
t := reflect.TypeOf(extension.ExtensionType)
|
||||||
|
unmarshal := typeUnmarshaler(t, extension.Tag)
|
||||||
props := extensionProperties(extension)
|
|
||||||
|
|
||||||
// t is a pointer to a struct, pointer to basic type or a slice.
|
// t is a pointer to a struct, pointer to basic type or a slice.
|
||||||
// Allocate a "field" to store the pointer/slice itself; the
|
// Allocate space to store the pointer/slice.
|
||||||
// pointer/slice will be stored here. We pass
|
|
||||||
// the address of this field to props.dec.
|
|
||||||
// This passes a zero field and a *t and lets props.dec
|
|
||||||
// interpret it as a *struct{ x t }.
|
|
||||||
value := reflect.New(t).Elem()
|
value := reflect.New(t).Elem()
|
||||||
|
|
||||||
|
var err error
|
||||||
for {
|
for {
|
||||||
// Discard wire type and field number varint. It isn't needed.
|
x, n := decodeVarint(b)
|
||||||
if _, err := o.DecodeVarint(); err != nil {
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
wire := int(x) & 7
|
||||||
|
|
||||||
|
b, err = unmarshal(b, valToPointer(value.Addr()), wire)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil {
|
if len(b) == 0 {
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if o.index >= len(o.buf) {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -564,9 +476,13 @@ func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) {
|
|||||||
// GetExtensions returns a slice of the extensions present in pb that are also listed in es.
|
// GetExtensions returns a slice of the extensions present in pb that are also listed in es.
|
||||||
// The returned slice has the same length as es; missing extensions will appear as nil elements.
|
// The returned slice has the same length as es; missing extensions will appear as nil elements.
|
||||||
func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) {
|
func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) {
|
||||||
|
epb, err := extendable(pb)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
extensions = make([]interface{}, len(es))
|
extensions = make([]interface{}, len(es))
|
||||||
for i, e := range es {
|
for i, e := range es {
|
||||||
extensions[i], err = GetExtension(pb, e)
|
extensions[i], err = GetExtension(epb, e)
|
||||||
if err == ErrMissingExtension {
|
if err == ErrMissingExtension {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
@@ -581,9 +497,9 @@ func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, e
|
|||||||
// For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing
|
// For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing
|
||||||
// just the Field field, which defines the extension's field number.
|
// just the Field field, which defines the extension's field number.
|
||||||
func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {
|
func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {
|
||||||
epb, ok := extendable(pb)
|
epb, err := extendable(pb)
|
||||||
if !ok {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("proto: %T is not an extendable proto.Message", pb)
|
return nil, err
|
||||||
}
|
}
|
||||||
registeredExtensions := RegisteredExtensions(pb)
|
registeredExtensions := RegisteredExtensions(pb)
|
||||||
|
|
||||||
@@ -610,23 +526,18 @@ func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {
|
|||||||
|
|
||||||
// SetExtension sets the specified extension of pb to the specified value.
|
// SetExtension sets the specified extension of pb to the specified value.
|
||||||
func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error {
|
func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error {
|
||||||
if epb, doki := pb.(extensionsBytes); doki {
|
if epb, ok := pb.(extensionsBytes); ok {
|
||||||
ClearExtension(pb, extension)
|
newb, err := encodeExtension(extension, value)
|
||||||
ext := epb.GetExtensions()
|
if err != nil {
|
||||||
et := reflect.TypeOf(extension.ExtensionType)
|
|
||||||
props := extensionProperties(extension)
|
|
||||||
p := NewBuffer(nil)
|
|
||||||
x := reflect.New(et)
|
|
||||||
x.Elem().Set(reflect.ValueOf(value))
|
|
||||||
if err := props.enc(p, props, toStructPointer(x)); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
*ext = append(*ext, p.buf...)
|
bb := epb.GetExtensions()
|
||||||
|
*bb = append(*bb, newb...)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
epb, ok := extendable(pb)
|
epb, err := extendable(pb)
|
||||||
if !ok {
|
if err != nil {
|
||||||
return errors.New("proto: not an extendable proto")
|
return err
|
||||||
}
|
}
|
||||||
if err := checkExtensionTypes(epb, extension); err != nil {
|
if err := checkExtensionTypes(epb, extension); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -656,8 +567,8 @@ func ClearAllExtensions(pb Message) {
|
|||||||
*ext = []byte{}
|
*ext = []byte{}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
epb, ok := extendable(pb)
|
epb, err := extendable(pb)
|
||||||
if !ok {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m := epb.extensionsWrite()
|
m := epb.extensionsWrite()
|
||||||
|
|||||||
+118
-44
@@ -32,12 +32,36 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type extensionsBytes interface {
|
||||||
|
Message
|
||||||
|
ExtensionRangeArray() []ExtensionRange
|
||||||
|
GetExtensions() *[]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type slowExtensionAdapter struct {
|
||||||
|
extensionsBytes
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s slowExtensionAdapter) extensionsWrite() map[int32]Extension {
|
||||||
|
panic("Please report a bug to github.com/gogo/protobuf if you see this message: Writing extensions is not supported for extensions stored in a byte slice field.")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s slowExtensionAdapter) extensionsRead() (map[int32]Extension, sync.Locker) {
|
||||||
|
b := s.GetExtensions()
|
||||||
|
m, err := BytesToExtensionsMap(*b)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return m, notLocker{}
|
||||||
|
}
|
||||||
|
|
||||||
func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool {
|
func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool {
|
||||||
if reflect.ValueOf(pb).IsNil() {
|
if reflect.ValueOf(pb).IsNil() {
|
||||||
return ifnotset
|
return ifnotset
|
||||||
@@ -56,19 +80,28 @@ func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Extension) Equal(that *Extension) bool {
|
func (this *Extension) Equal(that *Extension) bool {
|
||||||
|
if err := this.Encode(); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if err := that.Encode(); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return bytes.Equal(this.enc, that.enc)
|
return bytes.Equal(this.enc, that.enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Extension) Compare(that *Extension) int {
|
func (this *Extension) Compare(that *Extension) int {
|
||||||
|
if err := this.Encode(); err != nil {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if err := that.Encode(); err != nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
return bytes.Compare(this.enc, that.enc)
|
return bytes.Compare(this.enc, that.enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SizeOfInternalExtension(m extendableProto) (n int) {
|
func SizeOfInternalExtension(m extendableProto) (n int) {
|
||||||
return SizeOfExtensionMap(m.extensionsWrite())
|
info := getMarshalInfo(reflect.TypeOf(m))
|
||||||
}
|
return info.sizeV1Extensions(m.extensionsWrite())
|
||||||
|
|
||||||
func SizeOfExtensionMap(m map[int32]Extension) (n int) {
|
|
||||||
return extensionsMapSize(m)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type sortableMapElem struct {
|
type sortableMapElem struct {
|
||||||
@@ -122,28 +155,26 @@ func EncodeInternalExtension(m extendableProto, data []byte) (n int, err error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) {
|
func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) {
|
||||||
if err := encodeExtensionsMap(m); err != nil {
|
o := 0
|
||||||
return 0, err
|
for _, e := range m {
|
||||||
|
if err := e.Encode(); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
n := copy(data[o:], e.enc)
|
||||||
|
if n != len(e.enc) {
|
||||||
|
return 0, io.ErrShortBuffer
|
||||||
|
}
|
||||||
|
o += n
|
||||||
}
|
}
|
||||||
keys := make([]int, 0, len(m))
|
return o, nil
|
||||||
for k := range m {
|
|
||||||
keys = append(keys, int(k))
|
|
||||||
}
|
|
||||||
sort.Ints(keys)
|
|
||||||
for _, k := range keys {
|
|
||||||
n += copy(data[n:], m[int32(k)].enc)
|
|
||||||
}
|
|
||||||
return n, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) {
|
func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) {
|
||||||
if m[id].value == nil || m[id].desc == nil {
|
e := m[id]
|
||||||
return m[id].enc, nil
|
if err := e.Encode(); err != nil {
|
||||||
}
|
|
||||||
if err := encodeExtensionsMap(m); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return m[id].enc, nil
|
return e.enc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func size(buf []byte, wire int) (int, error) {
|
func size(buf []byte, wire int) (int, error) {
|
||||||
@@ -218,35 +249,58 @@ func AppendExtension(e Message, tag int32, buf []byte) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeExtension(e *Extension) error {
|
func encodeExtension(extension *ExtensionDesc, value interface{}) ([]byte, error) {
|
||||||
if e.value == nil || e.desc == nil {
|
u := getMarshalInfo(reflect.TypeOf(extension.ExtendedType))
|
||||||
// Extension is only in its encoded form.
|
ei := u.getExtElemInfo(extension)
|
||||||
return nil
|
v := value
|
||||||
}
|
p := toAddrPointer(&v, ei.isptr)
|
||||||
// We don't skip extensions that have an encoded form set,
|
siz := ei.sizer(p, SizeVarint(ei.wiretag))
|
||||||
// because the extension value may have been mutated after
|
buf := make([]byte, 0, siz)
|
||||||
// the last time this function was called.
|
return ei.marshaler(buf, p, ei.wiretag, false)
|
||||||
|
}
|
||||||
|
|
||||||
et := reflect.TypeOf(e.desc.ExtensionType)
|
func decodeExtensionFromBytes(extension *ExtensionDesc, buf []byte) (interface{}, error) {
|
||||||
props := extensionProperties(e.desc)
|
o := 0
|
||||||
|
for o < len(buf) {
|
||||||
p := NewBuffer(nil)
|
tag, n := DecodeVarint((buf)[o:])
|
||||||
// If e.value has type T, the encoder expects a *struct{ X T }.
|
fieldNum := int32(tag >> 3)
|
||||||
// Pass a *T with a zero field and hope it all works out.
|
wireType := int(tag & 0x7)
|
||||||
x := reflect.New(et)
|
if o+n > len(buf) {
|
||||||
x.Elem().Set(reflect.ValueOf(e.value))
|
return nil, fmt.Errorf("unable to decode extension")
|
||||||
if err := props.enc(p, props, toStructPointer(x)); err != nil {
|
}
|
||||||
return err
|
l, err := size((buf)[o+n:], wireType)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if int32(fieldNum) == extension.Field {
|
||||||
|
if o+n+l > len(buf) {
|
||||||
|
return nil, fmt.Errorf("unable to decode extension")
|
||||||
|
}
|
||||||
|
v, err := decodeExtension((buf)[o:o+n+l], extension)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
o += n + l
|
||||||
|
}
|
||||||
|
return defaultExtensionValue(extension)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Extension) Encode() error {
|
||||||
|
if this.enc == nil {
|
||||||
|
var err error
|
||||||
|
this.enc, err = encodeExtension(this.desc, this.value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
e.enc = p.buf
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Extension) GoString() string {
|
func (this Extension) GoString() string {
|
||||||
if this.enc == nil {
|
if err := this.Encode(); err != nil {
|
||||||
if err := encodeExtension(&this); err != nil {
|
return fmt.Sprintf("error encoding extension: %v", err)
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("proto.NewExtension(%#v)", this.enc)
|
return fmt.Sprintf("proto.NewExtension(%#v)", this.enc)
|
||||||
}
|
}
|
||||||
@@ -292,3 +346,23 @@ func GetUnsafeExtensionsMap(extendable Message) map[int32]Extension {
|
|||||||
pb := extendable.(extendableProto)
|
pb := extendable.(extendableProto)
|
||||||
return pb.extensionsWrite()
|
return pb.extensionsWrite()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int {
|
||||||
|
ext := pb.GetExtensions()
|
||||||
|
for offset < len(*ext) {
|
||||||
|
tag, n1 := DecodeVarint((*ext)[offset:])
|
||||||
|
fieldNum := int32(tag >> 3)
|
||||||
|
wireType := int(tag & 0x7)
|
||||||
|
n2, err := size((*ext)[offset+n1:], wireType)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
newOffset := offset + n1 + n2
|
||||||
|
if fieldNum == theFieldNum {
|
||||||
|
*ext = append((*ext)[:offset], (*ext)[newOffset:]...)
|
||||||
|
return offset
|
||||||
|
}
|
||||||
|
offset = newOffset
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|||||||
+118
-28
@@ -273,6 +273,67 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RequiredNotSetError is an error type returned by either Marshal or Unmarshal.
|
||||||
|
// Marshal reports this when a required field is not initialized.
|
||||||
|
// Unmarshal reports this when a required field is missing from the wire data.
|
||||||
|
type RequiredNotSetError struct{ field string }
|
||||||
|
|
||||||
|
func (e *RequiredNotSetError) Error() string {
|
||||||
|
if e.field == "" {
|
||||||
|
return fmt.Sprintf("proto: required field not set")
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("proto: required field %q not set", e.field)
|
||||||
|
}
|
||||||
|
func (e *RequiredNotSetError) RequiredNotSet() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
type invalidUTF8Error struct{ field string }
|
||||||
|
|
||||||
|
func (e *invalidUTF8Error) Error() string {
|
||||||
|
if e.field == "" {
|
||||||
|
return "proto: invalid UTF-8 detected"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("proto: field %q contains invalid UTF-8", e.field)
|
||||||
|
}
|
||||||
|
func (e *invalidUTF8Error) InvalidUTF8() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// errInvalidUTF8 is a sentinel error to identify fields with invalid UTF-8.
|
||||||
|
// This error should not be exposed to the external API as such errors should
|
||||||
|
// be recreated with the field information.
|
||||||
|
var errInvalidUTF8 = &invalidUTF8Error{}
|
||||||
|
|
||||||
|
// isNonFatal reports whether the error is either a RequiredNotSet error
|
||||||
|
// or a InvalidUTF8 error.
|
||||||
|
func isNonFatal(err error) bool {
|
||||||
|
if re, ok := err.(interface{ RequiredNotSet() bool }); ok && re.RequiredNotSet() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if re, ok := err.(interface{ InvalidUTF8() bool }); ok && re.InvalidUTF8() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type nonFatal struct{ E error }
|
||||||
|
|
||||||
|
// Merge merges err into nf and reports whether it was successful.
|
||||||
|
// Otherwise it returns false for any fatal non-nil errors.
|
||||||
|
func (nf *nonFatal) Merge(err error) (ok bool) {
|
||||||
|
if err == nil {
|
||||||
|
return true // not an error
|
||||||
|
}
|
||||||
|
if !isNonFatal(err) {
|
||||||
|
return false // fatal error
|
||||||
|
}
|
||||||
|
if nf.E == nil {
|
||||||
|
nf.E = err // store first instance of non-fatal error
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Message is implemented by generated protocol buffer messages.
|
// Message is implemented by generated protocol buffer messages.
|
||||||
type Message interface {
|
type Message interface {
|
||||||
Reset()
|
Reset()
|
||||||
@@ -309,16 +370,7 @@ type Buffer struct {
|
|||||||
buf []byte // encode/decode byte stream
|
buf []byte // encode/decode byte stream
|
||||||
index int // read point
|
index int // read point
|
||||||
|
|
||||||
// pools of basic types to amortize allocation.
|
deterministic bool
|
||||||
bools []bool
|
|
||||||
uint32s []uint32
|
|
||||||
uint64s []uint64
|
|
||||||
|
|
||||||
// extra pools, only used with pointer_reflect.go
|
|
||||||
int32s []int32
|
|
||||||
int64s []int64
|
|
||||||
float32s []float32
|
|
||||||
float64s []float64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBuffer allocates a new Buffer and initializes its internal data to
|
// NewBuffer allocates a new Buffer and initializes its internal data to
|
||||||
@@ -343,6 +395,30 @@ func (p *Buffer) SetBuf(s []byte) {
|
|||||||
// Bytes returns the contents of the Buffer.
|
// Bytes returns the contents of the Buffer.
|
||||||
func (p *Buffer) Bytes() []byte { return p.buf }
|
func (p *Buffer) Bytes() []byte { return p.buf }
|
||||||
|
|
||||||
|
// SetDeterministic sets whether to use deterministic serialization.
|
||||||
|
//
|
||||||
|
// Deterministic serialization guarantees that for a given binary, equal
|
||||||
|
// messages will always be serialized to the same bytes. This implies:
|
||||||
|
//
|
||||||
|
// - Repeated serialization of a message will return the same bytes.
|
||||||
|
// - Different processes of the same binary (which may be executing on
|
||||||
|
// different machines) will serialize equal messages to the same bytes.
|
||||||
|
//
|
||||||
|
// Note that the deterministic serialization is NOT canonical across
|
||||||
|
// languages. It is not guaranteed to remain stable over time. It is unstable
|
||||||
|
// across different builds with schema changes due to unknown fields.
|
||||||
|
// Users who need canonical serialization (e.g., persistent storage in a
|
||||||
|
// canonical form, fingerprinting, etc.) should define their own
|
||||||
|
// canonicalization specification and implement their own serializer rather
|
||||||
|
// than relying on this API.
|
||||||
|
//
|
||||||
|
// If deterministic serialization is requested, map entries will be sorted
|
||||||
|
// by keys in lexographical order. This is an implementation detail and
|
||||||
|
// subject to change.
|
||||||
|
func (p *Buffer) SetDeterministic(deterministic bool) {
|
||||||
|
p.deterministic = deterministic
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper routines for simplifying the creation of optional fields of basic type.
|
* Helper routines for simplifying the creation of optional fields of basic type.
|
||||||
*/
|
*/
|
||||||
@@ -552,9 +628,11 @@ func SetDefaults(pb Message) {
|
|||||||
setDefaults(reflect.ValueOf(pb), true, false)
|
setDefaults(reflect.ValueOf(pb), true, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// v is a pointer to a struct.
|
// v is a struct.
|
||||||
func setDefaults(v reflect.Value, recur, zeros bool) {
|
func setDefaults(v reflect.Value, recur, zeros bool) {
|
||||||
v = v.Elem()
|
if v.Kind() == reflect.Ptr {
|
||||||
|
v = v.Elem()
|
||||||
|
}
|
||||||
|
|
||||||
defaultMu.RLock()
|
defaultMu.RLock()
|
||||||
dm, ok := defaults[v.Type()]
|
dm, ok := defaults[v.Type()]
|
||||||
@@ -656,8 +734,11 @@ func setDefaults(v reflect.Value, recur, zeros bool) {
|
|||||||
|
|
||||||
for _, ni := range dm.nested {
|
for _, ni := range dm.nested {
|
||||||
f := v.Field(ni)
|
f := v.Field(ni)
|
||||||
// f is *T or []*T or map[T]*T
|
// f is *T or T or []*T or []T
|
||||||
switch f.Kind() {
|
switch f.Kind() {
|
||||||
|
case reflect.Struct:
|
||||||
|
setDefaults(f, recur, zeros)
|
||||||
|
|
||||||
case reflect.Ptr:
|
case reflect.Ptr:
|
||||||
if f.IsNil() {
|
if f.IsNil() {
|
||||||
continue
|
continue
|
||||||
@@ -667,7 +748,7 @@ func setDefaults(v reflect.Value, recur, zeros bool) {
|
|||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
for i := 0; i < f.Len(); i++ {
|
for i := 0; i < f.Len(); i++ {
|
||||||
e := f.Index(i)
|
e := f.Index(i)
|
||||||
if e.IsNil() {
|
if e.Kind() == reflect.Ptr && e.IsNil() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
setDefaults(e, recur, zeros)
|
setDefaults(e, recur, zeros)
|
||||||
@@ -739,6 +820,9 @@ func buildDefaultMessage(t reflect.Type) (dm defaultMessage) {
|
|||||||
func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) {
|
func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) {
|
||||||
var canHaveDefault bool
|
var canHaveDefault bool
|
||||||
switch ft.Kind() {
|
switch ft.Kind() {
|
||||||
|
case reflect.Struct:
|
||||||
|
nestedMessage = true // non-nullable
|
||||||
|
|
||||||
case reflect.Ptr:
|
case reflect.Ptr:
|
||||||
if ft.Elem().Kind() == reflect.Struct {
|
if ft.Elem().Kind() == reflect.Struct {
|
||||||
nestedMessage = true
|
nestedMessage = true
|
||||||
@@ -748,7 +832,7 @@ func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMes
|
|||||||
|
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
switch ft.Elem().Kind() {
|
switch ft.Elem().Kind() {
|
||||||
case reflect.Ptr:
|
case reflect.Ptr, reflect.Struct:
|
||||||
nestedMessage = true // repeated message
|
nestedMessage = true // repeated message
|
||||||
case reflect.Uint8:
|
case reflect.Uint8:
|
||||||
canHaveDefault = true // bytes field
|
canHaveDefault = true // bytes field
|
||||||
@@ -831,22 +915,12 @@ func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMes
|
|||||||
return sf, false, nil
|
return sf, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mapKeys returns a sort.Interface to be used for sorting the map keys.
|
||||||
// Map fields may have key types of non-float scalars, strings and enums.
|
// Map fields may have key types of non-float scalars, strings and enums.
|
||||||
// The easiest way to sort them in some deterministic order is to use fmt.
|
|
||||||
// If this turns out to be inefficient we can always consider other options,
|
|
||||||
// such as doing a Schwartzian transform.
|
|
||||||
|
|
||||||
func mapKeys(vs []reflect.Value) sort.Interface {
|
func mapKeys(vs []reflect.Value) sort.Interface {
|
||||||
s := mapKeySorter{
|
s := mapKeySorter{vs: vs}
|
||||||
vs: vs,
|
|
||||||
// default Less function: textual comparison
|
|
||||||
less: func(a, b reflect.Value) bool {
|
|
||||||
return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface())
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps;
|
// Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps.
|
||||||
// numeric keys are sorted numerically.
|
|
||||||
if len(vs) == 0 {
|
if len(vs) == 0 {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@@ -855,6 +929,12 @@ func mapKeys(vs []reflect.Value) sort.Interface {
|
|||||||
s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() }
|
s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() }
|
||||||
case reflect.Uint32, reflect.Uint64:
|
case reflect.Uint32, reflect.Uint64:
|
||||||
s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() }
|
s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() }
|
||||||
|
case reflect.Bool:
|
||||||
|
s.less = func(a, b reflect.Value) bool { return !a.Bool() && b.Bool() } // false < true
|
||||||
|
case reflect.String:
|
||||||
|
s.less = func(a, b reflect.Value) bool { return a.String() < b.String() }
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("unsupported map key type: %v", vs[0].Kind()))
|
||||||
}
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
@@ -895,3 +975,13 @@ const GoGoProtoPackageIsVersion2 = true
|
|||||||
// ProtoPackageIsVersion1 is referenced from generated protocol buffer files
|
// ProtoPackageIsVersion1 is referenced from generated protocol buffer files
|
||||||
// to assert that that code is compatible with this version of the proto package.
|
// to assert that that code is compatible with this version of the proto package.
|
||||||
const GoGoProtoPackageIsVersion1 = true
|
const GoGoProtoPackageIsVersion1 = true
|
||||||
|
|
||||||
|
// InternalMessageInfo is a type used internally by generated .pb.go files.
|
||||||
|
// This type is not intended to be used by non-generated code.
|
||||||
|
// This type is not subject to any compatibility guarantee.
|
||||||
|
type InternalMessageInfo struct {
|
||||||
|
marshal *marshalInfo
|
||||||
|
unmarshal *unmarshalInfo
|
||||||
|
merge *mergeInfo
|
||||||
|
discard *discardInfo
|
||||||
|
}
|
||||||
|
|||||||
+8
@@ -33,6 +33,14 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Sizer interface {
|
||||||
|
Size() int
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProtoSizer interface {
|
||||||
|
ProtoSize() int
|
||||||
|
}
|
||||||
|
|
||||||
func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) {
|
func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) {
|
||||||
s, ok := m[value]
|
s, ok := m[value]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
+42
-39
@@ -42,6 +42,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID.
|
// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID.
|
||||||
@@ -94,10 +95,7 @@ func (ms *messageSet) find(pb Message) *_MessageSet_Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ms *messageSet) Has(pb Message) bool {
|
func (ms *messageSet) Has(pb Message) bool {
|
||||||
if ms.find(pb) != nil {
|
return ms.find(pb) != nil
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ms *messageSet) Unmarshal(pb Message) error {
|
func (ms *messageSet) Unmarshal(pb Message) error {
|
||||||
@@ -150,46 +148,42 @@ func skipVarint(buf []byte) []byte {
|
|||||||
// MarshalMessageSet encodes the extension map represented by m in the message set wire format.
|
// MarshalMessageSet encodes the extension map represented by m in the message set wire format.
|
||||||
// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option.
|
// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option.
|
||||||
func MarshalMessageSet(exts interface{}) ([]byte, error) {
|
func MarshalMessageSet(exts interface{}) ([]byte, error) {
|
||||||
var m map[int32]Extension
|
return marshalMessageSet(exts, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// marshaMessageSet implements above function, with the opt to turn on / off deterministic during Marshal.
|
||||||
|
func marshalMessageSet(exts interface{}, deterministic bool) ([]byte, error) {
|
||||||
switch exts := exts.(type) {
|
switch exts := exts.(type) {
|
||||||
case *XXX_InternalExtensions:
|
case *XXX_InternalExtensions:
|
||||||
if err := encodeExtensions(exts); err != nil {
|
var u marshalInfo
|
||||||
return nil, err
|
siz := u.sizeMessageSet(exts)
|
||||||
}
|
b := make([]byte, 0, siz)
|
||||||
m, _ = exts.extensionsRead()
|
return u.appendMessageSet(b, exts, deterministic)
|
||||||
|
|
||||||
case map[int32]Extension:
|
case map[int32]Extension:
|
||||||
if err := encodeExtensionsMap(exts); err != nil {
|
// This is an old-style extension map.
|
||||||
return nil, err
|
// Wrap it in a new-style XXX_InternalExtensions.
|
||||||
|
ie := XXX_InternalExtensions{
|
||||||
|
p: &struct {
|
||||||
|
mu sync.Mutex
|
||||||
|
extensionMap map[int32]Extension
|
||||||
|
}{
|
||||||
|
extensionMap: exts,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
m = exts
|
|
||||||
|
var u marshalInfo
|
||||||
|
siz := u.sizeMessageSet(&ie)
|
||||||
|
b := make([]byte, 0, siz)
|
||||||
|
return u.appendMessageSet(b, &ie, deterministic)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("proto: not an extension map")
|
return nil, errors.New("proto: not an extension map")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort extension IDs to provide a deterministic encoding.
|
|
||||||
// See also enc_map in encode.go.
|
|
||||||
ids := make([]int, 0, len(m))
|
|
||||||
for id := range m {
|
|
||||||
ids = append(ids, int(id))
|
|
||||||
}
|
|
||||||
sort.Ints(ids)
|
|
||||||
|
|
||||||
ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))}
|
|
||||||
for _, id := range ids {
|
|
||||||
e := m[int32(id)]
|
|
||||||
// Remove the wire type and field number varint, as well as the length varint.
|
|
||||||
msg := skipVarint(skipVarint(e.enc))
|
|
||||||
|
|
||||||
ms.Item = append(ms.Item, &_MessageSet_Item{
|
|
||||||
TypeId: Int32(int32(id)),
|
|
||||||
Message: msg,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return Marshal(ms)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format.
|
// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format.
|
||||||
// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option.
|
// It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option.
|
||||||
func UnmarshalMessageSet(buf []byte, exts interface{}) error {
|
func UnmarshalMessageSet(buf []byte, exts interface{}) error {
|
||||||
var m map[int32]Extension
|
var m map[int32]Extension
|
||||||
switch exts := exts.(type) {
|
switch exts := exts.(type) {
|
||||||
@@ -235,7 +229,15 @@ func MarshalMessageSetJSON(exts interface{}) ([]byte, error) {
|
|||||||
var m map[int32]Extension
|
var m map[int32]Extension
|
||||||
switch exts := exts.(type) {
|
switch exts := exts.(type) {
|
||||||
case *XXX_InternalExtensions:
|
case *XXX_InternalExtensions:
|
||||||
m, _ = exts.extensionsRead()
|
var mu sync.Locker
|
||||||
|
m, mu = exts.extensionsRead()
|
||||||
|
if m != nil {
|
||||||
|
// Keep the extensions map locked until we're done marshaling to prevent
|
||||||
|
// races between marshaling and unmarshaling the lazily-{en,de}coded
|
||||||
|
// values.
|
||||||
|
mu.Lock()
|
||||||
|
defer mu.Unlock()
|
||||||
|
}
|
||||||
case map[int32]Extension:
|
case map[int32]Extension:
|
||||||
m = exts
|
m = exts
|
||||||
default:
|
default:
|
||||||
@@ -253,15 +255,16 @@ func MarshalMessageSetJSON(exts interface{}) ([]byte, error) {
|
|||||||
|
|
||||||
for i, id := range ids {
|
for i, id := range ids {
|
||||||
ext := m[id]
|
ext := m[id]
|
||||||
if i > 0 {
|
|
||||||
b.WriteByte(',')
|
|
||||||
}
|
|
||||||
|
|
||||||
msd, ok := messageSetMap[id]
|
msd, ok := messageSetMap[id]
|
||||||
if !ok {
|
if !ok {
|
||||||
// Unknown type; we can't render it, so skip it.
|
// Unknown type; we can't render it, so skip it.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if i > 0 && b.Len() > 1 {
|
||||||
|
b.WriteByte(',')
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Fprintf(&b, `"[%s]":`, msd.name)
|
fmt.Fprintf(&b, `"[%s]":`, msd.name)
|
||||||
|
|
||||||
x := ext.value
|
x := ext.value
|
||||||
|
|||||||
+259
-386
@@ -29,7 +29,7 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// +build appengine js
|
// +build purego appengine js
|
||||||
|
|
||||||
// This file contains an implementation of proto field accesses using package reflect.
|
// This file contains an implementation of proto field accesses using package reflect.
|
||||||
// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can
|
// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can
|
||||||
@@ -38,32 +38,13 @@
|
|||||||
package proto
|
package proto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A structPointer is a pointer to a struct.
|
const unsafeAllowed = false
|
||||||
type structPointer struct {
|
|
||||||
v reflect.Value
|
|
||||||
}
|
|
||||||
|
|
||||||
// toStructPointer returns a structPointer equivalent to the given reflect value.
|
// A field identifies a field in a struct, accessible from a pointer.
|
||||||
// The reflect value must itself be a pointer to a struct.
|
|
||||||
func toStructPointer(v reflect.Value) structPointer {
|
|
||||||
return structPointer{v}
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsNil reports whether p is nil.
|
|
||||||
func structPointer_IsNil(p structPointer) bool {
|
|
||||||
return p.v.IsNil()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interface returns the struct pointer as an interface value.
|
|
||||||
func structPointer_Interface(p structPointer, _ reflect.Type) interface{} {
|
|
||||||
return p.v.Interface()
|
|
||||||
}
|
|
||||||
|
|
||||||
// A field identifies a field in a struct, accessible from a structPointer.
|
|
||||||
// In this implementation, a field is identified by the sequence of field indices
|
// In this implementation, a field is identified by the sequence of field indices
|
||||||
// passed to reflect's FieldByIndex.
|
// passed to reflect's FieldByIndex.
|
||||||
type field []int
|
type field []int
|
||||||
@@ -76,409 +57,301 @@ func toField(f *reflect.StructField) field {
|
|||||||
// invalidField is an invalid field identifier.
|
// invalidField is an invalid field identifier.
|
||||||
var invalidField = field(nil)
|
var invalidField = field(nil)
|
||||||
|
|
||||||
|
// zeroField is a noop when calling pointer.offset.
|
||||||
|
var zeroField = field([]int{})
|
||||||
|
|
||||||
// IsValid reports whether the field identifier is valid.
|
// IsValid reports whether the field identifier is valid.
|
||||||
func (f field) IsValid() bool { return f != nil }
|
func (f field) IsValid() bool { return f != nil }
|
||||||
|
|
||||||
// field returns the given field in the struct as a reflect value.
|
// The pointer type is for the table-driven decoder.
|
||||||
func structPointer_field(p structPointer, f field) reflect.Value {
|
// The implementation here uses a reflect.Value of pointer type to
|
||||||
// Special case: an extension map entry with a value of type T
|
// create a generic pointer. In pointer_unsafe.go we use unsafe
|
||||||
// passes a *T to the struct-handling code with a zero field,
|
// instead of reflect to implement the same (but faster) interface.
|
||||||
// expecting that it will be treated as equivalent to *struct{ X T },
|
type pointer struct {
|
||||||
// which has the same memory layout. We have to handle that case
|
|
||||||
// specially, because reflect will panic if we call FieldByIndex on a
|
|
||||||
// non-struct.
|
|
||||||
if f == nil {
|
|
||||||
return p.v.Elem()
|
|
||||||
}
|
|
||||||
|
|
||||||
return p.v.Elem().FieldByIndex(f)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ifield returns the given field in the struct as an interface value.
|
|
||||||
func structPointer_ifield(p structPointer, f field) interface{} {
|
|
||||||
return structPointer_field(p, f).Addr().Interface()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bytes returns the address of a []byte field in the struct.
|
|
||||||
func structPointer_Bytes(p structPointer, f field) *[]byte {
|
|
||||||
return structPointer_ifield(p, f).(*[]byte)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BytesSlice returns the address of a [][]byte field in the struct.
|
|
||||||
func structPointer_BytesSlice(p structPointer, f field) *[][]byte {
|
|
||||||
return structPointer_ifield(p, f).(*[][]byte)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns the address of a *bool field in the struct.
|
|
||||||
func structPointer_Bool(p structPointer, f field) **bool {
|
|
||||||
return structPointer_ifield(p, f).(**bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolVal returns the address of a bool field in the struct.
|
|
||||||
func structPointer_BoolVal(p structPointer, f field) *bool {
|
|
||||||
return structPointer_ifield(p, f).(*bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolSlice returns the address of a []bool field in the struct.
|
|
||||||
func structPointer_BoolSlice(p structPointer, f field) *[]bool {
|
|
||||||
return structPointer_ifield(p, f).(*[]bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns the address of a *string field in the struct.
|
|
||||||
func structPointer_String(p structPointer, f field) **string {
|
|
||||||
return structPointer_ifield(p, f).(**string)
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringVal returns the address of a string field in the struct.
|
|
||||||
func structPointer_StringVal(p structPointer, f field) *string {
|
|
||||||
return structPointer_ifield(p, f).(*string)
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringSlice returns the address of a []string field in the struct.
|
|
||||||
func structPointer_StringSlice(p structPointer, f field) *[]string {
|
|
||||||
return structPointer_ifield(p, f).(*[]string)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extensions returns the address of an extension map field in the struct.
|
|
||||||
func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions {
|
|
||||||
return structPointer_ifield(p, f).(*XXX_InternalExtensions)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExtMap returns the address of an extension map field in the struct.
|
|
||||||
func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {
|
|
||||||
return structPointer_ifield(p, f).(*map[int32]Extension)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAt returns the reflect.Value for a pointer to a field in the struct.
|
|
||||||
func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {
|
|
||||||
return structPointer_field(p, f).Addr()
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetStructPointer writes a *struct field in the struct.
|
|
||||||
func structPointer_SetStructPointer(p structPointer, f field, q structPointer) {
|
|
||||||
structPointer_field(p, f).Set(q.v)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetStructPointer reads a *struct field in the struct.
|
|
||||||
func structPointer_GetStructPointer(p structPointer, f field) structPointer {
|
|
||||||
return structPointer{structPointer_field(p, f)}
|
|
||||||
}
|
|
||||||
|
|
||||||
// StructPointerSlice the address of a []*struct field in the struct.
|
|
||||||
func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice {
|
|
||||||
return structPointerSlice{structPointer_field(p, f)}
|
|
||||||
}
|
|
||||||
|
|
||||||
// A structPointerSlice represents the address of a slice of pointers to structs
|
|
||||||
// (themselves messages or groups). That is, v.Type() is *[]*struct{...}.
|
|
||||||
type structPointerSlice struct {
|
|
||||||
v reflect.Value
|
v reflect.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p structPointerSlice) Len() int { return p.v.Len() }
|
// toPointer converts an interface of pointer type to a pointer
|
||||||
func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} }
|
// that points to the same target.
|
||||||
func (p structPointerSlice) Append(q structPointer) {
|
func toPointer(i *Message) pointer {
|
||||||
p.v.Set(reflect.Append(p.v, q.v))
|
return pointer{v: reflect.ValueOf(*i)}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
// toAddrPointer converts an interface to a pointer that points to
|
||||||
int32Type = reflect.TypeOf(int32(0))
|
// the interface data.
|
||||||
uint32Type = reflect.TypeOf(uint32(0))
|
func toAddrPointer(i *interface{}, isptr bool) pointer {
|
||||||
float32Type = reflect.TypeOf(float32(0))
|
v := reflect.ValueOf(*i)
|
||||||
int64Type = reflect.TypeOf(int64(0))
|
u := reflect.New(v.Type())
|
||||||
uint64Type = reflect.TypeOf(uint64(0))
|
u.Elem().Set(v)
|
||||||
float64Type = reflect.TypeOf(float64(0))
|
return pointer{v: u}
|
||||||
)
|
|
||||||
|
|
||||||
// A word32 represents a field of type *int32, *uint32, *float32, or *enum.
|
|
||||||
// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable.
|
|
||||||
type word32 struct {
|
|
||||||
v reflect.Value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNil reports whether p is nil.
|
// valToPointer converts v to a pointer. v must be of pointer type.
|
||||||
func word32_IsNil(p word32) bool {
|
func valToPointer(v reflect.Value) pointer {
|
||||||
|
return pointer{v: v}
|
||||||
|
}
|
||||||
|
|
||||||
|
// offset converts from a pointer to a structure to a pointer to
|
||||||
|
// one of its fields.
|
||||||
|
func (p pointer) offset(f field) pointer {
|
||||||
|
return pointer{v: p.v.Elem().FieldByIndex(f).Addr()}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p pointer) isNil() bool {
|
||||||
return p.v.IsNil()
|
return p.v.IsNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set sets p to point at a newly allocated word with bits set to x.
|
// grow updates the slice s in place to make it one element longer.
|
||||||
func word32_Set(p word32, o *Buffer, x uint32) {
|
// s must be addressable.
|
||||||
t := p.v.Type().Elem()
|
// Returns the (addressable) new element.
|
||||||
switch t {
|
func grow(s reflect.Value) reflect.Value {
|
||||||
case int32Type:
|
n, m := s.Len(), s.Cap()
|
||||||
if len(o.int32s) == 0 {
|
|
||||||
o.int32s = make([]int32, uint32PoolSize)
|
|
||||||
}
|
|
||||||
o.int32s[0] = int32(x)
|
|
||||||
p.v.Set(reflect.ValueOf(&o.int32s[0]))
|
|
||||||
o.int32s = o.int32s[1:]
|
|
||||||
return
|
|
||||||
case uint32Type:
|
|
||||||
if len(o.uint32s) == 0 {
|
|
||||||
o.uint32s = make([]uint32, uint32PoolSize)
|
|
||||||
}
|
|
||||||
o.uint32s[0] = x
|
|
||||||
p.v.Set(reflect.ValueOf(&o.uint32s[0]))
|
|
||||||
o.uint32s = o.uint32s[1:]
|
|
||||||
return
|
|
||||||
case float32Type:
|
|
||||||
if len(o.float32s) == 0 {
|
|
||||||
o.float32s = make([]float32, uint32PoolSize)
|
|
||||||
}
|
|
||||||
o.float32s[0] = math.Float32frombits(x)
|
|
||||||
p.v.Set(reflect.ValueOf(&o.float32s[0]))
|
|
||||||
o.float32s = o.float32s[1:]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// must be enum
|
|
||||||
p.v.Set(reflect.New(t))
|
|
||||||
p.v.Elem().SetInt(int64(int32(x)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get gets the bits pointed at by p, as a uint32.
|
|
||||||
func word32_Get(p word32) uint32 {
|
|
||||||
elem := p.v.Elem()
|
|
||||||
switch elem.Kind() {
|
|
||||||
case reflect.Int32:
|
|
||||||
return uint32(elem.Int())
|
|
||||||
case reflect.Uint32:
|
|
||||||
return uint32(elem.Uint())
|
|
||||||
case reflect.Float32:
|
|
||||||
return math.Float32bits(float32(elem.Float()))
|
|
||||||
}
|
|
||||||
panic("unreachable")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct.
|
|
||||||
func structPointer_Word32(p structPointer, f field) word32 {
|
|
||||||
return word32{structPointer_field(p, f)}
|
|
||||||
}
|
|
||||||
|
|
||||||
// A word32Val represents a field of type int32, uint32, float32, or enum.
|
|
||||||
// That is, v.Type() is int32, uint32, float32, or enum and v is assignable.
|
|
||||||
type word32Val struct {
|
|
||||||
v reflect.Value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set sets *p to x.
|
|
||||||
func word32Val_Set(p word32Val, x uint32) {
|
|
||||||
switch p.v.Type() {
|
|
||||||
case int32Type:
|
|
||||||
p.v.SetInt(int64(x))
|
|
||||||
return
|
|
||||||
case uint32Type:
|
|
||||||
p.v.SetUint(uint64(x))
|
|
||||||
return
|
|
||||||
case float32Type:
|
|
||||||
p.v.SetFloat(float64(math.Float32frombits(x)))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// must be enum
|
|
||||||
p.v.SetInt(int64(int32(x)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get gets the bits pointed at by p, as a uint32.
|
|
||||||
func word32Val_Get(p word32Val) uint32 {
|
|
||||||
elem := p.v
|
|
||||||
switch elem.Kind() {
|
|
||||||
case reflect.Int32:
|
|
||||||
return uint32(elem.Int())
|
|
||||||
case reflect.Uint32:
|
|
||||||
return uint32(elem.Uint())
|
|
||||||
case reflect.Float32:
|
|
||||||
return math.Float32bits(float32(elem.Float()))
|
|
||||||
}
|
|
||||||
panic("unreachable")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct.
|
|
||||||
func structPointer_Word32Val(p structPointer, f field) word32Val {
|
|
||||||
return word32Val{structPointer_field(p, f)}
|
|
||||||
}
|
|
||||||
|
|
||||||
// A word32Slice is a slice of 32-bit values.
|
|
||||||
// That is, v.Type() is []int32, []uint32, []float32, or []enum.
|
|
||||||
type word32Slice struct {
|
|
||||||
v reflect.Value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p word32Slice) Append(x uint32) {
|
|
||||||
n, m := p.v.Len(), p.v.Cap()
|
|
||||||
if n < m {
|
if n < m {
|
||||||
p.v.SetLen(n + 1)
|
s.SetLen(n + 1)
|
||||||
} else {
|
} else {
|
||||||
t := p.v.Type().Elem()
|
s.Set(reflect.Append(s, reflect.Zero(s.Type().Elem())))
|
||||||
p.v.Set(reflect.Append(p.v, reflect.Zero(t)))
|
|
||||||
}
|
}
|
||||||
elem := p.v.Index(n)
|
return s.Index(n)
|
||||||
switch elem.Kind() {
|
}
|
||||||
case reflect.Int32:
|
|
||||||
elem.SetInt(int64(int32(x)))
|
func (p pointer) toInt64() *int64 {
|
||||||
case reflect.Uint32:
|
return p.v.Interface().(*int64)
|
||||||
elem.SetUint(uint64(x))
|
}
|
||||||
case reflect.Float32:
|
func (p pointer) toInt64Ptr() **int64 {
|
||||||
elem.SetFloat(float64(math.Float32frombits(x)))
|
return p.v.Interface().(**int64)
|
||||||
|
}
|
||||||
|
func (p pointer) toInt64Slice() *[]int64 {
|
||||||
|
return p.v.Interface().(*[]int64)
|
||||||
|
}
|
||||||
|
|
||||||
|
var int32ptr = reflect.TypeOf((*int32)(nil))
|
||||||
|
|
||||||
|
func (p pointer) toInt32() *int32 {
|
||||||
|
return p.v.Convert(int32ptr).Interface().(*int32)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The toInt32Ptr/Slice methods don't work because of enums.
|
||||||
|
// Instead, we must use set/get methods for the int32ptr/slice case.
|
||||||
|
/*
|
||||||
|
func (p pointer) toInt32Ptr() **int32 {
|
||||||
|
return p.v.Interface().(**int32)
|
||||||
|
}
|
||||||
|
func (p pointer) toInt32Slice() *[]int32 {
|
||||||
|
return p.v.Interface().(*[]int32)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
func (p pointer) getInt32Ptr() *int32 {
|
||||||
|
if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
|
||||||
|
// raw int32 type
|
||||||
|
return p.v.Elem().Interface().(*int32)
|
||||||
}
|
}
|
||||||
|
// an enum
|
||||||
|
return p.v.Elem().Convert(int32PtrType).Interface().(*int32)
|
||||||
|
}
|
||||||
|
func (p pointer) setInt32Ptr(v int32) {
|
||||||
|
// Allocate value in a *int32. Possibly convert that to a *enum.
|
||||||
|
// Then assign it to a **int32 or **enum.
|
||||||
|
// Note: we can convert *int32 to *enum, but we can't convert
|
||||||
|
// **int32 to **enum!
|
||||||
|
p.v.Elem().Set(reflect.ValueOf(&v).Convert(p.v.Type().Elem()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p word32Slice) Len() int {
|
// getInt32Slice copies []int32 from p as a new slice.
|
||||||
return p.v.Len()
|
// This behavior differs from the implementation in pointer_unsafe.go.
|
||||||
}
|
func (p pointer) getInt32Slice() []int32 {
|
||||||
|
if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
|
||||||
func (p word32Slice) Index(i int) uint32 {
|
// raw int32 type
|
||||||
elem := p.v.Index(i)
|
return p.v.Elem().Interface().([]int32)
|
||||||
switch elem.Kind() {
|
|
||||||
case reflect.Int32:
|
|
||||||
return uint32(elem.Int())
|
|
||||||
case reflect.Uint32:
|
|
||||||
return uint32(elem.Uint())
|
|
||||||
case reflect.Float32:
|
|
||||||
return math.Float32bits(float32(elem.Float()))
|
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
// an enum
|
||||||
|
// Allocate a []int32, then assign []enum's values into it.
|
||||||
|
// Note: we can't convert []enum to []int32.
|
||||||
|
slice := p.v.Elem()
|
||||||
|
s := make([]int32, slice.Len())
|
||||||
|
for i := 0; i < slice.Len(); i++ {
|
||||||
|
s[i] = int32(slice.Index(i).Int())
|
||||||
|
}
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct.
|
// setInt32Slice copies []int32 into p as a new slice.
|
||||||
func structPointer_Word32Slice(p structPointer, f field) word32Slice {
|
// This behavior differs from the implementation in pointer_unsafe.go.
|
||||||
return word32Slice{structPointer_field(p, f)}
|
func (p pointer) setInt32Slice(v []int32) {
|
||||||
}
|
if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
|
||||||
|
// raw int32 type
|
||||||
// word64 is like word32 but for 64-bit values.
|
p.v.Elem().Set(reflect.ValueOf(v))
|
||||||
type word64 struct {
|
|
||||||
v reflect.Value
|
|
||||||
}
|
|
||||||
|
|
||||||
func word64_Set(p word64, o *Buffer, x uint64) {
|
|
||||||
t := p.v.Type().Elem()
|
|
||||||
switch t {
|
|
||||||
case int64Type:
|
|
||||||
if len(o.int64s) == 0 {
|
|
||||||
o.int64s = make([]int64, uint64PoolSize)
|
|
||||||
}
|
|
||||||
o.int64s[0] = int64(x)
|
|
||||||
p.v.Set(reflect.ValueOf(&o.int64s[0]))
|
|
||||||
o.int64s = o.int64s[1:]
|
|
||||||
return
|
|
||||||
case uint64Type:
|
|
||||||
if len(o.uint64s) == 0 {
|
|
||||||
o.uint64s = make([]uint64, uint64PoolSize)
|
|
||||||
}
|
|
||||||
o.uint64s[0] = x
|
|
||||||
p.v.Set(reflect.ValueOf(&o.uint64s[0]))
|
|
||||||
o.uint64s = o.uint64s[1:]
|
|
||||||
return
|
|
||||||
case float64Type:
|
|
||||||
if len(o.float64s) == 0 {
|
|
||||||
o.float64s = make([]float64, uint64PoolSize)
|
|
||||||
}
|
|
||||||
o.float64s[0] = math.Float64frombits(x)
|
|
||||||
p.v.Set(reflect.ValueOf(&o.float64s[0]))
|
|
||||||
o.float64s = o.float64s[1:]
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
// an enum
|
||||||
}
|
// Allocate a []enum, then assign []int32's values into it.
|
||||||
|
// Note: we can't convert []enum to []int32.
|
||||||
func word64_IsNil(p word64) bool {
|
slice := reflect.MakeSlice(p.v.Type().Elem(), len(v), cap(v))
|
||||||
return p.v.IsNil()
|
for i, x := range v {
|
||||||
}
|
slice.Index(i).SetInt(int64(x))
|
||||||
|
|
||||||
func word64_Get(p word64) uint64 {
|
|
||||||
elem := p.v.Elem()
|
|
||||||
switch elem.Kind() {
|
|
||||||
case reflect.Int64:
|
|
||||||
return uint64(elem.Int())
|
|
||||||
case reflect.Uint64:
|
|
||||||
return elem.Uint()
|
|
||||||
case reflect.Float64:
|
|
||||||
return math.Float64bits(elem.Float())
|
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
p.v.Elem().Set(slice)
|
||||||
|
}
|
||||||
|
func (p pointer) appendInt32Slice(v int32) {
|
||||||
|
grow(p.v.Elem()).SetInt(int64(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
func structPointer_Word64(p structPointer, f field) word64 {
|
func (p pointer) toUint64() *uint64 {
|
||||||
return word64{structPointer_field(p, f)}
|
return p.v.Interface().(*uint64)
|
||||||
|
}
|
||||||
|
func (p pointer) toUint64Ptr() **uint64 {
|
||||||
|
return p.v.Interface().(**uint64)
|
||||||
|
}
|
||||||
|
func (p pointer) toUint64Slice() *[]uint64 {
|
||||||
|
return p.v.Interface().(*[]uint64)
|
||||||
|
}
|
||||||
|
func (p pointer) toUint32() *uint32 {
|
||||||
|
return p.v.Interface().(*uint32)
|
||||||
|
}
|
||||||
|
func (p pointer) toUint32Ptr() **uint32 {
|
||||||
|
return p.v.Interface().(**uint32)
|
||||||
|
}
|
||||||
|
func (p pointer) toUint32Slice() *[]uint32 {
|
||||||
|
return p.v.Interface().(*[]uint32)
|
||||||
|
}
|
||||||
|
func (p pointer) toBool() *bool {
|
||||||
|
return p.v.Interface().(*bool)
|
||||||
|
}
|
||||||
|
func (p pointer) toBoolPtr() **bool {
|
||||||
|
return p.v.Interface().(**bool)
|
||||||
|
}
|
||||||
|
func (p pointer) toBoolSlice() *[]bool {
|
||||||
|
return p.v.Interface().(*[]bool)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat64() *float64 {
|
||||||
|
return p.v.Interface().(*float64)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat64Ptr() **float64 {
|
||||||
|
return p.v.Interface().(**float64)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat64Slice() *[]float64 {
|
||||||
|
return p.v.Interface().(*[]float64)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat32() *float32 {
|
||||||
|
return p.v.Interface().(*float32)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat32Ptr() **float32 {
|
||||||
|
return p.v.Interface().(**float32)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat32Slice() *[]float32 {
|
||||||
|
return p.v.Interface().(*[]float32)
|
||||||
|
}
|
||||||
|
func (p pointer) toString() *string {
|
||||||
|
return p.v.Interface().(*string)
|
||||||
|
}
|
||||||
|
func (p pointer) toStringPtr() **string {
|
||||||
|
return p.v.Interface().(**string)
|
||||||
|
}
|
||||||
|
func (p pointer) toStringSlice() *[]string {
|
||||||
|
return p.v.Interface().(*[]string)
|
||||||
|
}
|
||||||
|
func (p pointer) toBytes() *[]byte {
|
||||||
|
return p.v.Interface().(*[]byte)
|
||||||
|
}
|
||||||
|
func (p pointer) toBytesSlice() *[][]byte {
|
||||||
|
return p.v.Interface().(*[][]byte)
|
||||||
|
}
|
||||||
|
func (p pointer) toExtensions() *XXX_InternalExtensions {
|
||||||
|
return p.v.Interface().(*XXX_InternalExtensions)
|
||||||
|
}
|
||||||
|
func (p pointer) toOldExtensions() *map[int32]Extension {
|
||||||
|
return p.v.Interface().(*map[int32]Extension)
|
||||||
|
}
|
||||||
|
func (p pointer) getPointer() pointer {
|
||||||
|
return pointer{v: p.v.Elem()}
|
||||||
|
}
|
||||||
|
func (p pointer) setPointer(q pointer) {
|
||||||
|
p.v.Elem().Set(q.v)
|
||||||
|
}
|
||||||
|
func (p pointer) appendPointer(q pointer) {
|
||||||
|
grow(p.v.Elem()).Set(q.v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// word64Val is like word32Val but for 64-bit values.
|
// getPointerSlice copies []*T from p as a new []pointer.
|
||||||
type word64Val struct {
|
// This behavior differs from the implementation in pointer_unsafe.go.
|
||||||
v reflect.Value
|
func (p pointer) getPointerSlice() []pointer {
|
||||||
|
if p.v.IsNil() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
n := p.v.Elem().Len()
|
||||||
|
s := make([]pointer, n)
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
s[i] = pointer{v: p.v.Elem().Index(i)}
|
||||||
|
}
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func word64Val_Set(p word64Val, o *Buffer, x uint64) {
|
// setPointerSlice copies []pointer into p as a new []*T.
|
||||||
switch p.v.Type() {
|
// This behavior differs from the implementation in pointer_unsafe.go.
|
||||||
case int64Type:
|
func (p pointer) setPointerSlice(v []pointer) {
|
||||||
p.v.SetInt(int64(x))
|
if v == nil {
|
||||||
return
|
p.v.Elem().Set(reflect.New(p.v.Elem().Type()).Elem())
|
||||||
case uint64Type:
|
|
||||||
p.v.SetUint(x)
|
|
||||||
return
|
|
||||||
case float64Type:
|
|
||||||
p.v.SetFloat(math.Float64frombits(x))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
s := reflect.MakeSlice(p.v.Elem().Type(), 0, len(v))
|
||||||
}
|
for _, p := range v {
|
||||||
|
s = reflect.Append(s, p.v)
|
||||||
func word64Val_Get(p word64Val) uint64 {
|
|
||||||
elem := p.v
|
|
||||||
switch elem.Kind() {
|
|
||||||
case reflect.Int64:
|
|
||||||
return uint64(elem.Int())
|
|
||||||
case reflect.Uint64:
|
|
||||||
return elem.Uint()
|
|
||||||
case reflect.Float64:
|
|
||||||
return math.Float64bits(elem.Float())
|
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
p.v.Elem().Set(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func structPointer_Word64Val(p structPointer, f field) word64Val {
|
// getInterfacePointer returns a pointer that points to the
|
||||||
return word64Val{structPointer_field(p, f)}
|
// interface data of the interface pointed by p.
|
||||||
}
|
func (p pointer) getInterfacePointer() pointer {
|
||||||
|
if p.v.Elem().IsNil() {
|
||||||
type word64Slice struct {
|
return pointer{v: p.v.Elem()}
|
||||||
v reflect.Value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p word64Slice) Append(x uint64) {
|
|
||||||
n, m := p.v.Len(), p.v.Cap()
|
|
||||||
if n < m {
|
|
||||||
p.v.SetLen(n + 1)
|
|
||||||
} else {
|
|
||||||
t := p.v.Type().Elem()
|
|
||||||
p.v.Set(reflect.Append(p.v, reflect.Zero(t)))
|
|
||||||
}
|
|
||||||
elem := p.v.Index(n)
|
|
||||||
switch elem.Kind() {
|
|
||||||
case reflect.Int64:
|
|
||||||
elem.SetInt(int64(int64(x)))
|
|
||||||
case reflect.Uint64:
|
|
||||||
elem.SetUint(uint64(x))
|
|
||||||
case reflect.Float64:
|
|
||||||
elem.SetFloat(float64(math.Float64frombits(x)))
|
|
||||||
}
|
}
|
||||||
|
return pointer{v: p.v.Elem().Elem().Elem().Field(0).Addr()} // *interface -> interface -> *struct -> struct
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p word64Slice) Len() int {
|
func (p pointer) asPointerTo(t reflect.Type) reflect.Value {
|
||||||
return p.v.Len()
|
// TODO: check that p.v.Type().Elem() == t?
|
||||||
|
return p.v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p word64Slice) Index(i int) uint64 {
|
func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo {
|
||||||
elem := p.v.Index(i)
|
atomicLock.Lock()
|
||||||
switch elem.Kind() {
|
defer atomicLock.Unlock()
|
||||||
case reflect.Int64:
|
return *p
|
||||||
return uint64(elem.Int())
|
}
|
||||||
case reflect.Uint64:
|
func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) {
|
||||||
return uint64(elem.Uint())
|
atomicLock.Lock()
|
||||||
case reflect.Float64:
|
defer atomicLock.Unlock()
|
||||||
return math.Float64bits(float64(elem.Float()))
|
*p = v
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo {
|
||||||
|
atomicLock.Lock()
|
||||||
|
defer atomicLock.Unlock()
|
||||||
|
return *p
|
||||||
|
}
|
||||||
|
func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) {
|
||||||
|
atomicLock.Lock()
|
||||||
|
defer atomicLock.Unlock()
|
||||||
|
*p = v
|
||||||
|
}
|
||||||
|
func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo {
|
||||||
|
atomicLock.Lock()
|
||||||
|
defer atomicLock.Unlock()
|
||||||
|
return *p
|
||||||
|
}
|
||||||
|
func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) {
|
||||||
|
atomicLock.Lock()
|
||||||
|
defer atomicLock.Unlock()
|
||||||
|
*p = v
|
||||||
|
}
|
||||||
|
func atomicLoadDiscardInfo(p **discardInfo) *discardInfo {
|
||||||
|
atomicLock.Lock()
|
||||||
|
defer atomicLock.Unlock()
|
||||||
|
return *p
|
||||||
|
}
|
||||||
|
func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) {
|
||||||
|
atomicLock.Lock()
|
||||||
|
defer atomicLock.Unlock()
|
||||||
|
*p = v
|
||||||
}
|
}
|
||||||
|
|
||||||
func structPointer_Word64Slice(p structPointer, f field) word64Slice {
|
var atomicLock sync.Mutex
|
||||||
return word64Slice{structPointer_field(p, f)}
|
|
||||||
}
|
|
||||||
|
|||||||
+20
-46
@@ -1,6 +1,6 @@
|
|||||||
// Protocol Buffers for Go with Gadgets
|
// Protocol Buffers for Go with Gadgets
|
||||||
//
|
//
|
||||||
// Copyright (c) 2016, The GoGo Authors. All rights reserved.
|
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
|
||||||
// http://github.com/gogo/protobuf
|
// http://github.com/gogo/protobuf
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -26,7 +26,11 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// +build appengine js
|
// +build purego appengine js
|
||||||
|
|
||||||
|
// This file contains an implementation of proto field accesses using package reflect.
|
||||||
|
// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can
|
||||||
|
// be used on App Engine.
|
||||||
|
|
||||||
package proto
|
package proto
|
||||||
|
|
||||||
@@ -34,52 +38,22 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
func structPointer_FieldPointer(p structPointer, f field) structPointer {
|
// TODO: untested, so probably incorrect.
|
||||||
panic("not implemented")
|
|
||||||
|
func (p pointer) getRef() pointer {
|
||||||
|
return pointer{v: p.v.Addr()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer {
|
func (p pointer) appendRef(v pointer, typ reflect.Type) {
|
||||||
panic("not implemented")
|
slice := p.getSlice(typ)
|
||||||
|
elem := v.asPointerTo(typ).Elem()
|
||||||
|
newSlice := reflect.Append(slice, elem)
|
||||||
|
slice.Set(newSlice)
|
||||||
}
|
}
|
||||||
|
|
||||||
func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} {
|
func (p pointer) getSlice(typ reflect.Type) reflect.Value {
|
||||||
panic("not implemented")
|
sliceTyp := reflect.SliceOf(typ)
|
||||||
}
|
slice := p.asPointerTo(sliceTyp)
|
||||||
|
slice = slice.Elem()
|
||||||
func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} {
|
return slice
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_GetRefStructPointer(p structPointer, f field) structPointer {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_Add(p structPointer, size field) structPointer {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_Len(p structPointer, f field) int {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_StructRefSlice(p structPointer, f field, size uintptr) *structRefSlice {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
type structRefSlice struct{}
|
|
||||||
|
|
||||||
func (v *structRefSlice) Len() int {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *structRefSlice) Index(i int) structPointer {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
}
|
||||||
|
|||||||
+220
-182
@@ -29,7 +29,7 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// +build !appengine,!js
|
// +build !purego,!appengine,!js
|
||||||
|
|
||||||
// This file contains the implementation of the proto field accesses using package unsafe.
|
// This file contains the implementation of the proto field accesses using package unsafe.
|
||||||
|
|
||||||
@@ -37,38 +37,13 @@ package proto
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sync/atomic"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NOTE: These type_Foo functions would more idiomatically be methods,
|
const unsafeAllowed = true
|
||||||
// but Go does not allow methods on pointer types, and we must preserve
|
|
||||||
// some pointer type for the garbage collector. We use these
|
|
||||||
// funcs with clunky names as our poor approximation to methods.
|
|
||||||
//
|
|
||||||
// An alternative would be
|
|
||||||
// type structPointer struct { p unsafe.Pointer }
|
|
||||||
// but that does not registerize as well.
|
|
||||||
|
|
||||||
// A structPointer is a pointer to a struct.
|
// A field identifies a field in a struct, accessible from a pointer.
|
||||||
type structPointer unsafe.Pointer
|
|
||||||
|
|
||||||
// toStructPointer returns a structPointer equivalent to the given reflect value.
|
|
||||||
func toStructPointer(v reflect.Value) structPointer {
|
|
||||||
return structPointer(unsafe.Pointer(v.Pointer()))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsNil reports whether p is nil.
|
|
||||||
func structPointer_IsNil(p structPointer) bool {
|
|
||||||
return p == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interface returns the struct pointer, assumed to have element type t,
|
|
||||||
// as an interface value.
|
|
||||||
func structPointer_Interface(p structPointer, t reflect.Type) interface{} {
|
|
||||||
return reflect.NewAt(t, unsafe.Pointer(p)).Interface()
|
|
||||||
}
|
|
||||||
|
|
||||||
// A field identifies a field in a struct, accessible from a structPointer.
|
|
||||||
// In this implementation, a field is identified by its byte offset from the start of the struct.
|
// In this implementation, a field is identified by its byte offset from the start of the struct.
|
||||||
type field uintptr
|
type field uintptr
|
||||||
|
|
||||||
@@ -80,191 +55,254 @@ func toField(f *reflect.StructField) field {
|
|||||||
// invalidField is an invalid field identifier.
|
// invalidField is an invalid field identifier.
|
||||||
const invalidField = ^field(0)
|
const invalidField = ^field(0)
|
||||||
|
|
||||||
|
// zeroField is a noop when calling pointer.offset.
|
||||||
|
const zeroField = field(0)
|
||||||
|
|
||||||
// IsValid reports whether the field identifier is valid.
|
// IsValid reports whether the field identifier is valid.
|
||||||
func (f field) IsValid() bool {
|
func (f field) IsValid() bool {
|
||||||
return f != ^field(0)
|
return f != invalidField
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bytes returns the address of a []byte field in the struct.
|
// The pointer type below is for the new table-driven encoder/decoder.
|
||||||
func structPointer_Bytes(p structPointer, f field) *[]byte {
|
// The implementation here uses unsafe.Pointer to create a generic pointer.
|
||||||
return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
// In pointer_reflect.go we use reflect instead of unsafe to implement
|
||||||
|
// the same (but slower) interface.
|
||||||
|
type pointer struct {
|
||||||
|
p unsafe.Pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
// BytesSlice returns the address of a [][]byte field in the struct.
|
// size of pointer
|
||||||
func structPointer_BytesSlice(p structPointer, f field) *[][]byte {
|
var ptrSize = unsafe.Sizeof(uintptr(0))
|
||||||
return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
|
// toPointer converts an interface of pointer type to a pointer
|
||||||
|
// that points to the same target.
|
||||||
|
func toPointer(i *Message) pointer {
|
||||||
|
// Super-tricky - read pointer out of data word of interface value.
|
||||||
|
// Saves ~25ns over the equivalent:
|
||||||
|
// return valToPointer(reflect.ValueOf(*i))
|
||||||
|
return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bool returns the address of a *bool field in the struct.
|
// toAddrPointer converts an interface to a pointer that points to
|
||||||
func structPointer_Bool(p structPointer, f field) **bool {
|
// the interface data.
|
||||||
return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
func toAddrPointer(i *interface{}, isptr bool) pointer {
|
||||||
}
|
// Super-tricky - read or get the address of data word of interface value.
|
||||||
|
if isptr {
|
||||||
// BoolVal returns the address of a bool field in the struct.
|
// The interface is of pointer type, thus it is a direct interface.
|
||||||
func structPointer_BoolVal(p structPointer, f field) *bool {
|
// The data word is the pointer data itself. We take its address.
|
||||||
return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)}
|
||||||
}
|
|
||||||
|
|
||||||
// BoolSlice returns the address of a []bool field in the struct.
|
|
||||||
func structPointer_BoolSlice(p structPointer, f field) *[]bool {
|
|
||||||
return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns the address of a *string field in the struct.
|
|
||||||
func structPointer_String(p structPointer, f field) **string {
|
|
||||||
return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringVal returns the address of a string field in the struct.
|
|
||||||
func structPointer_StringVal(p structPointer, f field) *string {
|
|
||||||
return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringSlice returns the address of a []string field in the struct.
|
|
||||||
func structPointer_StringSlice(p structPointer, f field) *[]string {
|
|
||||||
return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExtMap returns the address of an extension map field in the struct.
|
|
||||||
func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions {
|
|
||||||
return (*XXX_InternalExtensions)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {
|
|
||||||
return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAt returns the reflect.Value for a pointer to a field in the struct.
|
|
||||||
func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {
|
|
||||||
return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetStructPointer writes a *struct field in the struct.
|
|
||||||
func structPointer_SetStructPointer(p structPointer, f field, q structPointer) {
|
|
||||||
*(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetStructPointer reads a *struct field in the struct.
|
|
||||||
func structPointer_GetStructPointer(p structPointer, f field) structPointer {
|
|
||||||
return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// StructPointerSlice the address of a []*struct field in the struct.
|
|
||||||
func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice {
|
|
||||||
return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups).
|
|
||||||
type structPointerSlice []structPointer
|
|
||||||
|
|
||||||
func (v *structPointerSlice) Len() int { return len(*v) }
|
|
||||||
func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] }
|
|
||||||
func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) }
|
|
||||||
|
|
||||||
// A word32 is the address of a "pointer to 32-bit value" field.
|
|
||||||
type word32 **uint32
|
|
||||||
|
|
||||||
// IsNil reports whether *v is nil.
|
|
||||||
func word32_IsNil(p word32) bool {
|
|
||||||
return *p == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set sets *v to point at a newly allocated word set to x.
|
|
||||||
func word32_Set(p word32, o *Buffer, x uint32) {
|
|
||||||
if len(o.uint32s) == 0 {
|
|
||||||
o.uint32s = make([]uint32, uint32PoolSize)
|
|
||||||
}
|
}
|
||||||
o.uint32s[0] = x
|
// The interface is not of pointer type. The data word is the pointer
|
||||||
*p = &o.uint32s[0]
|
// to the data.
|
||||||
o.uint32s = o.uint32s[1:]
|
return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets the value pointed at by *v.
|
// valToPointer converts v to a pointer. v must be of pointer type.
|
||||||
func word32_Get(p word32) uint32 {
|
func valToPointer(v reflect.Value) pointer {
|
||||||
return **p
|
return pointer{p: unsafe.Pointer(v.Pointer())}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct.
|
// offset converts from a pointer to a structure to a pointer to
|
||||||
func structPointer_Word32(p structPointer, f field) word32 {
|
// one of its fields.
|
||||||
return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f))))
|
func (p pointer) offset(f field) pointer {
|
||||||
|
// For safety, we should panic if !f.IsValid, however calling panic causes
|
||||||
|
// this to no longer be inlineable, which is a serious performance cost.
|
||||||
|
/*
|
||||||
|
if !f.IsValid() {
|
||||||
|
panic("invalid field")
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return pointer{p: unsafe.Pointer(uintptr(p.p) + uintptr(f))}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A word32Val is the address of a 32-bit value field.
|
func (p pointer) isNil() bool {
|
||||||
type word32Val *uint32
|
return p.p == nil
|
||||||
|
|
||||||
// Set sets *p to x.
|
|
||||||
func word32Val_Set(p word32Val, x uint32) {
|
|
||||||
*p = x
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets the value pointed at by p.
|
func (p pointer) toInt64() *int64 {
|
||||||
func word32Val_Get(p word32Val) uint32 {
|
return (*int64)(p.p)
|
||||||
return *p
|
}
|
||||||
|
func (p pointer) toInt64Ptr() **int64 {
|
||||||
|
return (**int64)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toInt64Slice() *[]int64 {
|
||||||
|
return (*[]int64)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toInt32() *int32 {
|
||||||
|
return (*int32)(p.p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct.
|
// See pointer_reflect.go for why toInt32Ptr/Slice doesn't exist.
|
||||||
func structPointer_Word32Val(p structPointer, f field) word32Val {
|
/*
|
||||||
return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f))))
|
func (p pointer) toInt32Ptr() **int32 {
|
||||||
}
|
return (**int32)(p.p)
|
||||||
|
|
||||||
// A word32Slice is a slice of 32-bit values.
|
|
||||||
type word32Slice []uint32
|
|
||||||
|
|
||||||
func (v *word32Slice) Append(x uint32) { *v = append(*v, x) }
|
|
||||||
func (v *word32Slice) Len() int { return len(*v) }
|
|
||||||
func (v *word32Slice) Index(i int) uint32 { return (*v)[i] }
|
|
||||||
|
|
||||||
// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct.
|
|
||||||
func structPointer_Word32Slice(p structPointer, f field) *word32Slice {
|
|
||||||
return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// word64 is like word32 but for 64-bit values.
|
|
||||||
type word64 **uint64
|
|
||||||
|
|
||||||
func word64_Set(p word64, o *Buffer, x uint64) {
|
|
||||||
if len(o.uint64s) == 0 {
|
|
||||||
o.uint64s = make([]uint64, uint64PoolSize)
|
|
||||||
}
|
}
|
||||||
o.uint64s[0] = x
|
func (p pointer) toInt32Slice() *[]int32 {
|
||||||
*p = &o.uint64s[0]
|
return (*[]int32)(p.p)
|
||||||
o.uint64s = o.uint64s[1:]
|
}
|
||||||
|
*/
|
||||||
|
func (p pointer) getInt32Ptr() *int32 {
|
||||||
|
return *(**int32)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) setInt32Ptr(v int32) {
|
||||||
|
*(**int32)(p.p) = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
func word64_IsNil(p word64) bool {
|
// getInt32Slice loads a []int32 from p.
|
||||||
return *p == nil
|
// The value returned is aliased with the original slice.
|
||||||
|
// This behavior differs from the implementation in pointer_reflect.go.
|
||||||
|
func (p pointer) getInt32Slice() []int32 {
|
||||||
|
return *(*[]int32)(p.p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func word64_Get(p word64) uint64 {
|
// setInt32Slice stores a []int32 to p.
|
||||||
return **p
|
// The value set is aliased with the input slice.
|
||||||
|
// This behavior differs from the implementation in pointer_reflect.go.
|
||||||
|
func (p pointer) setInt32Slice(v []int32) {
|
||||||
|
*(*[]int32)(p.p) = v
|
||||||
}
|
}
|
||||||
|
|
||||||
func structPointer_Word64(p structPointer, f field) word64 {
|
// TODO: Can we get rid of appendInt32Slice and use setInt32Slice instead?
|
||||||
return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f))))
|
func (p pointer) appendInt32Slice(v int32) {
|
||||||
|
s := (*[]int32)(p.p)
|
||||||
|
*s = append(*s, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// word64Val is like word32Val but for 64-bit values.
|
func (p pointer) toUint64() *uint64 {
|
||||||
type word64Val *uint64
|
return (*uint64)(p.p)
|
||||||
|
}
|
||||||
func word64Val_Set(p word64Val, o *Buffer, x uint64) {
|
func (p pointer) toUint64Ptr() **uint64 {
|
||||||
*p = x
|
return (**uint64)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toUint64Slice() *[]uint64 {
|
||||||
|
return (*[]uint64)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toUint32() *uint32 {
|
||||||
|
return (*uint32)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toUint32Ptr() **uint32 {
|
||||||
|
return (**uint32)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toUint32Slice() *[]uint32 {
|
||||||
|
return (*[]uint32)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toBool() *bool {
|
||||||
|
return (*bool)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toBoolPtr() **bool {
|
||||||
|
return (**bool)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toBoolSlice() *[]bool {
|
||||||
|
return (*[]bool)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat64() *float64 {
|
||||||
|
return (*float64)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat64Ptr() **float64 {
|
||||||
|
return (**float64)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat64Slice() *[]float64 {
|
||||||
|
return (*[]float64)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat32() *float32 {
|
||||||
|
return (*float32)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat32Ptr() **float32 {
|
||||||
|
return (**float32)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toFloat32Slice() *[]float32 {
|
||||||
|
return (*[]float32)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toString() *string {
|
||||||
|
return (*string)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toStringPtr() **string {
|
||||||
|
return (**string)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toStringSlice() *[]string {
|
||||||
|
return (*[]string)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toBytes() *[]byte {
|
||||||
|
return (*[]byte)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toBytesSlice() *[][]byte {
|
||||||
|
return (*[][]byte)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toExtensions() *XXX_InternalExtensions {
|
||||||
|
return (*XXX_InternalExtensions)(p.p)
|
||||||
|
}
|
||||||
|
func (p pointer) toOldExtensions() *map[int32]Extension {
|
||||||
|
return (*map[int32]Extension)(p.p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func word64Val_Get(p word64Val) uint64 {
|
// getPointerSlice loads []*T from p as a []pointer.
|
||||||
return *p
|
// The value returned is aliased with the original slice.
|
||||||
|
// This behavior differs from the implementation in pointer_reflect.go.
|
||||||
|
func (p pointer) getPointerSlice() []pointer {
|
||||||
|
// Super-tricky - p should point to a []*T where T is a
|
||||||
|
// message type. We load it as []pointer.
|
||||||
|
return *(*[]pointer)(p.p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func structPointer_Word64Val(p structPointer, f field) word64Val {
|
// setPointerSlice stores []pointer into p as a []*T.
|
||||||
return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f))))
|
// The value set is aliased with the input slice.
|
||||||
|
// This behavior differs from the implementation in pointer_reflect.go.
|
||||||
|
func (p pointer) setPointerSlice(v []pointer) {
|
||||||
|
// Super-tricky - p should point to a []*T where T is a
|
||||||
|
// message type. We store it as []pointer.
|
||||||
|
*(*[]pointer)(p.p) = v
|
||||||
}
|
}
|
||||||
|
|
||||||
// word64Slice is like word32Slice but for 64-bit values.
|
// getPointer loads the pointer at p and returns it.
|
||||||
type word64Slice []uint64
|
func (p pointer) getPointer() pointer {
|
||||||
|
return pointer{p: *(*unsafe.Pointer)(p.p)}
|
||||||
func (v *word64Slice) Append(x uint64) { *v = append(*v, x) }
|
}
|
||||||
func (v *word64Slice) Len() int { return len(*v) }
|
|
||||||
func (v *word64Slice) Index(i int) uint64 { return (*v)[i] }
|
// setPointer stores the pointer q at p.
|
||||||
|
func (p pointer) setPointer(q pointer) {
|
||||||
func structPointer_Word64Slice(p structPointer, f field) *word64Slice {
|
*(*unsafe.Pointer)(p.p) = q.p
|
||||||
return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
}
|
||||||
|
|
||||||
|
// append q to the slice pointed to by p.
|
||||||
|
func (p pointer) appendPointer(q pointer) {
|
||||||
|
s := (*[]unsafe.Pointer)(p.p)
|
||||||
|
*s = append(*s, q.p)
|
||||||
|
}
|
||||||
|
|
||||||
|
// getInterfacePointer returns a pointer that points to the
|
||||||
|
// interface data of the interface pointed by p.
|
||||||
|
func (p pointer) getInterfacePointer() pointer {
|
||||||
|
// Super-tricky - read pointer out of data word of interface value.
|
||||||
|
return pointer{p: (*(*[2]unsafe.Pointer)(p.p))[1]}
|
||||||
|
}
|
||||||
|
|
||||||
|
// asPointerTo returns a reflect.Value that is a pointer to an
|
||||||
|
// object of type t stored at p.
|
||||||
|
func (p pointer) asPointerTo(t reflect.Type) reflect.Value {
|
||||||
|
return reflect.NewAt(t, p.p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo {
|
||||||
|
return (*unmarshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
|
||||||
|
}
|
||||||
|
func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) {
|
||||||
|
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
|
||||||
|
}
|
||||||
|
func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo {
|
||||||
|
return (*marshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
|
||||||
|
}
|
||||||
|
func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) {
|
||||||
|
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
|
||||||
|
}
|
||||||
|
func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo {
|
||||||
|
return (*mergeInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
|
||||||
|
}
|
||||||
|
func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) {
|
||||||
|
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
|
||||||
|
}
|
||||||
|
func atomicLoadDiscardInfo(p **discardInfo) *discardInfo {
|
||||||
|
return (*discardInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
|
||||||
|
}
|
||||||
|
func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) {
|
||||||
|
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-86
@@ -1,6 +1,6 @@
|
|||||||
// Protocol Buffers for Go with Gadgets
|
// Protocol Buffers for Go with Gadgets
|
||||||
//
|
//
|
||||||
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
|
||||||
// http://github.com/gogo/protobuf
|
// http://github.com/gogo/protobuf
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// +build !appengine,!js
|
// +build !purego,!appengine,!js
|
||||||
|
|
||||||
// This file contains the implementation of the proto field accesses using package unsafe.
|
// This file contains the implementation of the proto field accesses using package unsafe.
|
||||||
|
|
||||||
@@ -37,92 +37,20 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} {
|
func (p pointer) getRef() pointer {
|
||||||
point := unsafe.Pointer(uintptr(p) + uintptr(f))
|
return pointer{p: (unsafe.Pointer)(&p.p)}
|
||||||
r := reflect.NewAt(t, point)
|
|
||||||
return r.Interface()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} {
|
func (p pointer) appendRef(v pointer, typ reflect.Type) {
|
||||||
point := unsafe.Pointer(uintptr(p) + uintptr(f))
|
slice := p.getSlice(typ)
|
||||||
r := reflect.NewAt(t, point)
|
elem := v.asPointerTo(typ).Elem()
|
||||||
if r.Elem().IsNil() {
|
newSlice := reflect.Append(slice, elem)
|
||||||
return nil
|
slice.Set(newSlice)
|
||||||
}
|
|
||||||
return r.Elem().Interface()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyUintPtr(oldptr, newptr uintptr, size int) {
|
func (p pointer) getSlice(typ reflect.Type) reflect.Value {
|
||||||
oldbytes := make([]byte, 0)
|
sliceTyp := reflect.SliceOf(typ)
|
||||||
oldslice := (*reflect.SliceHeader)(unsafe.Pointer(&oldbytes))
|
slice := p.asPointerTo(sliceTyp)
|
||||||
oldslice.Data = oldptr
|
slice = slice.Elem()
|
||||||
oldslice.Len = size
|
return slice
|
||||||
oldslice.Cap = size
|
|
||||||
newbytes := make([]byte, 0)
|
|
||||||
newslice := (*reflect.SliceHeader)(unsafe.Pointer(&newbytes))
|
|
||||||
newslice.Data = newptr
|
|
||||||
newslice.Len = size
|
|
||||||
newslice.Cap = size
|
|
||||||
copy(newbytes, oldbytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) {
|
|
||||||
copyUintPtr(uintptr(oldptr), uintptr(newptr), size)
|
|
||||||
}
|
|
||||||
|
|
||||||
func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer {
|
|
||||||
size := typ.Elem().Size()
|
|
||||||
|
|
||||||
oldHeader := structPointer_GetSliceHeader(base, f)
|
|
||||||
oldSlice := reflect.NewAt(typ, unsafe.Pointer(oldHeader)).Elem()
|
|
||||||
newLen := oldHeader.Len + 1
|
|
||||||
newSlice := reflect.MakeSlice(typ, newLen, newLen)
|
|
||||||
reflect.Copy(newSlice, oldSlice)
|
|
||||||
bas := toStructPointer(newSlice)
|
|
||||||
oldHeader.Data = uintptr(bas)
|
|
||||||
oldHeader.Len = newLen
|
|
||||||
oldHeader.Cap = newLen
|
|
||||||
|
|
||||||
return structPointer(unsafe.Pointer(uintptr(unsafe.Pointer(bas)) + uintptr(uintptr(newLen-1)*size)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_FieldPointer(p structPointer, f field) structPointer {
|
|
||||||
return structPointer(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_GetRefStructPointer(p structPointer, f field) structPointer {
|
|
||||||
return structPointer((*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))))
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader {
|
|
||||||
return (*reflect.SliceHeader)(unsafe.Pointer(uintptr(p) + uintptr(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_Add(p structPointer, size field) structPointer {
|
|
||||||
return structPointer(unsafe.Pointer(uintptr(p) + uintptr(size)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_Len(p structPointer, f field) int {
|
|
||||||
return len(*(*[]interface{})(unsafe.Pointer(structPointer_GetRefStructPointer(p, f))))
|
|
||||||
}
|
|
||||||
|
|
||||||
func structPointer_StructRefSlice(p structPointer, f field, size uintptr) *structRefSlice {
|
|
||||||
return &structRefSlice{p: p, f: f, size: size}
|
|
||||||
}
|
|
||||||
|
|
||||||
// A structRefSlice represents a slice of structs (themselves submessages or groups).
|
|
||||||
type structRefSlice struct {
|
|
||||||
p structPointer
|
|
||||||
f field
|
|
||||||
size uintptr
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *structRefSlice) Len() int {
|
|
||||||
return structPointer_Len(v.p, v.f)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *structRefSlice) Index(i int) structPointer {
|
|
||||||
ss := structPointer_GetStructPointer(v.p, v.f)
|
|
||||||
ss1 := structPointer_GetRefStructPointer(ss, 0)
|
|
||||||
return structPointer_Add(ss1, field(uintptr(i)*v.size))
|
|
||||||
}
|
}
|
||||||
|
|||||||
+68
-431
@@ -63,42 +63,6 @@ const (
|
|||||||
WireFixed32 = 5
|
WireFixed32 = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
const startSize = 10 // initial slice/string sizes
|
|
||||||
|
|
||||||
// Encoders are defined in encode.go
|
|
||||||
// An encoder outputs the full representation of a field, including its
|
|
||||||
// tag and encoder type.
|
|
||||||
type encoder func(p *Buffer, prop *Properties, base structPointer) error
|
|
||||||
|
|
||||||
// A valueEncoder encodes a single integer in a particular encoding.
|
|
||||||
type valueEncoder func(o *Buffer, x uint64) error
|
|
||||||
|
|
||||||
// Sizers are defined in encode.go
|
|
||||||
// A sizer returns the encoded size of a field, including its tag and encoder
|
|
||||||
// type.
|
|
||||||
type sizer func(prop *Properties, base structPointer) int
|
|
||||||
|
|
||||||
// A valueSizer returns the encoded size of a single integer in a particular
|
|
||||||
// encoding.
|
|
||||||
type valueSizer func(x uint64) int
|
|
||||||
|
|
||||||
// Decoders are defined in decode.go
|
|
||||||
// A decoder creates a value from its wire representation.
|
|
||||||
// Unrecognized subelements are saved in unrec.
|
|
||||||
type decoder func(p *Buffer, prop *Properties, base structPointer) error
|
|
||||||
|
|
||||||
// A valueDecoder decodes a single integer in a particular encoding.
|
|
||||||
type valueDecoder func(o *Buffer) (x uint64, err error)
|
|
||||||
|
|
||||||
// A oneofMarshaler does the marshaling for all oneof fields in a message.
|
|
||||||
type oneofMarshaler func(Message, *Buffer) error
|
|
||||||
|
|
||||||
// A oneofUnmarshaler does the unmarshaling for a oneof field in a message.
|
|
||||||
type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error)
|
|
||||||
|
|
||||||
// A oneofSizer does the sizing for all oneof fields in a message.
|
|
||||||
type oneofSizer func(Message) int
|
|
||||||
|
|
||||||
// tagMap is an optimization over map[int]int for typical protocol buffer
|
// tagMap is an optimization over map[int]int for typical protocol buffer
|
||||||
// use-cases. Encoded protocol buffers are often in tag order with small tag
|
// use-cases. Encoded protocol buffers are often in tag order with small tag
|
||||||
// numbers.
|
// numbers.
|
||||||
@@ -145,13 +109,6 @@ type StructProperties struct {
|
|||||||
decoderTags tagMap // map from proto tag to struct field number
|
decoderTags tagMap // map from proto tag to struct field number
|
||||||
decoderOrigNames map[string]int // map from original name to struct field number
|
decoderOrigNames map[string]int // map from original name to struct field number
|
||||||
order []int // list of struct field numbers in tag order
|
order []int // list of struct field numbers in tag order
|
||||||
unrecField field // field id of the XXX_unrecognized []byte field
|
|
||||||
extendable bool // is this an extendable proto
|
|
||||||
|
|
||||||
oneofMarshaler oneofMarshaler
|
|
||||||
oneofUnmarshaler oneofUnmarshaler
|
|
||||||
oneofSizer oneofSizer
|
|
||||||
stype reflect.Type
|
|
||||||
|
|
||||||
// OneofTypes contains information about the oneof fields in this message.
|
// OneofTypes contains information about the oneof fields in this message.
|
||||||
// It is keyed by the original name of a field.
|
// It is keyed by the original name of a field.
|
||||||
@@ -187,7 +144,7 @@ type Properties struct {
|
|||||||
Repeated bool
|
Repeated bool
|
||||||
Packed bool // relevant for repeated primitives only
|
Packed bool // relevant for repeated primitives only
|
||||||
Enum string // set for enum types only
|
Enum string // set for enum types only
|
||||||
proto3 bool // whether this is known to be a proto3 field; set for []byte only
|
proto3 bool // whether this is known to be a proto3 field
|
||||||
oneof bool // whether this is a oneof field
|
oneof bool // whether this is a oneof field
|
||||||
|
|
||||||
Default string // default value
|
Default string // default value
|
||||||
@@ -196,37 +153,21 @@ type Properties struct {
|
|||||||
CastType string
|
CastType string
|
||||||
StdTime bool
|
StdTime bool
|
||||||
StdDuration bool
|
StdDuration bool
|
||||||
|
WktPointer bool
|
||||||
|
|
||||||
enc encoder
|
stype reflect.Type // set for struct types only
|
||||||
valEnc valueEncoder // set for bool and numeric types only
|
ctype reflect.Type // set for custom types only
|
||||||
field field
|
sprop *StructProperties // set for struct types only
|
||||||
tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType)
|
|
||||||
tagbuf [8]byte
|
|
||||||
stype reflect.Type // set for struct types only
|
|
||||||
sstype reflect.Type // set for slices of structs types only
|
|
||||||
ctype reflect.Type // set for custom types only
|
|
||||||
sprop *StructProperties // set for struct types only
|
|
||||||
isMarshaler bool
|
|
||||||
isUnmarshaler bool
|
|
||||||
|
|
||||||
mtype reflect.Type // set for map types only
|
mtype reflect.Type // set for map types only
|
||||||
mkeyprop *Properties // set for map types only
|
MapKeyProp *Properties // set for map types only
|
||||||
mvalprop *Properties // set for map types only
|
MapValProp *Properties // set for map types only
|
||||||
|
|
||||||
size sizer
|
|
||||||
valSize valueSizer // set for bool and numeric types only
|
|
||||||
|
|
||||||
dec decoder
|
|
||||||
valDec valueDecoder // set for bool and numeric types only
|
|
||||||
|
|
||||||
// If this is a packable field, this will be the decoder for the packed version of the field.
|
|
||||||
packedDec decoder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// String formats the properties in the protobuf struct field tag style.
|
// String formats the properties in the protobuf struct field tag style.
|
||||||
func (p *Properties) String() string {
|
func (p *Properties) String() string {
|
||||||
s := p.Wire
|
s := p.Wire
|
||||||
s = ","
|
s += ","
|
||||||
s += strconv.Itoa(p.Tag)
|
s += strconv.Itoa(p.Tag)
|
||||||
if p.Required {
|
if p.Required {
|
||||||
s += ",req"
|
s += ",req"
|
||||||
@@ -272,29 +213,14 @@ func (p *Properties) Parse(s string) {
|
|||||||
switch p.Wire {
|
switch p.Wire {
|
||||||
case "varint":
|
case "varint":
|
||||||
p.WireType = WireVarint
|
p.WireType = WireVarint
|
||||||
p.valEnc = (*Buffer).EncodeVarint
|
|
||||||
p.valDec = (*Buffer).DecodeVarint
|
|
||||||
p.valSize = sizeVarint
|
|
||||||
case "fixed32":
|
case "fixed32":
|
||||||
p.WireType = WireFixed32
|
p.WireType = WireFixed32
|
||||||
p.valEnc = (*Buffer).EncodeFixed32
|
|
||||||
p.valDec = (*Buffer).DecodeFixed32
|
|
||||||
p.valSize = sizeFixed32
|
|
||||||
case "fixed64":
|
case "fixed64":
|
||||||
p.WireType = WireFixed64
|
p.WireType = WireFixed64
|
||||||
p.valEnc = (*Buffer).EncodeFixed64
|
|
||||||
p.valDec = (*Buffer).DecodeFixed64
|
|
||||||
p.valSize = sizeFixed64
|
|
||||||
case "zigzag32":
|
case "zigzag32":
|
||||||
p.WireType = WireVarint
|
p.WireType = WireVarint
|
||||||
p.valEnc = (*Buffer).EncodeZigzag32
|
|
||||||
p.valDec = (*Buffer).DecodeZigzag32
|
|
||||||
p.valSize = sizeZigzag32
|
|
||||||
case "zigzag64":
|
case "zigzag64":
|
||||||
p.WireType = WireVarint
|
p.WireType = WireVarint
|
||||||
p.valEnc = (*Buffer).EncodeZigzag64
|
|
||||||
p.valDec = (*Buffer).DecodeZigzag64
|
|
||||||
p.valSize = sizeZigzag64
|
|
||||||
case "bytes", "group":
|
case "bytes", "group":
|
||||||
p.WireType = WireBytes
|
p.WireType = WireBytes
|
||||||
// no numeric converter for non-numeric types
|
// no numeric converter for non-numeric types
|
||||||
@@ -309,6 +235,7 @@ func (p *Properties) Parse(s string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
outer:
|
||||||
for i := 2; i < len(fields); i++ {
|
for i := 2; i < len(fields); i++ {
|
||||||
f := fields[i]
|
f := fields[i]
|
||||||
switch {
|
switch {
|
||||||
@@ -336,7 +263,7 @@ func (p *Properties) Parse(s string) {
|
|||||||
if i+1 < len(fields) {
|
if i+1 < len(fields) {
|
||||||
// Commas aren't escaped, and def is always last.
|
// Commas aren't escaped, and def is always last.
|
||||||
p.Default += "," + strings.Join(fields[i+1:], ",")
|
p.Default += "," + strings.Join(fields[i+1:], ",")
|
||||||
break
|
break outer
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(f, "embedded="):
|
case strings.HasPrefix(f, "embedded="):
|
||||||
p.OrigName = strings.Split(f, "=")[1]
|
p.OrigName = strings.Split(f, "=")[1]
|
||||||
@@ -348,301 +275,58 @@ func (p *Properties) Parse(s string) {
|
|||||||
p.StdTime = true
|
p.StdTime = true
|
||||||
case f == "stdduration":
|
case f == "stdduration":
|
||||||
p.StdDuration = true
|
p.StdDuration = true
|
||||||
|
case f == "wktptr":
|
||||||
|
p.WktPointer = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func logNoSliceEnc(t1, t2 reflect.Type) {
|
|
||||||
fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2)
|
|
||||||
}
|
|
||||||
|
|
||||||
var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem()
|
var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem()
|
||||||
|
|
||||||
// Initialize the fields for encoding and decoding.
|
// setFieldProps initializes the field properties for submessages and maps.
|
||||||
func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) {
|
func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, lockGetProp bool) {
|
||||||
p.enc = nil
|
|
||||||
p.dec = nil
|
|
||||||
p.size = nil
|
|
||||||
isMap := typ.Kind() == reflect.Map
|
isMap := typ.Kind() == reflect.Map
|
||||||
if len(p.CustomType) > 0 && !isMap {
|
if len(p.CustomType) > 0 && !isMap {
|
||||||
p.setCustomEncAndDec(typ)
|
p.ctype = typ
|
||||||
p.setTag(lockGetProp)
|
p.setTag(lockGetProp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if p.StdTime && !isMap {
|
if p.StdTime && !isMap {
|
||||||
p.setTimeEncAndDec(typ)
|
|
||||||
p.setTag(lockGetProp)
|
p.setTag(lockGetProp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if p.StdDuration && !isMap {
|
if p.StdDuration && !isMap {
|
||||||
p.setDurationEncAndDec(typ)
|
p.setTag(lockGetProp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if p.WktPointer && !isMap {
|
||||||
p.setTag(lockGetProp)
|
p.setTag(lockGetProp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch t1 := typ; t1.Kind() {
|
switch t1 := typ; t1.Kind() {
|
||||||
default:
|
|
||||||
fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1)
|
|
||||||
|
|
||||||
// proto3 scalar types
|
|
||||||
|
|
||||||
case reflect.Bool:
|
|
||||||
if p.proto3 {
|
|
||||||
p.enc = (*Buffer).enc_proto3_bool
|
|
||||||
p.dec = (*Buffer).dec_proto3_bool
|
|
||||||
p.size = size_proto3_bool
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_ref_bool
|
|
||||||
p.dec = (*Buffer).dec_proto3_bool
|
|
||||||
p.size = size_ref_bool
|
|
||||||
}
|
|
||||||
case reflect.Int32:
|
|
||||||
if p.proto3 {
|
|
||||||
p.enc = (*Buffer).enc_proto3_int32
|
|
||||||
p.dec = (*Buffer).dec_proto3_int32
|
|
||||||
p.size = size_proto3_int32
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_ref_int32
|
|
||||||
p.dec = (*Buffer).dec_proto3_int32
|
|
||||||
p.size = size_ref_int32
|
|
||||||
}
|
|
||||||
case reflect.Uint32:
|
|
||||||
if p.proto3 {
|
|
||||||
p.enc = (*Buffer).enc_proto3_uint32
|
|
||||||
p.dec = (*Buffer).dec_proto3_int32 // can reuse
|
|
||||||
p.size = size_proto3_uint32
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_ref_uint32
|
|
||||||
p.dec = (*Buffer).dec_proto3_int32 // can reuse
|
|
||||||
p.size = size_ref_uint32
|
|
||||||
}
|
|
||||||
case reflect.Int64, reflect.Uint64:
|
|
||||||
if p.proto3 {
|
|
||||||
p.enc = (*Buffer).enc_proto3_int64
|
|
||||||
p.dec = (*Buffer).dec_proto3_int64
|
|
||||||
p.size = size_proto3_int64
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_ref_int64
|
|
||||||
p.dec = (*Buffer).dec_proto3_int64
|
|
||||||
p.size = size_ref_int64
|
|
||||||
}
|
|
||||||
case reflect.Float32:
|
|
||||||
if p.proto3 {
|
|
||||||
p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits
|
|
||||||
p.dec = (*Buffer).dec_proto3_int32
|
|
||||||
p.size = size_proto3_uint32
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_ref_uint32 // can just treat them as bits
|
|
||||||
p.dec = (*Buffer).dec_proto3_int32
|
|
||||||
p.size = size_ref_uint32
|
|
||||||
}
|
|
||||||
case reflect.Float64:
|
|
||||||
if p.proto3 {
|
|
||||||
p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits
|
|
||||||
p.dec = (*Buffer).dec_proto3_int64
|
|
||||||
p.size = size_proto3_int64
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_ref_int64 // can just treat them as bits
|
|
||||||
p.dec = (*Buffer).dec_proto3_int64
|
|
||||||
p.size = size_ref_int64
|
|
||||||
}
|
|
||||||
case reflect.String:
|
|
||||||
if p.proto3 {
|
|
||||||
p.enc = (*Buffer).enc_proto3_string
|
|
||||||
p.dec = (*Buffer).dec_proto3_string
|
|
||||||
p.size = size_proto3_string
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_ref_string
|
|
||||||
p.dec = (*Buffer).dec_proto3_string
|
|
||||||
p.size = size_ref_string
|
|
||||||
}
|
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
p.stype = typ
|
p.stype = typ
|
||||||
p.isMarshaler = isMarshaler(typ)
|
|
||||||
p.isUnmarshaler = isUnmarshaler(typ)
|
|
||||||
if p.Wire == "bytes" {
|
|
||||||
p.enc = (*Buffer).enc_ref_struct_message
|
|
||||||
p.dec = (*Buffer).dec_ref_struct_message
|
|
||||||
p.size = size_ref_struct_message
|
|
||||||
} else {
|
|
||||||
fmt.Fprintf(os.Stderr, "proto: no coders for struct %T\n", typ)
|
|
||||||
}
|
|
||||||
|
|
||||||
case reflect.Ptr:
|
case reflect.Ptr:
|
||||||
switch t2 := t1.Elem(); t2.Kind() {
|
if t1.Elem().Kind() == reflect.Struct {
|
||||||
default:
|
|
||||||
fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2)
|
|
||||||
break
|
|
||||||
case reflect.Bool:
|
|
||||||
p.enc = (*Buffer).enc_bool
|
|
||||||
p.dec = (*Buffer).dec_bool
|
|
||||||
p.size = size_bool
|
|
||||||
case reflect.Int32:
|
|
||||||
p.enc = (*Buffer).enc_int32
|
|
||||||
p.dec = (*Buffer).dec_int32
|
|
||||||
p.size = size_int32
|
|
||||||
case reflect.Uint32:
|
|
||||||
p.enc = (*Buffer).enc_uint32
|
|
||||||
p.dec = (*Buffer).dec_int32 // can reuse
|
|
||||||
p.size = size_uint32
|
|
||||||
case reflect.Int64, reflect.Uint64:
|
|
||||||
p.enc = (*Buffer).enc_int64
|
|
||||||
p.dec = (*Buffer).dec_int64
|
|
||||||
p.size = size_int64
|
|
||||||
case reflect.Float32:
|
|
||||||
p.enc = (*Buffer).enc_uint32 // can just treat them as bits
|
|
||||||
p.dec = (*Buffer).dec_int32
|
|
||||||
p.size = size_uint32
|
|
||||||
case reflect.Float64:
|
|
||||||
p.enc = (*Buffer).enc_int64 // can just treat them as bits
|
|
||||||
p.dec = (*Buffer).dec_int64
|
|
||||||
p.size = size_int64
|
|
||||||
case reflect.String:
|
|
||||||
p.enc = (*Buffer).enc_string
|
|
||||||
p.dec = (*Buffer).dec_string
|
|
||||||
p.size = size_string
|
|
||||||
case reflect.Struct:
|
|
||||||
p.stype = t1.Elem()
|
p.stype = t1.Elem()
|
||||||
p.isMarshaler = isMarshaler(t1)
|
|
||||||
p.isUnmarshaler = isUnmarshaler(t1)
|
|
||||||
if p.Wire == "bytes" {
|
|
||||||
p.enc = (*Buffer).enc_struct_message
|
|
||||||
p.dec = (*Buffer).dec_struct_message
|
|
||||||
p.size = size_struct_message
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_struct_group
|
|
||||||
p.dec = (*Buffer).dec_struct_group
|
|
||||||
p.size = size_struct_group
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
switch t2 := t1.Elem(); t2.Kind() {
|
switch t2 := t1.Elem(); t2.Kind() {
|
||||||
default:
|
|
||||||
logNoSliceEnc(t1, t2)
|
|
||||||
break
|
|
||||||
case reflect.Bool:
|
|
||||||
if p.Packed {
|
|
||||||
p.enc = (*Buffer).enc_slice_packed_bool
|
|
||||||
p.size = size_slice_packed_bool
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_slice_bool
|
|
||||||
p.size = size_slice_bool
|
|
||||||
}
|
|
||||||
p.dec = (*Buffer).dec_slice_bool
|
|
||||||
p.packedDec = (*Buffer).dec_slice_packed_bool
|
|
||||||
case reflect.Int32:
|
|
||||||
if p.Packed {
|
|
||||||
p.enc = (*Buffer).enc_slice_packed_int32
|
|
||||||
p.size = size_slice_packed_int32
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_slice_int32
|
|
||||||
p.size = size_slice_int32
|
|
||||||
}
|
|
||||||
p.dec = (*Buffer).dec_slice_int32
|
|
||||||
p.packedDec = (*Buffer).dec_slice_packed_int32
|
|
||||||
case reflect.Uint32:
|
|
||||||
if p.Packed {
|
|
||||||
p.enc = (*Buffer).enc_slice_packed_uint32
|
|
||||||
p.size = size_slice_packed_uint32
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_slice_uint32
|
|
||||||
p.size = size_slice_uint32
|
|
||||||
}
|
|
||||||
p.dec = (*Buffer).dec_slice_int32
|
|
||||||
p.packedDec = (*Buffer).dec_slice_packed_int32
|
|
||||||
case reflect.Int64, reflect.Uint64:
|
|
||||||
if p.Packed {
|
|
||||||
p.enc = (*Buffer).enc_slice_packed_int64
|
|
||||||
p.size = size_slice_packed_int64
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_slice_int64
|
|
||||||
p.size = size_slice_int64
|
|
||||||
}
|
|
||||||
p.dec = (*Buffer).dec_slice_int64
|
|
||||||
p.packedDec = (*Buffer).dec_slice_packed_int64
|
|
||||||
case reflect.Uint8:
|
|
||||||
p.dec = (*Buffer).dec_slice_byte
|
|
||||||
if p.proto3 {
|
|
||||||
p.enc = (*Buffer).enc_proto3_slice_byte
|
|
||||||
p.size = size_proto3_slice_byte
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_slice_byte
|
|
||||||
p.size = size_slice_byte
|
|
||||||
}
|
|
||||||
case reflect.Float32, reflect.Float64:
|
|
||||||
switch t2.Bits() {
|
|
||||||
case 32:
|
|
||||||
// can just treat them as bits
|
|
||||||
if p.Packed {
|
|
||||||
p.enc = (*Buffer).enc_slice_packed_uint32
|
|
||||||
p.size = size_slice_packed_uint32
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_slice_uint32
|
|
||||||
p.size = size_slice_uint32
|
|
||||||
}
|
|
||||||
p.dec = (*Buffer).dec_slice_int32
|
|
||||||
p.packedDec = (*Buffer).dec_slice_packed_int32
|
|
||||||
case 64:
|
|
||||||
// can just treat them as bits
|
|
||||||
if p.Packed {
|
|
||||||
p.enc = (*Buffer).enc_slice_packed_int64
|
|
||||||
p.size = size_slice_packed_int64
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_slice_int64
|
|
||||||
p.size = size_slice_int64
|
|
||||||
}
|
|
||||||
p.dec = (*Buffer).dec_slice_int64
|
|
||||||
p.packedDec = (*Buffer).dec_slice_packed_int64
|
|
||||||
default:
|
|
||||||
logNoSliceEnc(t1, t2)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case reflect.String:
|
|
||||||
p.enc = (*Buffer).enc_slice_string
|
|
||||||
p.dec = (*Buffer).dec_slice_string
|
|
||||||
p.size = size_slice_string
|
|
||||||
case reflect.Ptr:
|
case reflect.Ptr:
|
||||||
switch t3 := t2.Elem(); t3.Kind() {
|
switch t3 := t2.Elem(); t3.Kind() {
|
||||||
default:
|
|
||||||
fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3)
|
|
||||||
break
|
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
p.stype = t2.Elem()
|
p.stype = t3
|
||||||
p.isMarshaler = isMarshaler(t2)
|
|
||||||
p.isUnmarshaler = isUnmarshaler(t2)
|
|
||||||
if p.Wire == "bytes" {
|
|
||||||
p.enc = (*Buffer).enc_slice_struct_message
|
|
||||||
p.dec = (*Buffer).dec_slice_struct_message
|
|
||||||
p.size = size_slice_struct_message
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_slice_struct_group
|
|
||||||
p.dec = (*Buffer).dec_slice_struct_group
|
|
||||||
p.size = size_slice_struct_group
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case reflect.Slice:
|
|
||||||
switch t2.Elem().Kind() {
|
|
||||||
default:
|
|
||||||
fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem())
|
|
||||||
break
|
|
||||||
case reflect.Uint8:
|
|
||||||
p.enc = (*Buffer).enc_slice_slice_byte
|
|
||||||
p.dec = (*Buffer).dec_slice_slice_byte
|
|
||||||
p.size = size_slice_slice_byte
|
|
||||||
}
|
}
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
p.setSliceOfNonPointerStructs(t1)
|
p.stype = t2
|
||||||
}
|
}
|
||||||
|
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
p.enc = (*Buffer).enc_new_map
|
|
||||||
p.dec = (*Buffer).dec_new_map
|
|
||||||
p.size = size_new_map
|
|
||||||
|
|
||||||
p.mtype = t1
|
p.mtype = t1
|
||||||
p.mkeyprop = &Properties{}
|
p.MapKeyProp = &Properties{}
|
||||||
p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp)
|
p.MapKeyProp.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp)
|
||||||
p.mvalprop = &Properties{}
|
p.MapValProp = &Properties{}
|
||||||
vtype := p.mtype.Elem()
|
vtype := p.mtype.Elem()
|
||||||
if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice {
|
if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice {
|
||||||
// The value type is not a message (*T) or bytes ([]byte),
|
// The value type is not a message (*T) or bytes ([]byte),
|
||||||
@@ -650,29 +334,16 @@ func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lock
|
|||||||
vtype = reflect.PtrTo(vtype)
|
vtype = reflect.PtrTo(vtype)
|
||||||
}
|
}
|
||||||
|
|
||||||
p.mvalprop.CustomType = p.CustomType
|
p.MapValProp.CustomType = p.CustomType
|
||||||
p.mvalprop.StdDuration = p.StdDuration
|
p.MapValProp.StdDuration = p.StdDuration
|
||||||
p.mvalprop.StdTime = p.StdTime
|
p.MapValProp.StdTime = p.StdTime
|
||||||
p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp)
|
p.MapValProp.WktPointer = p.WktPointer
|
||||||
|
p.MapValProp.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp)
|
||||||
}
|
}
|
||||||
p.setTag(lockGetProp)
|
p.setTag(lockGetProp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Properties) setTag(lockGetProp bool) {
|
func (p *Properties) setTag(lockGetProp bool) {
|
||||||
// precalculate tag code
|
|
||||||
wire := p.WireType
|
|
||||||
if p.Packed {
|
|
||||||
wire = WireBytes
|
|
||||||
}
|
|
||||||
x := uint32(p.Tag)<<3 | uint32(wire)
|
|
||||||
i := 0
|
|
||||||
for i = 0; x > 127; i++ {
|
|
||||||
p.tagbuf[i] = 0x80 | uint8(x&0x7F)
|
|
||||||
x >>= 7
|
|
||||||
}
|
|
||||||
p.tagbuf[i] = uint8(x)
|
|
||||||
p.tagcode = p.tagbuf[0 : i+1]
|
|
||||||
|
|
||||||
if p.stype != nil {
|
if p.stype != nil {
|
||||||
if lockGetProp {
|
if lockGetProp {
|
||||||
p.sprop = GetProperties(p.stype)
|
p.sprop = GetProperties(p.stype)
|
||||||
@@ -683,20 +354,9 @@ func (p *Properties) setTag(lockGetProp bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
|
marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
|
||||||
unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// isMarshaler reports whether type t implements Marshaler.
|
|
||||||
func isMarshaler(t reflect.Type) bool {
|
|
||||||
return t.Implements(marshalerType)
|
|
||||||
}
|
|
||||||
|
|
||||||
// isUnmarshaler reports whether type t implements Unmarshaler.
|
|
||||||
func isUnmarshaler(t reflect.Type) bool {
|
|
||||||
return t.Implements(unmarshalerType)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init populates the properties from a protocol buffer struct tag.
|
// Init populates the properties from a protocol buffer struct tag.
|
||||||
func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) {
|
func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) {
|
||||||
p.init(typ, name, tag, f, true)
|
p.init(typ, name, tag, f, true)
|
||||||
@@ -706,14 +366,11 @@ func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructF
|
|||||||
// "bytes,49,opt,def=hello!"
|
// "bytes,49,opt,def=hello!"
|
||||||
p.Name = name
|
p.Name = name
|
||||||
p.OrigName = name
|
p.OrigName = name
|
||||||
if f != nil {
|
|
||||||
p.field = toField(f)
|
|
||||||
}
|
|
||||||
if tag == "" {
|
if tag == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.Parse(tag)
|
p.Parse(tag)
|
||||||
p.setEncAndDec(typ, f, lockGetProp)
|
p.setFieldProps(typ, f, lockGetProp)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -763,10 +420,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
|
|||||||
propertiesMap[t] = prop
|
propertiesMap[t] = prop
|
||||||
|
|
||||||
// build properties
|
// build properties
|
||||||
prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) ||
|
|
||||||
reflect.PtrTo(t).Implements(extendableProtoV1Type) ||
|
|
||||||
reflect.PtrTo(t).Implements(extendableBytesType)
|
|
||||||
prop.unrecField = invalidField
|
|
||||||
prop.Prop = make([]*Properties, t.NumField())
|
prop.Prop = make([]*Properties, t.NumField())
|
||||||
prop.order = make([]int, t.NumField())
|
prop.order = make([]int, t.NumField())
|
||||||
|
|
||||||
@@ -777,23 +430,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
|
|||||||
name := f.Name
|
name := f.Name
|
||||||
p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false)
|
p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false)
|
||||||
|
|
||||||
if f.Name == "XXX_InternalExtensions" { // special case
|
|
||||||
p.enc = (*Buffer).enc_exts
|
|
||||||
p.dec = nil // not needed
|
|
||||||
p.size = size_exts
|
|
||||||
} else if f.Name == "XXX_extensions" { // special case
|
|
||||||
if len(f.Tag.Get("protobuf")) > 0 {
|
|
||||||
p.enc = (*Buffer).enc_ext_slice_byte
|
|
||||||
p.dec = nil // not needed
|
|
||||||
p.size = size_ext_slice_byte
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_map
|
|
||||||
p.dec = nil // not needed
|
|
||||||
p.size = size_map
|
|
||||||
}
|
|
||||||
} else if f.Name == "XXX_unrecognized" { // special case
|
|
||||||
prop.unrecField = toField(&f)
|
|
||||||
}
|
|
||||||
oneof := f.Tag.Get("protobuf_oneof") // special case
|
oneof := f.Tag.Get("protobuf_oneof") // special case
|
||||||
if oneof != "" {
|
if oneof != "" {
|
||||||
isOneofMessage = true
|
isOneofMessage = true
|
||||||
@@ -809,9 +445,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
|
|||||||
}
|
}
|
||||||
print("\n")
|
print("\n")
|
||||||
}
|
}
|
||||||
if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && oneof == "" {
|
|
||||||
fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-order prop.order.
|
// Re-order prop.order.
|
||||||
@@ -822,8 +455,7 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
|
|||||||
}
|
}
|
||||||
if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok {
|
if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok {
|
||||||
var oots []interface{}
|
var oots []interface{}
|
||||||
prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs()
|
_, _, _, oots = om.XXX_OneofFuncs()
|
||||||
prop.stype = t
|
|
||||||
|
|
||||||
// Interpret oneof metadata.
|
// Interpret oneof metadata.
|
||||||
prop.OneofTypes = make(map[string]*OneofProperties)
|
prop.OneofTypes = make(map[string]*OneofProperties)
|
||||||
@@ -873,30 +505,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
|
|||||||
return prop
|
return prop
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the Properties object for the x[0]'th field of the structure.
|
|
||||||
func propByIndex(t reflect.Type, x []int) *Properties {
|
|
||||||
if len(x) != 1 {
|
|
||||||
fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
prop := GetProperties(t)
|
|
||||||
return prop.Prop[x[0]]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the address and type of a pointer to a struct from an interface.
|
|
||||||
func getbase(pb Message) (t reflect.Type, b structPointer, err error) {
|
|
||||||
if pb == nil {
|
|
||||||
err = ErrNil
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// get the reflect type of the pointer to the struct.
|
|
||||||
t = reflect.TypeOf(pb)
|
|
||||||
// get the address of the struct.
|
|
||||||
value := reflect.ValueOf(pb)
|
|
||||||
b = toStructPointer(value)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// A global registry of enum types.
|
// A global registry of enum types.
|
||||||
// The generated code will register the generated maps by calling RegisterEnum.
|
// The generated code will register the generated maps by calling RegisterEnum.
|
||||||
|
|
||||||
@@ -925,20 +533,42 @@ func EnumValueMap(enumType string) map[string]int32 {
|
|||||||
// A registry of all linked message types.
|
// A registry of all linked message types.
|
||||||
// The string is a fully-qualified proto name ("pkg.Message").
|
// The string is a fully-qualified proto name ("pkg.Message").
|
||||||
var (
|
var (
|
||||||
protoTypes = make(map[string]reflect.Type)
|
protoTypedNils = make(map[string]Message) // a map from proto names to typed nil pointers
|
||||||
revProtoTypes = make(map[reflect.Type]string)
|
protoMapTypes = make(map[string]reflect.Type) // a map from proto names to map types
|
||||||
|
revProtoTypes = make(map[reflect.Type]string)
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterType is called from generated code and maps from the fully qualified
|
// RegisterType is called from generated code and maps from the fully qualified
|
||||||
// proto name to the type (pointer to struct) of the protocol buffer.
|
// proto name to the type (pointer to struct) of the protocol buffer.
|
||||||
func RegisterType(x Message, name string) {
|
func RegisterType(x Message, name string) {
|
||||||
if _, ok := protoTypes[name]; ok {
|
if _, ok := protoTypedNils[name]; ok {
|
||||||
// TODO: Some day, make this a panic.
|
// TODO: Some day, make this a panic.
|
||||||
log.Printf("proto: duplicate proto type registered: %s", name)
|
log.Printf("proto: duplicate proto type registered: %s", name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
t := reflect.TypeOf(x)
|
t := reflect.TypeOf(x)
|
||||||
protoTypes[name] = t
|
if v := reflect.ValueOf(x); v.Kind() == reflect.Ptr && v.Pointer() == 0 {
|
||||||
|
// Generated code always calls RegisterType with nil x.
|
||||||
|
// This check is just for extra safety.
|
||||||
|
protoTypedNils[name] = x
|
||||||
|
} else {
|
||||||
|
protoTypedNils[name] = reflect.Zero(t).Interface().(Message)
|
||||||
|
}
|
||||||
|
revProtoTypes[t] = name
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterMapType is called from generated code and maps from the fully qualified
|
||||||
|
// proto name to the native map type of the proto map definition.
|
||||||
|
func RegisterMapType(x interface{}, name string) {
|
||||||
|
if reflect.TypeOf(x).Kind() != reflect.Map {
|
||||||
|
panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name))
|
||||||
|
}
|
||||||
|
if _, ok := protoMapTypes[name]; ok {
|
||||||
|
log.Printf("proto: duplicate proto type registered: %s", name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t := reflect.TypeOf(x)
|
||||||
|
protoMapTypes[name] = t
|
||||||
revProtoTypes[t] = name
|
revProtoTypes[t] = name
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -954,7 +584,14 @@ func MessageName(x Message) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MessageType returns the message type (pointer to struct) for a named message.
|
// MessageType returns the message type (pointer to struct) for a named message.
|
||||||
func MessageType(name string) reflect.Type { return protoTypes[name] }
|
// The type is not guaranteed to implement proto.Message if the name refers to a
|
||||||
|
// map entry.
|
||||||
|
func MessageType(name string) reflect.Type {
|
||||||
|
if t, ok := protoTypedNils[name]; ok {
|
||||||
|
return reflect.TypeOf(t)
|
||||||
|
}
|
||||||
|
return protoMapTypes[name]
|
||||||
|
}
|
||||||
|
|
||||||
// A registry of all linked proto files.
|
// A registry of all linked proto files.
|
||||||
var (
|
var (
|
||||||
|
|||||||
+3
-78
@@ -1,6 +1,6 @@
|
|||||||
// Protocol Buffers for Go with Gadgets
|
// Protocol Buffers for Go with Gadgets
|
||||||
//
|
//
|
||||||
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
|
||||||
// http://github.com/gogo/protobuf
|
// http://github.com/gogo/protobuf
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -29,83 +29,8 @@
|
|||||||
package proto
|
package proto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *Properties) setCustomEncAndDec(typ reflect.Type) {
|
var sizerType = reflect.TypeOf((*Sizer)(nil)).Elem()
|
||||||
p.ctype = typ
|
var protosizerType = reflect.TypeOf((*ProtoSizer)(nil)).Elem()
|
||||||
if p.Repeated {
|
|
||||||
p.enc = (*Buffer).enc_custom_slice_bytes
|
|
||||||
p.dec = (*Buffer).dec_custom_slice_bytes
|
|
||||||
p.size = size_custom_slice_bytes
|
|
||||||
} else if typ.Kind() == reflect.Ptr {
|
|
||||||
p.enc = (*Buffer).enc_custom_bytes
|
|
||||||
p.dec = (*Buffer).dec_custom_bytes
|
|
||||||
p.size = size_custom_bytes
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_custom_ref_bytes
|
|
||||||
p.dec = (*Buffer).dec_custom_ref_bytes
|
|
||||||
p.size = size_custom_ref_bytes
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Properties) setDurationEncAndDec(typ reflect.Type) {
|
|
||||||
if p.Repeated {
|
|
||||||
if typ.Elem().Kind() == reflect.Ptr {
|
|
||||||
p.enc = (*Buffer).enc_slice_duration
|
|
||||||
p.dec = (*Buffer).dec_slice_duration
|
|
||||||
p.size = size_slice_duration
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_slice_ref_duration
|
|
||||||
p.dec = (*Buffer).dec_slice_ref_duration
|
|
||||||
p.size = size_slice_ref_duration
|
|
||||||
}
|
|
||||||
} else if typ.Kind() == reflect.Ptr {
|
|
||||||
p.enc = (*Buffer).enc_duration
|
|
||||||
p.dec = (*Buffer).dec_duration
|
|
||||||
p.size = size_duration
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_ref_duration
|
|
||||||
p.dec = (*Buffer).dec_ref_duration
|
|
||||||
p.size = size_ref_duration
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Properties) setTimeEncAndDec(typ reflect.Type) {
|
|
||||||
if p.Repeated {
|
|
||||||
if typ.Elem().Kind() == reflect.Ptr {
|
|
||||||
p.enc = (*Buffer).enc_slice_time
|
|
||||||
p.dec = (*Buffer).dec_slice_time
|
|
||||||
p.size = size_slice_time
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_slice_ref_time
|
|
||||||
p.dec = (*Buffer).dec_slice_ref_time
|
|
||||||
p.size = size_slice_ref_time
|
|
||||||
}
|
|
||||||
} else if typ.Kind() == reflect.Ptr {
|
|
||||||
p.enc = (*Buffer).enc_time
|
|
||||||
p.dec = (*Buffer).dec_time
|
|
||||||
p.size = size_time
|
|
||||||
} else {
|
|
||||||
p.enc = (*Buffer).enc_ref_time
|
|
||||||
p.dec = (*Buffer).dec_ref_time
|
|
||||||
p.size = size_ref_time
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Properties) setSliceOfNonPointerStructs(typ reflect.Type) {
|
|
||||||
t2 := typ.Elem()
|
|
||||||
p.sstype = typ
|
|
||||||
p.stype = t2
|
|
||||||
p.isMarshaler = isMarshaler(t2)
|
|
||||||
p.isUnmarshaler = isUnmarshaler(t2)
|
|
||||||
p.enc = (*Buffer).enc_slice_ref_struct_message
|
|
||||||
p.dec = (*Buffer).dec_slice_ref_struct_message
|
|
||||||
p.size = size_slice_ref_struct_message
|
|
||||||
if p.Wire != "bytes" {
|
|
||||||
fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T \n", typ, t2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
regenerate:
|
||||||
|
go install github.com/gogo/protobuf/protoc-min-version
|
||||||
|
protoc-min-version --version="3.0.0" --gogo_out=\
|
||||||
|
Mtest_proto/test.proto=github.com/gogo/protobuf/proto/test_proto,\
|
||||||
|
Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. \
|
||||||
|
--proto_path=../../protobuf:../:. proto3.proto
|
||||||
|
|
||||||
+381
-116
@@ -1,26 +1,13 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: proto3_proto/proto3.proto
|
// source: proto3.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package proto3_proto is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
proto3_proto/proto3.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
Message
|
|
||||||
Nested
|
|
||||||
MessageWithMap
|
|
||||||
IntMap
|
|
||||||
IntMaps
|
|
||||||
*/
|
|
||||||
package proto3_proto
|
package proto3_proto
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
import google_protobuf "github.com/gogo/protobuf/types"
|
import test_proto "github.com/gogo/protobuf/proto/test_proto"
|
||||||
import testdata "github.com/gogo/protobuf/proto/testdata"
|
import types "github.com/gogo/protobuf/types"
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
var _ = proto.Marshal
|
var _ = proto.Marshal
|
||||||
@@ -58,33 +45,58 @@ var Message_Humour_value = map[string]int32{
|
|||||||
func (x Message_Humour) String() string {
|
func (x Message_Humour) String() string {
|
||||||
return proto.EnumName(Message_Humour_name, int32(x))
|
return proto.EnumName(Message_Humour_name, int32(x))
|
||||||
}
|
}
|
||||||
func (Message_Humour) EnumDescriptor() ([]byte, []int) { return fileDescriptorProto3, []int{0, 0} }
|
func (Message_Humour) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_proto3_648c710522dc372e, []int{0, 0}
|
||||||
type Message struct {
|
|
||||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
|
||||||
Hilarity Message_Humour `protobuf:"varint,2,opt,name=hilarity,proto3,enum=proto3_proto.Message_Humour" json:"hilarity,omitempty"`
|
|
||||||
HeightInCm uint32 `protobuf:"varint,3,opt,name=height_in_cm,json=heightInCm,proto3" json:"height_in_cm,omitempty"`
|
|
||||||
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
|
|
||||||
ResultCount int64 `protobuf:"varint,7,opt,name=result_count,json=resultCount,proto3" json:"result_count,omitempty"`
|
|
||||||
TrueScotsman bool `protobuf:"varint,8,opt,name=true_scotsman,json=trueScotsman,proto3" json:"true_scotsman,omitempty"`
|
|
||||||
Score float32 `protobuf:"fixed32,9,opt,name=score,proto3" json:"score,omitempty"`
|
|
||||||
Key []uint64 `protobuf:"varint,5,rep,packed,name=key" json:"key,omitempty"`
|
|
||||||
ShortKey []int32 `protobuf:"varint,19,rep,packed,name=short_key,json=shortKey" json:"short_key,omitempty"`
|
|
||||||
Nested *Nested `protobuf:"bytes,6,opt,name=nested" json:"nested,omitempty"`
|
|
||||||
RFunny []Message_Humour `protobuf:"varint,16,rep,packed,name=r_funny,json=rFunny,enum=proto3_proto.Message_Humour" json:"r_funny,omitempty"`
|
|
||||||
Terrain map[string]*Nested `protobuf:"bytes,10,rep,name=terrain" json:"terrain,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"`
|
|
||||||
Proto2Field *testdata.SubDefaults `protobuf:"bytes,11,opt,name=proto2_field,json=proto2Field" json:"proto2_field,omitempty"`
|
|
||||||
Proto2Value map[string]*testdata.SubDefaults `protobuf:"bytes,13,rep,name=proto2_value,json=proto2Value" json:"proto2_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"`
|
|
||||||
Anything *google_protobuf.Any `protobuf:"bytes,14,opt,name=anything" json:"anything,omitempty"`
|
|
||||||
ManyThings []*google_protobuf.Any `protobuf:"bytes,15,rep,name=many_things,json=manyThings" json:"many_things,omitempty"`
|
|
||||||
Submessage *Message `protobuf:"bytes,17,opt,name=submessage" json:"submessage,omitempty"`
|
|
||||||
Children []*Message `protobuf:"bytes,18,rep,name=children" json:"children,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) Reset() { *m = Message{} }
|
type Message struct {
|
||||||
func (m *Message) String() string { return proto.CompactTextString(m) }
|
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||||
func (*Message) ProtoMessage() {}
|
Hilarity Message_Humour `protobuf:"varint,2,opt,name=hilarity,proto3,enum=proto3_proto.Message_Humour" json:"hilarity,omitempty"`
|
||||||
func (*Message) Descriptor() ([]byte, []int) { return fileDescriptorProto3, []int{0} }
|
HeightInCm uint32 `protobuf:"varint,3,opt,name=height_in_cm,json=heightInCm,proto3" json:"height_in_cm,omitempty"`
|
||||||
|
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
|
||||||
|
ResultCount int64 `protobuf:"varint,7,opt,name=result_count,json=resultCount,proto3" json:"result_count,omitempty"`
|
||||||
|
TrueScotsman bool `protobuf:"varint,8,opt,name=true_scotsman,json=trueScotsman,proto3" json:"true_scotsman,omitempty"`
|
||||||
|
Score float32 `protobuf:"fixed32,9,opt,name=score,proto3" json:"score,omitempty"`
|
||||||
|
Key []uint64 `protobuf:"varint,5,rep,packed,name=key,proto3" json:"key,omitempty"`
|
||||||
|
ShortKey []int32 `protobuf:"varint,19,rep,packed,name=short_key,json=shortKey,proto3" json:"short_key,omitempty"`
|
||||||
|
Nested *Nested `protobuf:"bytes,6,opt,name=nested,proto3" json:"nested,omitempty"`
|
||||||
|
RFunny []Message_Humour `protobuf:"varint,16,rep,packed,name=r_funny,json=rFunny,proto3,enum=proto3_proto.Message_Humour" json:"r_funny,omitempty"`
|
||||||
|
Terrain map[string]*Nested `protobuf:"bytes,10,rep,name=terrain,proto3" json:"terrain,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
|
Proto2Field *test_proto.SubDefaults `protobuf:"bytes,11,opt,name=proto2_field,json=proto2Field,proto3" json:"proto2_field,omitempty"`
|
||||||
|
Proto2Value map[string]*test_proto.SubDefaults `protobuf:"bytes,13,rep,name=proto2_value,json=proto2Value,proto3" json:"proto2_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
|
Anything *types.Any `protobuf:"bytes,14,opt,name=anything,proto3" json:"anything,omitempty"`
|
||||||
|
ManyThings []*types.Any `protobuf:"bytes,15,rep,name=many_things,json=manyThings,proto3" json:"many_things,omitempty"`
|
||||||
|
Submessage *Message `protobuf:"bytes,17,opt,name=submessage,proto3" json:"submessage,omitempty"`
|
||||||
|
Children []*Message `protobuf:"bytes,18,rep,name=children,proto3" json:"children,omitempty"`
|
||||||
|
StringMap map[string]string `protobuf:"bytes,20,rep,name=string_map,json=stringMap,proto3" json:"string_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Message) Reset() { *m = Message{} }
|
||||||
|
func (m *Message) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Message) ProtoMessage() {}
|
||||||
|
func (*Message) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_proto3_648c710522dc372e, []int{0}
|
||||||
|
}
|
||||||
|
func (m *Message) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Message.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Message.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *Message) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Message.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *Message) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Message.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Message) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Message.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Message proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *Message) GetName() string {
|
func (m *Message) GetName() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -170,28 +182,28 @@ func (m *Message) GetTerrain() map[string]*Nested {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) GetProto2Field() *testdata.SubDefaults {
|
func (m *Message) GetProto2Field() *test_proto.SubDefaults {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Proto2Field
|
return m.Proto2Field
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) GetProto2Value() map[string]*testdata.SubDefaults {
|
func (m *Message) GetProto2Value() map[string]*test_proto.SubDefaults {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Proto2Value
|
return m.Proto2Value
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) GetAnything() *google_protobuf.Any {
|
func (m *Message) GetAnything() *types.Any {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Anything
|
return m.Anything
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) GetManyThings() []*google_protobuf.Any {
|
func (m *Message) GetManyThings() []*types.Any {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.ManyThings
|
return m.ManyThings
|
||||||
}
|
}
|
||||||
@@ -212,15 +224,44 @@ func (m *Message) GetChildren() []*Message {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type Nested struct {
|
func (m *Message) GetStringMap() map[string]string {
|
||||||
Bunny string `protobuf:"bytes,1,opt,name=bunny,proto3" json:"bunny,omitempty"`
|
if m != nil {
|
||||||
Cute bool `protobuf:"varint,2,opt,name=cute,proto3" json:"cute,omitempty"`
|
return m.StringMap
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Nested) Reset() { *m = Nested{} }
|
type Nested struct {
|
||||||
func (m *Nested) String() string { return proto.CompactTextString(m) }
|
Bunny string `protobuf:"bytes,1,opt,name=bunny,proto3" json:"bunny,omitempty"`
|
||||||
func (*Nested) ProtoMessage() {}
|
Cute bool `protobuf:"varint,2,opt,name=cute,proto3" json:"cute,omitempty"`
|
||||||
func (*Nested) Descriptor() ([]byte, []int) { return fileDescriptorProto3, []int{1} }
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Nested) Reset() { *m = Nested{} }
|
||||||
|
func (m *Nested) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Nested) ProtoMessage() {}
|
||||||
|
func (*Nested) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_proto3_648c710522dc372e, []int{1}
|
||||||
|
}
|
||||||
|
func (m *Nested) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Nested.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Nested) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Nested.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *Nested) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Nested.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *Nested) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Nested.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Nested) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Nested.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Nested proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *Nested) GetBunny() string {
|
func (m *Nested) GetBunny() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -237,13 +278,35 @@ func (m *Nested) GetCute() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MessageWithMap struct {
|
type MessageWithMap struct {
|
||||||
ByteMapping map[bool][]byte `protobuf:"bytes,1,rep,name=byte_mapping,json=byteMapping" json:"byte_mapping,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
ByteMapping map[bool][]byte `protobuf:"bytes,1,rep,name=byte_mapping,json=byteMapping,proto3" json:"byte_mapping,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageWithMap) Reset() { *m = MessageWithMap{} }
|
func (m *MessageWithMap) Reset() { *m = MessageWithMap{} }
|
||||||
func (m *MessageWithMap) String() string { return proto.CompactTextString(m) }
|
func (m *MessageWithMap) String() string { return proto.CompactTextString(m) }
|
||||||
func (*MessageWithMap) ProtoMessage() {}
|
func (*MessageWithMap) ProtoMessage() {}
|
||||||
func (*MessageWithMap) Descriptor() ([]byte, []int) { return fileDescriptorProto3, []int{2} }
|
func (*MessageWithMap) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_proto3_648c710522dc372e, []int{2}
|
||||||
|
}
|
||||||
|
func (m *MessageWithMap) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_MessageWithMap.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *MessageWithMap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_MessageWithMap.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *MessageWithMap) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_MessageWithMap.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *MessageWithMap) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_MessageWithMap.Size(m)
|
||||||
|
}
|
||||||
|
func (m *MessageWithMap) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_MessageWithMap.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_MessageWithMap proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *MessageWithMap) GetByteMapping() map[bool][]byte {
|
func (m *MessageWithMap) GetByteMapping() map[bool][]byte {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -253,13 +316,35 @@ func (m *MessageWithMap) GetByteMapping() map[bool][]byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IntMap struct {
|
type IntMap struct {
|
||||||
Rtt map[int32]int32 `protobuf:"bytes,1,rep,name=rtt" json:"rtt,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
Rtt map[int32]int32 `protobuf:"bytes,1,rep,name=rtt,proto3" json:"rtt,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *IntMap) Reset() { *m = IntMap{} }
|
func (m *IntMap) Reset() { *m = IntMap{} }
|
||||||
func (m *IntMap) String() string { return proto.CompactTextString(m) }
|
func (m *IntMap) String() string { return proto.CompactTextString(m) }
|
||||||
func (*IntMap) ProtoMessage() {}
|
func (*IntMap) ProtoMessage() {}
|
||||||
func (*IntMap) Descriptor() ([]byte, []int) { return fileDescriptorProto3, []int{3} }
|
func (*IntMap) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_proto3_648c710522dc372e, []int{3}
|
||||||
|
}
|
||||||
|
func (m *IntMap) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_IntMap.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *IntMap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_IntMap.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *IntMap) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_IntMap.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *IntMap) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_IntMap.Size(m)
|
||||||
|
}
|
||||||
|
func (m *IntMap) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_IntMap.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_IntMap proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *IntMap) GetRtt() map[int32]int32 {
|
func (m *IntMap) GetRtt() map[int32]int32 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -269,13 +354,35 @@ func (m *IntMap) GetRtt() map[int32]int32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IntMaps struct {
|
type IntMaps struct {
|
||||||
Maps []*IntMap `protobuf:"bytes,1,rep,name=maps" json:"maps,omitempty"`
|
Maps []*IntMap `protobuf:"bytes,1,rep,name=maps,proto3" json:"maps,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *IntMaps) Reset() { *m = IntMaps{} }
|
func (m *IntMaps) Reset() { *m = IntMaps{} }
|
||||||
func (m *IntMaps) String() string { return proto.CompactTextString(m) }
|
func (m *IntMaps) String() string { return proto.CompactTextString(m) }
|
||||||
func (*IntMaps) ProtoMessage() {}
|
func (*IntMaps) ProtoMessage() {}
|
||||||
func (*IntMaps) Descriptor() ([]byte, []int) { return fileDescriptorProto3, []int{4} }
|
func (*IntMaps) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_proto3_648c710522dc372e, []int{4}
|
||||||
|
}
|
||||||
|
func (m *IntMaps) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_IntMaps.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *IntMaps) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_IntMaps.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *IntMaps) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_IntMaps.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *IntMaps) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_IntMaps.Size(m)
|
||||||
|
}
|
||||||
|
func (m *IntMaps) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_IntMaps.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_IntMaps proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *IntMaps) GetMaps() []*IntMap {
|
func (m *IntMaps) GetMaps() []*IntMap {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -284,63 +391,221 @@ func (m *IntMaps) GetMaps() []*IntMap {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TestUTF8 struct {
|
||||||
|
Scalar string `protobuf:"bytes,1,opt,name=scalar,proto3" json:"scalar,omitempty"`
|
||||||
|
Vector []string `protobuf:"bytes,2,rep,name=vector,proto3" json:"vector,omitempty"`
|
||||||
|
// Types that are valid to be assigned to Oneof:
|
||||||
|
// *TestUTF8_Field
|
||||||
|
Oneof isTestUTF8_Oneof `protobuf_oneof:"oneof"`
|
||||||
|
MapKey map[string]int64 `protobuf:"bytes,4,rep,name=map_key,json=mapKey,proto3" json:"map_key,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
|
MapValue map[int64]string `protobuf:"bytes,5,rep,name=map_value,json=mapValue,proto3" json:"map_value,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TestUTF8) Reset() { *m = TestUTF8{} }
|
||||||
|
func (m *TestUTF8) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*TestUTF8) ProtoMessage() {}
|
||||||
|
func (*TestUTF8) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_proto3_648c710522dc372e, []int{5}
|
||||||
|
}
|
||||||
|
func (m *TestUTF8) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_TestUTF8.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *TestUTF8) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_TestUTF8.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *TestUTF8) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_TestUTF8.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *TestUTF8) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_TestUTF8.Size(m)
|
||||||
|
}
|
||||||
|
func (m *TestUTF8) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_TestUTF8.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_TestUTF8 proto.InternalMessageInfo
|
||||||
|
|
||||||
|
type isTestUTF8_Oneof interface {
|
||||||
|
isTestUTF8_Oneof()
|
||||||
|
}
|
||||||
|
|
||||||
|
type TestUTF8_Field struct {
|
||||||
|
Field string `protobuf:"bytes,3,opt,name=field,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*TestUTF8_Field) isTestUTF8_Oneof() {}
|
||||||
|
|
||||||
|
func (m *TestUTF8) GetOneof() isTestUTF8_Oneof {
|
||||||
|
if m != nil {
|
||||||
|
return m.Oneof
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TestUTF8) GetScalar() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Scalar
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TestUTF8) GetVector() []string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Vector
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TestUTF8) GetField() string {
|
||||||
|
if x, ok := m.GetOneof().(*TestUTF8_Field); ok {
|
||||||
|
return x.Field
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TestUTF8) GetMapKey() map[string]int64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.MapKey
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TestUTF8) GetMapValue() map[int64]string {
|
||||||
|
if m != nil {
|
||||||
|
return m.MapValue
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// XXX_OneofFuncs is for the internal use of the proto package.
|
||||||
|
func (*TestUTF8) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
|
||||||
|
return _TestUTF8_OneofMarshaler, _TestUTF8_OneofUnmarshaler, _TestUTF8_OneofSizer, []interface{}{
|
||||||
|
(*TestUTF8_Field)(nil),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func _TestUTF8_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
|
||||||
|
m := msg.(*TestUTF8)
|
||||||
|
// oneof
|
||||||
|
switch x := m.Oneof.(type) {
|
||||||
|
case *TestUTF8_Field:
|
||||||
|
_ = b.EncodeVarint(3<<3 | proto.WireBytes)
|
||||||
|
_ = b.EncodeStringBytes(x.Field)
|
||||||
|
case nil:
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("TestUTF8.Oneof has unexpected type %T", x)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func _TestUTF8_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
|
||||||
|
m := msg.(*TestUTF8)
|
||||||
|
switch tag {
|
||||||
|
case 3: // oneof.field
|
||||||
|
if wire != proto.WireBytes {
|
||||||
|
return true, proto.ErrInternalBadWireType
|
||||||
|
}
|
||||||
|
x, err := b.DecodeStringBytes()
|
||||||
|
m.Oneof = &TestUTF8_Field{x}
|
||||||
|
return true, err
|
||||||
|
default:
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func _TestUTF8_OneofSizer(msg proto.Message) (n int) {
|
||||||
|
m := msg.(*TestUTF8)
|
||||||
|
// oneof
|
||||||
|
switch x := m.Oneof.(type) {
|
||||||
|
case *TestUTF8_Field:
|
||||||
|
n += 1 // tag and wire
|
||||||
|
n += proto.SizeVarint(uint64(len(x.Field)))
|
||||||
|
n += len(x.Field)
|
||||||
|
case nil:
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*Message)(nil), "proto3_proto.Message")
|
proto.RegisterType((*Message)(nil), "proto3_proto.Message")
|
||||||
|
proto.RegisterMapType((map[string]*test_proto.SubDefaults)(nil), "proto3_proto.Message.Proto2ValueEntry")
|
||||||
|
proto.RegisterMapType((map[string]string)(nil), "proto3_proto.Message.StringMapEntry")
|
||||||
|
proto.RegisterMapType((map[string]*Nested)(nil), "proto3_proto.Message.TerrainEntry")
|
||||||
proto.RegisterType((*Nested)(nil), "proto3_proto.Nested")
|
proto.RegisterType((*Nested)(nil), "proto3_proto.Nested")
|
||||||
proto.RegisterType((*MessageWithMap)(nil), "proto3_proto.MessageWithMap")
|
proto.RegisterType((*MessageWithMap)(nil), "proto3_proto.MessageWithMap")
|
||||||
|
proto.RegisterMapType((map[bool][]byte)(nil), "proto3_proto.MessageWithMap.ByteMappingEntry")
|
||||||
proto.RegisterType((*IntMap)(nil), "proto3_proto.IntMap")
|
proto.RegisterType((*IntMap)(nil), "proto3_proto.IntMap")
|
||||||
|
proto.RegisterMapType((map[int32]int32)(nil), "proto3_proto.IntMap.RttEntry")
|
||||||
proto.RegisterType((*IntMaps)(nil), "proto3_proto.IntMaps")
|
proto.RegisterType((*IntMaps)(nil), "proto3_proto.IntMaps")
|
||||||
|
proto.RegisterType((*TestUTF8)(nil), "proto3_proto.TestUTF8")
|
||||||
|
proto.RegisterMapType((map[string]int64)(nil), "proto3_proto.TestUTF8.MapKeyEntry")
|
||||||
|
proto.RegisterMapType((map[int64]string)(nil), "proto3_proto.TestUTF8.MapValueEntry")
|
||||||
proto.RegisterEnum("proto3_proto.Message_Humour", Message_Humour_name, Message_Humour_value)
|
proto.RegisterEnum("proto3_proto.Message_Humour", Message_Humour_name, Message_Humour_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("proto3_proto/proto3.proto", fileDescriptorProto3) }
|
func init() { proto.RegisterFile("proto3.proto", fileDescriptor_proto3_648c710522dc372e) }
|
||||||
|
|
||||||
var fileDescriptorProto3 = []byte{
|
var fileDescriptor_proto3_648c710522dc372e = []byte{
|
||||||
// 733 bytes of a gzipped FileDescriptorProto
|
// 891 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x6d, 0x6f, 0xf3, 0x34,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xff, 0x8e, 0xdb, 0x44,
|
||||||
0x14, 0x25, 0x4d, 0x5f, 0xd2, 0x9b, 0x74, 0x0b, 0x5e, 0x91, 0xbc, 0x02, 0x52, 0x28, 0x12, 0x8a,
|
0x10, 0xae, 0xe3, 0xfc, 0x70, 0x26, 0xc9, 0x35, 0x2c, 0x69, 0x59, 0x02, 0x48, 0x26, 0x20, 0x64,
|
||||||
0x78, 0x49, 0xa1, 0xd3, 0xd0, 0x84, 0x10, 0x68, 0x1b, 0x9b, 0xa8, 0xd6, 0x95, 0xca, 0xdd, 0x98,
|
0x21, 0xea, 0x83, 0x54, 0x87, 0x8e, 0xb6, 0x02, 0xdd, 0x1d, 0x3d, 0x35, 0xba, 0x4b, 0x88, 0x36,
|
||||||
0xf8, 0x14, 0xa5, 0xad, 0xdb, 0x46, 0x34, 0x4e, 0x49, 0x1c, 0xa4, 0xfc, 0x1d, 0xfe, 0x28, 0x8f,
|
0x39, 0x4e, 0xfc, 0x65, 0x6d, 0x72, 0x9b, 0xc4, 0x22, 0x5e, 0x07, 0xef, 0xba, 0x92, 0x5f, 0x80,
|
||||||
0x6c, 0xa7, 0x5d, 0x36, 0x65, 0xcf, 0xf3, 0x29, 0xf6, 0xf1, 0xb9, 0xf7, 0x9c, 0x1c, 0x5f, 0xc3,
|
0x07, 0xe1, 0x95, 0x78, 0x21, 0xb4, 0xbb, 0xce, 0xd5, 0xa9, 0x5c, 0xee, 0x2f, 0xef, 0x7c, 0xfe,
|
||||||
0xe9, 0x2e, 0x89, 0x79, 0x7c, 0xe6, 0xcb, 0xcf, 0x40, 0x6d, 0x3c, 0xf9, 0x41, 0x56, 0xf9, 0xa8,
|
0x66, 0xbe, 0xd9, 0x99, 0xd9, 0x81, 0xf6, 0x2e, 0x89, 0x65, 0xfc, 0xdc, 0xd7, 0x1f, 0x94, 0x5b,
|
||||||
0x77, 0xba, 0x8e, 0xe3, 0xf5, 0x96, 0x2a, 0xca, 0x3c, 0x5b, 0x0d, 0x02, 0x96, 0x2b, 0x62, 0xef,
|
0x81, 0xfe, 0xf4, 0x3f, 0x5d, 0xc7, 0xf1, 0x7a, 0xcb, 0x8e, 0xb5, 0xb5, 0x48, 0x57, 0xc7, 0x94,
|
||||||
0x84, 0xd3, 0x94, 0x2f, 0x03, 0x1e, 0x0c, 0xc4, 0x42, 0x81, 0xfd, 0xff, 0x5b, 0xd0, 0xba, 0xa7,
|
0x67, 0x86, 0xd8, 0x7f, 0x22, 0x99, 0x90, 0x86, 0x76, 0xac, 0x8e, 0x06, 0x1e, 0xfc, 0xdd, 0x84,
|
||||||
0x69, 0x1a, 0xac, 0x29, 0x42, 0x50, 0x67, 0x41, 0x44, 0xb1, 0xe6, 0x68, 0x6e, 0x9b, 0xc8, 0x35,
|
0xc6, 0x98, 0x09, 0x41, 0xd7, 0x0c, 0x21, 0xa8, 0x72, 0x1a, 0x31, 0x6c, 0xb9, 0x96, 0xd7, 0x24,
|
||||||
0xba, 0x00, 0x63, 0x13, 0x6e, 0x83, 0x24, 0xe4, 0x39, 0xae, 0x39, 0x9a, 0x7b, 0x34, 0xfc, 0xcc,
|
0xfa, 0x8c, 0x4e, 0xc1, 0xd9, 0x84, 0x5b, 0x9a, 0x84, 0x32, 0xc3, 0x15, 0xd7, 0xf2, 0x8e, 0x86,
|
||||||
0x2b, 0x0b, 0x7a, 0x45, 0xb1, 0xf7, 0x7b, 0x16, 0xc5, 0x59, 0x42, 0x0e, 0x6c, 0xe4, 0x80, 0xb5,
|
0x9f, 0xfb, 0x45, 0x49, 0x3f, 0x77, 0xf6, 0xdf, 0xa4, 0x51, 0x9c, 0x26, 0xe4, 0x9e, 0x8d, 0x5c,
|
||||||
0xa1, 0xe1, 0x7a, 0xc3, 0xfd, 0x90, 0xf9, 0x8b, 0x08, 0xeb, 0x8e, 0xe6, 0x76, 0x08, 0x28, 0x6c,
|
0x68, 0x6f, 0x58, 0xb8, 0xde, 0xc8, 0x20, 0xe4, 0xc1, 0x32, 0xc2, 0xb6, 0x6b, 0x79, 0x1d, 0x02,
|
||||||
0xc4, 0xae, 0x23, 0xa1, 0x27, 0xec, 0xe0, 0xba, 0xa3, 0xb9, 0x16, 0x91, 0x6b, 0xf4, 0x05, 0x58,
|
0x06, 0x1b, 0xf1, 0x8b, 0x48, 0xe9, 0xdd, 0x51, 0x49, 0x71, 0xd5, 0xb5, 0xbc, 0x36, 0xd1, 0x67,
|
||||||
0x09, 0x4d, 0xb3, 0x2d, 0xf7, 0x17, 0x71, 0xc6, 0x38, 0x6e, 0x39, 0x9a, 0xab, 0x13, 0x53, 0x61,
|
0xf4, 0x25, 0xb4, 0x13, 0x26, 0xd2, 0xad, 0x0c, 0x96, 0x71, 0xca, 0x25, 0x6e, 0xb8, 0x96, 0x67,
|
||||||
0xd7, 0x02, 0x42, 0x5f, 0x42, 0x87, 0x27, 0x19, 0xf5, 0xd3, 0x45, 0xcc, 0xd3, 0x28, 0x60, 0xd8,
|
0x93, 0x96, 0xc1, 0x2e, 0x14, 0x84, 0xbe, 0x82, 0x8e, 0x4c, 0x52, 0x16, 0x88, 0x65, 0x2c, 0x45,
|
||||||
0x70, 0x34, 0xd7, 0x20, 0x96, 0x00, 0x67, 0x05, 0x86, 0xba, 0xd0, 0x48, 0x17, 0x71, 0x42, 0x71,
|
0x44, 0x39, 0x76, 0x5c, 0xcb, 0x73, 0x48, 0x5b, 0x81, 0xb3, 0x1c, 0x43, 0x3d, 0xa8, 0x89, 0x65,
|
||||||
0xdb, 0xd1, 0xdc, 0x1a, 0x51, 0x1b, 0x64, 0x83, 0xfe, 0x37, 0xcd, 0x71, 0xc3, 0xd1, 0xdd, 0x3a,
|
0x9c, 0x30, 0xdc, 0x74, 0x2d, 0xaf, 0x42, 0x8c, 0x81, 0xba, 0x60, 0xff, 0xc9, 0x32, 0x5c, 0x73,
|
||||||
0x11, 0x4b, 0xf4, 0x29, 0xb4, 0xd3, 0x4d, 0x9c, 0x70, 0x5f, 0xe0, 0x27, 0x8e, 0xee, 0x36, 0x88,
|
0x6d, 0xaf, 0x4a, 0xd4, 0x11, 0x7d, 0x06, 0x4d, 0xb1, 0x89, 0x13, 0x19, 0x28, 0xfc, 0x63, 0xd7,
|
||||||
0x21, 0x81, 0x3b, 0x9a, 0xa3, 0x6f, 0xa1, 0xc9, 0x68, 0xca, 0xe9, 0x12, 0x37, 0x1d, 0xcd, 0x35,
|
0xf6, 0x6a, 0xc4, 0xd1, 0xc0, 0x15, 0xcb, 0xd0, 0x77, 0x50, 0xe7, 0x4c, 0x48, 0x76, 0x87, 0xeb,
|
||||||
0x87, 0xdd, 0x97, 0xbf, 0x3e, 0x91, 0x67, 0xa4, 0xe0, 0xa0, 0x73, 0x68, 0x25, 0xfe, 0x2a, 0x63,
|
0xae, 0xe5, 0xb5, 0x86, 0xbd, 0xc3, 0xab, 0x4f, 0xf4, 0x3f, 0x92, 0x73, 0xd0, 0x09, 0x34, 0x92,
|
||||||
0x2c, 0xc7, 0xb6, 0xa3, 0x7f, 0x30, 0xa9, 0x66, 0x72, 0x2b, 0xb8, 0xe8, 0x67, 0x68, 0x71, 0x9a,
|
0x60, 0x95, 0x72, 0x9e, 0xe1, 0xae, 0x6b, 0x3f, 0x58, 0xa9, 0x7a, 0x72, 0xa9, 0xb8, 0xe8, 0x15,
|
||||||
0x24, 0x41, 0xc8, 0x30, 0x38, 0xba, 0x6b, 0x0e, 0xfb, 0xd5, 0x65, 0x0f, 0x8a, 0x74, 0xc3, 0x78,
|
0x34, 0x24, 0x4b, 0x12, 0x1a, 0x72, 0x0c, 0xae, 0xed, 0xb5, 0x86, 0x83, 0x72, 0xb7, 0xb9, 0x21,
|
||||||
0x92, 0x93, 0x7d, 0x09, 0xba, 0x00, 0x75, 0xff, 0x43, 0x7f, 0x15, 0xd2, 0xed, 0x12, 0x9b, 0xd2,
|
0xbd, 0xe6, 0x32, 0xc9, 0xc8, 0xde, 0x05, 0xbd, 0xc8, 0xe7, 0x61, 0x18, 0xac, 0x42, 0xb6, 0xbd,
|
||||||
0xe8, 0x27, 0xde, 0xfe, 0xae, 0xbd, 0x59, 0x36, 0xff, 0x8d, 0xae, 0x82, 0x6c, 0xcb, 0x53, 0x62,
|
0xc3, 0x2d, 0x9d, 0xe8, 0x27, 0xfe, 0xbb, 0x6e, 0xfb, 0xb3, 0x74, 0xf1, 0x2b, 0x5b, 0xd1, 0x74,
|
||||||
0x2a, 0xea, 0xad, 0x60, 0xa2, 0xd1, 0xa1, 0xf2, 0xdf, 0x60, 0x9b, 0x51, 0xdc, 0x91, 0xe2, 0x5f,
|
0x2b, 0x05, 0x69, 0x19, 0xf2, 0xa5, 0xe2, 0xa2, 0xd1, 0xbd, 0xef, 0x5b, 0xba, 0x4d, 0x19, 0xee,
|
||||||
0x55, 0x8b, 0x4f, 0x25, 0xf3, 0x4f, 0x41, 0x54, 0x06, 0x8a, 0x56, 0x12, 0x41, 0xdf, 0x83, 0x11,
|
0x68, 0xf9, 0x6f, 0xca, 0xe5, 0xa7, 0x9a, 0xf9, 0xbb, 0x22, 0x9a, 0x14, 0xf2, 0x50, 0x1a, 0x41,
|
||||||
0xb0, 0x9c, 0x6f, 0x42, 0xb6, 0xc6, 0x47, 0x45, 0x52, 0x6a, 0x0e, 0xbd, 0xfd, 0x1c, 0x7a, 0x97,
|
0xdf, 0x83, 0x43, 0x79, 0x26, 0x37, 0x21, 0x5f, 0xe3, 0xa3, 0xbc, 0x56, 0x66, 0x16, 0xfd, 0xfd,
|
||||||
0x2c, 0x27, 0x07, 0x16, 0x3a, 0x07, 0x33, 0x0a, 0x58, 0xee, 0xcb, 0x5d, 0x8a, 0x8f, 0xa5, 0x76,
|
0x2c, 0xfa, 0x67, 0x3c, 0x23, 0xf7, 0x2c, 0x74, 0x02, 0xad, 0x88, 0xf2, 0x2c, 0xd0, 0x96, 0xc0,
|
||||||
0x75, 0x11, 0x08, 0xe2, 0x83, 0xe4, 0xa1, 0x73, 0x80, 0x34, 0x9b, 0x47, 0xca, 0x14, 0xfe, 0xb8,
|
0x8f, 0xb5, 0x76, 0xb9, 0x13, 0x28, 0xe2, 0x5c, 0xf3, 0xd0, 0x09, 0x80, 0x48, 0x17, 0x91, 0x49,
|
||||||
0xf8, 0xd7, 0x2a, 0xc7, 0xa4, 0x44, 0x44, 0x3f, 0x80, 0xb1, 0xd8, 0x84, 0xdb, 0x65, 0x42, 0x19,
|
0x0a, 0x7f, 0xa4, 0xa5, 0x9e, 0x94, 0x66, 0x4c, 0x0a, 0x44, 0xf4, 0x03, 0x38, 0xcb, 0x4d, 0xb8,
|
||||||
0x46, 0x52, 0xea, 0x8d, 0xa2, 0x03, 0xad, 0x37, 0x05, 0xab, 0x1c, 0xf8, 0x7e, 0x72, 0xd4, 0xd3,
|
0xbd, 0x4b, 0x18, 0xc7, 0x48, 0x4b, 0x7d, 0xc0, 0xe9, 0x9e, 0x86, 0x2e, 0x00, 0x84, 0x4c, 0x42,
|
||||||
0x90, 0x93, 0xf3, 0x35, 0x34, 0x54, 0x70, 0xb5, 0xf7, 0xcc, 0x86, 0xa2, 0xfc, 0x54, 0xbb, 0xd0,
|
0xbe, 0x0e, 0x22, 0xba, 0xc3, 0x3d, 0xed, 0xf4, 0x75, 0x79, 0x6d, 0x66, 0x9a, 0x37, 0xa6, 0x3b,
|
||||||
0x7a, 0x8f, 0x60, 0xbf, 0x4e, 0xb1, 0xa2, 0xeb, 0x37, 0x2f, 0xbb, 0xbe, 0x71, 0x91, 0xcf, 0x6d,
|
0x53, 0x99, 0xa6, 0xd8, 0xdb, 0xfd, 0x29, 0xb4, 0x8b, 0x7d, 0xdb, 0x0f, 0xa0, 0x79, 0x61, 0x7a,
|
||||||
0xfb, 0xbf, 0x42, 0x53, 0x0d, 0x14, 0x32, 0xa1, 0xf5, 0x38, 0xb9, 0x9b, 0xfc, 0xf1, 0x34, 0xb1,
|
0x00, 0xbf, 0x85, 0x9a, 0xa9, 0x7e, 0xe5, 0x7f, 0x46, 0xcc, 0x50, 0x5e, 0x54, 0x4e, 0xad, 0xfe,
|
||||||
0x3f, 0x42, 0x06, 0xd4, 0xa7, 0x8f, 0x93, 0x99, 0xad, 0xa1, 0x0e, 0xb4, 0x67, 0xe3, 0xcb, 0xe9,
|
0x2d, 0x74, 0xdf, 0x6f, 0x45, 0x49, 0xd4, 0x67, 0x87, 0x51, 0x3f, 0x38, 0x0f, 0x85, 0xc0, 0xaf,
|
||||||
0xec, 0x61, 0x74, 0x7d, 0x67, 0xd7, 0xd0, 0x31, 0x98, 0x57, 0xa3, 0xf1, 0xd8, 0xbf, 0xba, 0x1c,
|
0xe0, 0xe8, 0xf0, 0x1e, 0x25, 0x61, 0x7b, 0xc5, 0xb0, 0xcd, 0x82, 0xf7, 0xe0, 0x17, 0xa8, 0x9b,
|
||||||
0x8d, 0x6f, 0xfe, 0xb2, 0xf5, 0xfe, 0x10, 0x9a, 0xca, 0xac, 0x78, 0x33, 0x73, 0x39, 0xbe, 0xca,
|
0xb9, 0x46, 0x2d, 0x68, 0xdc, 0x4c, 0xae, 0x26, 0xbf, 0xdd, 0x4e, 0xba, 0x8f, 0x90, 0x03, 0xd5,
|
||||||
0x8f, 0xda, 0x88, 0x57, 0xba, 0xc8, 0xb8, 0x32, 0x64, 0x10, 0xb9, 0xee, 0xff, 0xa7, 0xc1, 0x51,
|
0xe9, 0xcd, 0x64, 0xd6, 0xb5, 0x50, 0x07, 0x9a, 0xb3, 0xeb, 0xb3, 0xe9, 0x6c, 0x3e, 0xba, 0xb8,
|
||||||
0x91, 0xd9, 0x53, 0xc8, 0x37, 0xf7, 0xc1, 0x0e, 0x4d, 0xc1, 0x9a, 0xe7, 0x9c, 0xfa, 0x51, 0xb0,
|
0xea, 0x56, 0xd0, 0x63, 0x68, 0x9d, 0x8f, 0xae, 0xaf, 0x83, 0xf3, 0xb3, 0xd1, 0xf5, 0xeb, 0x3f,
|
||||||
0xdb, 0x89, 0x39, 0xd0, 0x64, 0xce, 0xdf, 0x55, 0xe6, 0x5c, 0xd4, 0x78, 0x57, 0x39, 0xa7, 0xf7,
|
0xba, 0xf6, 0x60, 0x08, 0x75, 0x73, 0x59, 0x25, 0xb2, 0xd0, 0xaf, 0xc8, 0x08, 0x1b, 0x43, 0x2d,
|
||||||
0x8a, 0x5f, 0x4c, 0xd5, 0xfc, 0x19, 0xe9, 0xfd, 0x02, 0xf6, 0x6b, 0x42, 0x39, 0x30, 0x43, 0x05,
|
0x8b, 0x65, 0x2a, 0x8d, 0xb2, 0x43, 0xf4, 0x79, 0xf0, 0x8f, 0x05, 0x47, 0x79, 0x0f, 0x6e, 0x43,
|
||||||
0xd6, 0x2d, 0x07, 0x66, 0x95, 0x93, 0xf9, 0x07, 0x9a, 0x23, 0xc6, 0x85, 0xb7, 0x01, 0xe8, 0x09,
|
0xb9, 0x19, 0xd3, 0x1d, 0x9a, 0x42, 0x7b, 0x91, 0x49, 0xa6, 0x7a, 0xb6, 0x53, 0xc3, 0x68, 0xe9,
|
||||||
0xe7, 0x85, 0xa5, 0xcf, 0x5f, 0x5a, 0x52, 0x14, 0x8f, 0x70, 0xae, 0x2c, 0x08, 0x66, 0xef, 0x47,
|
0xbe, 0x3d, 0x2b, 0xed, 0x5b, 0xee, 0xe3, 0x9f, 0x67, 0x92, 0x8d, 0x0d, 0x3f, 0x1f, 0xed, 0xc5,
|
||||||
0x30, 0xf6, 0x40, 0x59, 0xb2, 0x51, 0x21, 0xd9, 0x28, 0x4b, 0x9e, 0x41, 0x4b, 0xf5, 0x4b, 0x91,
|
0x3b, 0xa4, 0xff, 0x33, 0x74, 0xdf, 0x27, 0x14, 0x2b, 0xe3, 0x94, 0x54, 0xa6, 0x5d, 0xac, 0xcc,
|
||||||
0x0b, 0xf5, 0x28, 0xd8, 0xa5, 0x85, 0x68, 0xb7, 0x4a, 0x94, 0x48, 0xc6, 0xbc, 0xa9, 0x8e, 0xde,
|
0x5f, 0x50, 0x1f, 0x71, 0xa9, 0x72, 0x3b, 0x06, 0x3b, 0x91, 0x32, 0x4f, 0xe9, 0x8b, 0xc3, 0x94,
|
||||||
0x05, 0x00, 0x00, 0xff, 0xff, 0x75, 0x38, 0xad, 0x84, 0xe4, 0x05, 0x00, 0x00,
|
0x0c, 0xc5, 0x27, 0x52, 0x9a, 0x14, 0x14, 0xb3, 0xff, 0x23, 0x38, 0x7b, 0xa0, 0x28, 0x59, 0x2b,
|
||||||
|
0x91, 0xac, 0x15, 0x25, 0x9f, 0x43, 0xc3, 0xc4, 0x13, 0xc8, 0x83, 0x6a, 0x44, 0x77, 0x22, 0x17,
|
||||||
|
0xed, 0x95, 0x89, 0x12, 0xcd, 0x18, 0xfc, 0x5b, 0x01, 0x67, 0xce, 0x84, 0xbc, 0x99, 0x5f, 0x9e,
|
||||||
|
0xa2, 0xa7, 0x50, 0x17, 0x4b, 0xba, 0xa5, 0x49, 0xde, 0x84, 0xdc, 0x52, 0xf8, 0x5b, 0xb6, 0x94,
|
||||||
|
0x71, 0x82, 0x2b, 0xae, 0xad, 0x70, 0x63, 0xa1, 0xa7, 0x50, 0x33, 0xfb, 0x47, 0x6d, 0xf9, 0xe6,
|
||||||
|
0x9b, 0x47, 0xc4, 0x98, 0xe8, 0x25, 0x34, 0x22, 0xba, 0xd3, 0xcb, 0xb5, 0x5a, 0xb6, 0xdc, 0xf6,
|
||||||
|
0x82, 0xfe, 0x98, 0xee, 0xae, 0x58, 0x66, 0xee, 0x5e, 0x8f, 0xb4, 0x81, 0xce, 0xa0, 0xa9, 0x9c,
|
||||||
|
0xcd, 0x25, 0x6b, 0x65, 0x0f, 0xb0, 0xe8, 0x5e, 0x58, 0x4d, 0x4e, 0x94, 0x9b, 0xfd, 0x9f, 0xa0,
|
||||||
|
0x55, 0x88, 0xfc, 0xd0, 0x44, 0xdb, 0xc5, 0xf7, 0xf0, 0x12, 0x3a, 0x07, 0x51, 0x8b, 0xce, 0xf6,
|
||||||
|
0x03, 0xcf, 0xe1, 0xbc, 0x01, 0xb5, 0x98, 0xb3, 0x78, 0xb5, 0xa8, 0x9b, 0x7c, 0xff, 0x0b, 0x00,
|
||||||
|
0x00, 0xff, 0xff, 0x0e, 0x22, 0xea, 0x15, 0xb6, 0x07, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-4
@@ -32,7 +32,7 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
import "google/protobuf/any.proto";
|
import "google/protobuf/any.proto";
|
||||||
import "testdata/test.proto";
|
import "test_proto/test.proto";
|
||||||
|
|
||||||
package proto3_proto;
|
package proto3_proto;
|
||||||
|
|
||||||
@@ -58,14 +58,16 @@ message Message {
|
|||||||
repeated Humour r_funny = 16;
|
repeated Humour r_funny = 16;
|
||||||
|
|
||||||
map<string, Nested> terrain = 10;
|
map<string, Nested> terrain = 10;
|
||||||
testdata.SubDefaults proto2_field = 11;
|
test_proto.SubDefaults proto2_field = 11;
|
||||||
map<string, testdata.SubDefaults> proto2_value = 13;
|
map<string, test_proto.SubDefaults> proto2_value = 13;
|
||||||
|
|
||||||
google.protobuf.Any anything = 14;
|
google.protobuf.Any anything = 14;
|
||||||
repeated google.protobuf.Any many_things = 15;
|
repeated google.protobuf.Any many_things = 15;
|
||||||
|
|
||||||
Message submessage = 17;
|
Message submessage = 17;
|
||||||
repeated Message children = 18;
|
repeated Message children = 18;
|
||||||
|
|
||||||
|
map<string, string> string_map = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Nested {
|
message Nested {
|
||||||
@@ -84,4 +86,12 @@ message IntMap {
|
|||||||
|
|
||||||
message IntMaps {
|
message IntMaps {
|
||||||
repeated IntMap maps = 1;
|
repeated IntMap maps = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message TestUTF8 {
|
||||||
|
string scalar = 1;
|
||||||
|
repeated string vector = 2;
|
||||||
|
oneof oneof { string field = 3; }
|
||||||
|
map<string, int64> map_key = 4;
|
||||||
|
map<int64, string> map_value = 5;
|
||||||
|
}
|
||||||
|
|||||||
+3006
File diff suppressed because it is too large
Load Diff
+388
@@ -0,0 +1,388 @@
|
|||||||
|
// Protocol Buffers for Go with Gadgets
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
|
||||||
|
// http://github.com/gogo/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
package proto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// makeMessageRefMarshaler differs a bit from makeMessageMarshaler
|
||||||
|
// It marshal a message T instead of a *T
|
||||||
|
func makeMessageRefMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
siz := u.size(ptr)
|
||||||
|
return siz + SizeVarint(uint64(siz)) + tagsize
|
||||||
|
},
|
||||||
|
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
siz := u.cachedsize(ptr)
|
||||||
|
b = appendVarint(b, uint64(siz))
|
||||||
|
return u.marshal(b, ptr, deterministic)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// makeMessageRefSliceMarshaler differs quite a lot from makeMessageSliceMarshaler
|
||||||
|
// It marshals a slice of messages []T instead of []*T
|
||||||
|
func makeMessageRefSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
s := ptr.getSlice(u.typ)
|
||||||
|
n := 0
|
||||||
|
for i := 0; i < s.Len(); i++ {
|
||||||
|
elem := s.Index(i)
|
||||||
|
e := elem.Interface()
|
||||||
|
v := toAddrPointer(&e, false)
|
||||||
|
siz := u.size(v)
|
||||||
|
n += siz + SizeVarint(uint64(siz)) + tagsize
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
},
|
||||||
|
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
s := ptr.getSlice(u.typ)
|
||||||
|
var err, errreq error
|
||||||
|
for i := 0; i < s.Len(); i++ {
|
||||||
|
elem := s.Index(i)
|
||||||
|
e := elem.Interface()
|
||||||
|
v := toAddrPointer(&e, false)
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
siz := u.size(v)
|
||||||
|
b = appendVarint(b, uint64(siz))
|
||||||
|
b, err = u.marshal(b, v, deterministic)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if _, ok := err.(*RequiredNotSetError); ok {
|
||||||
|
// Required field in submessage is not set.
|
||||||
|
// We record the error but keep going, to give a complete marshaling.
|
||||||
|
if errreq == nil {
|
||||||
|
errreq = err
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err == ErrNil {
|
||||||
|
err = errRepeatedHasNil
|
||||||
|
}
|
||||||
|
return b, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return b, errreq
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeCustomPtrMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
if ptr.isNil() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
m := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(custom)
|
||||||
|
siz := m.Size()
|
||||||
|
return tagsize + SizeVarint(uint64(siz)) + siz
|
||||||
|
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
if ptr.isNil() {
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
m := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(custom)
|
||||||
|
siz := m.Size()
|
||||||
|
buf, err := m.Marshal()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(siz))
|
||||||
|
b = append(b, buf...)
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeCustomMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
m := ptr.asPointerTo(u.typ).Interface().(custom)
|
||||||
|
siz := m.Size()
|
||||||
|
return tagsize + SizeVarint(uint64(siz)) + siz
|
||||||
|
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
m := ptr.asPointerTo(u.typ).Interface().(custom)
|
||||||
|
siz := m.Size()
|
||||||
|
buf, err := m.Marshal()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(siz))
|
||||||
|
b = append(b, buf...)
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeTimeMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
t := ptr.asPointerTo(u.typ).Interface().(*time.Time)
|
||||||
|
ts, err := timestampProto(*t)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
siz := Size(ts)
|
||||||
|
return tagsize + SizeVarint(uint64(siz)) + siz
|
||||||
|
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
t := ptr.asPointerTo(u.typ).Interface().(*time.Time)
|
||||||
|
ts, err := timestampProto(*t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
buf, err := Marshal(ts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(len(buf)))
|
||||||
|
b = append(b, buf...)
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeTimePtrMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
if ptr.isNil() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Time)
|
||||||
|
ts, err := timestampProto(*t)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
siz := Size(ts)
|
||||||
|
return tagsize + SizeVarint(uint64(siz)) + siz
|
||||||
|
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
if ptr.isNil() {
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Time)
|
||||||
|
ts, err := timestampProto(*t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
buf, err := Marshal(ts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(len(buf)))
|
||||||
|
b = append(b, buf...)
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeTimeSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
s := ptr.getSlice(u.typ)
|
||||||
|
n := 0
|
||||||
|
for i := 0; i < s.Len(); i++ {
|
||||||
|
elem := s.Index(i)
|
||||||
|
t := elem.Interface().(time.Time)
|
||||||
|
ts, err := timestampProto(t)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
siz := Size(ts)
|
||||||
|
n += siz + SizeVarint(uint64(siz)) + tagsize
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
},
|
||||||
|
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
s := ptr.getSlice(u.typ)
|
||||||
|
for i := 0; i < s.Len(); i++ {
|
||||||
|
elem := s.Index(i)
|
||||||
|
t := elem.Interface().(time.Time)
|
||||||
|
ts, err := timestampProto(t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
siz := Size(ts)
|
||||||
|
buf, err := Marshal(ts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(siz))
|
||||||
|
b = append(b, buf...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeTimePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
s := ptr.getSlice(reflect.PtrTo(u.typ))
|
||||||
|
n := 0
|
||||||
|
for i := 0; i < s.Len(); i++ {
|
||||||
|
elem := s.Index(i)
|
||||||
|
t := elem.Interface().(*time.Time)
|
||||||
|
ts, err := timestampProto(*t)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
siz := Size(ts)
|
||||||
|
n += siz + SizeVarint(uint64(siz)) + tagsize
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
},
|
||||||
|
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
s := ptr.getSlice(reflect.PtrTo(u.typ))
|
||||||
|
for i := 0; i < s.Len(); i++ {
|
||||||
|
elem := s.Index(i)
|
||||||
|
t := elem.Interface().(*time.Time)
|
||||||
|
ts, err := timestampProto(*t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
siz := Size(ts)
|
||||||
|
buf, err := Marshal(ts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(siz))
|
||||||
|
b = append(b, buf...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeDurationMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
d := ptr.asPointerTo(u.typ).Interface().(*time.Duration)
|
||||||
|
dur := durationProto(*d)
|
||||||
|
siz := Size(dur)
|
||||||
|
return tagsize + SizeVarint(uint64(siz)) + siz
|
||||||
|
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
d := ptr.asPointerTo(u.typ).Interface().(*time.Duration)
|
||||||
|
dur := durationProto(*d)
|
||||||
|
buf, err := Marshal(dur)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(len(buf)))
|
||||||
|
b = append(b, buf...)
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeDurationPtrMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
if ptr.isNil() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
d := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Duration)
|
||||||
|
dur := durationProto(*d)
|
||||||
|
siz := Size(dur)
|
||||||
|
return tagsize + SizeVarint(uint64(siz)) + siz
|
||||||
|
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
if ptr.isNil() {
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
d := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Duration)
|
||||||
|
dur := durationProto(*d)
|
||||||
|
buf, err := Marshal(dur)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(len(buf)))
|
||||||
|
b = append(b, buf...)
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeDurationSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
s := ptr.getSlice(u.typ)
|
||||||
|
n := 0
|
||||||
|
for i := 0; i < s.Len(); i++ {
|
||||||
|
elem := s.Index(i)
|
||||||
|
d := elem.Interface().(time.Duration)
|
||||||
|
dur := durationProto(d)
|
||||||
|
siz := Size(dur)
|
||||||
|
n += siz + SizeVarint(uint64(siz)) + tagsize
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
},
|
||||||
|
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
s := ptr.getSlice(u.typ)
|
||||||
|
for i := 0; i < s.Len(); i++ {
|
||||||
|
elem := s.Index(i)
|
||||||
|
d := elem.Interface().(time.Duration)
|
||||||
|
dur := durationProto(d)
|
||||||
|
siz := Size(dur)
|
||||||
|
buf, err := Marshal(dur)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(siz))
|
||||||
|
b = append(b, buf...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeDurationPtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
|
||||||
|
return func(ptr pointer, tagsize int) int {
|
||||||
|
s := ptr.getSlice(reflect.PtrTo(u.typ))
|
||||||
|
n := 0
|
||||||
|
for i := 0; i < s.Len(); i++ {
|
||||||
|
elem := s.Index(i)
|
||||||
|
d := elem.Interface().(*time.Duration)
|
||||||
|
dur := durationProto(*d)
|
||||||
|
siz := Size(dur)
|
||||||
|
n += siz + SizeVarint(uint64(siz)) + tagsize
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
},
|
||||||
|
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
|
s := ptr.getSlice(reflect.PtrTo(u.typ))
|
||||||
|
for i := 0; i < s.Len(); i++ {
|
||||||
|
elem := s.Index(i)
|
||||||
|
d := elem.Interface().(*time.Duration)
|
||||||
|
dur := durationProto(*d)
|
||||||
|
siz := Size(dur)
|
||||||
|
buf, err := Marshal(dur)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(siz))
|
||||||
|
b = append(b, buf...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
+657
@@ -0,0 +1,657 @@
|
|||||||
|
// Go support for Protocol Buffers - Google's data interchange format
|
||||||
|
//
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// https://github.com/golang/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
package proto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Merge merges the src message into dst.
|
||||||
|
// This assumes that dst and src of the same type and are non-nil.
|
||||||
|
func (a *InternalMessageInfo) Merge(dst, src Message) {
|
||||||
|
mi := atomicLoadMergeInfo(&a.merge)
|
||||||
|
if mi == nil {
|
||||||
|
mi = getMergeInfo(reflect.TypeOf(dst).Elem())
|
||||||
|
atomicStoreMergeInfo(&a.merge, mi)
|
||||||
|
}
|
||||||
|
mi.merge(toPointer(&dst), toPointer(&src))
|
||||||
|
}
|
||||||
|
|
||||||
|
type mergeInfo struct {
|
||||||
|
typ reflect.Type
|
||||||
|
|
||||||
|
initialized int32 // 0: only typ is valid, 1: everything is valid
|
||||||
|
lock sync.Mutex
|
||||||
|
|
||||||
|
fields []mergeFieldInfo
|
||||||
|
unrecognized field // Offset of XXX_unrecognized
|
||||||
|
}
|
||||||
|
|
||||||
|
type mergeFieldInfo struct {
|
||||||
|
field field // Offset of field, guaranteed to be valid
|
||||||
|
|
||||||
|
// isPointer reports whether the value in the field is a pointer.
|
||||||
|
// This is true for the following situations:
|
||||||
|
// * Pointer to struct
|
||||||
|
// * Pointer to basic type (proto2 only)
|
||||||
|
// * Slice (first value in slice header is a pointer)
|
||||||
|
// * String (first value in string header is a pointer)
|
||||||
|
isPointer bool
|
||||||
|
|
||||||
|
// basicWidth reports the width of the field assuming that it is directly
|
||||||
|
// embedded in the struct (as is the case for basic types in proto3).
|
||||||
|
// The possible values are:
|
||||||
|
// 0: invalid
|
||||||
|
// 1: bool
|
||||||
|
// 4: int32, uint32, float32
|
||||||
|
// 8: int64, uint64, float64
|
||||||
|
basicWidth int
|
||||||
|
|
||||||
|
// Where dst and src are pointers to the types being merged.
|
||||||
|
merge func(dst, src pointer)
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
mergeInfoMap = map[reflect.Type]*mergeInfo{}
|
||||||
|
mergeInfoLock sync.Mutex
|
||||||
|
)
|
||||||
|
|
||||||
|
func getMergeInfo(t reflect.Type) *mergeInfo {
|
||||||
|
mergeInfoLock.Lock()
|
||||||
|
defer mergeInfoLock.Unlock()
|
||||||
|
mi := mergeInfoMap[t]
|
||||||
|
if mi == nil {
|
||||||
|
mi = &mergeInfo{typ: t}
|
||||||
|
mergeInfoMap[t] = mi
|
||||||
|
}
|
||||||
|
return mi
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge merges src into dst assuming they are both of type *mi.typ.
|
||||||
|
func (mi *mergeInfo) merge(dst, src pointer) {
|
||||||
|
if dst.isNil() {
|
||||||
|
panic("proto: nil destination")
|
||||||
|
}
|
||||||
|
if src.isNil() {
|
||||||
|
return // Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
|
if atomic.LoadInt32(&mi.initialized) == 0 {
|
||||||
|
mi.computeMergeInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, fi := range mi.fields {
|
||||||
|
sfp := src.offset(fi.field)
|
||||||
|
|
||||||
|
// As an optimization, we can avoid the merge function call cost
|
||||||
|
// if we know for sure that the source will have no effect
|
||||||
|
// by checking if it is the zero value.
|
||||||
|
if unsafeAllowed {
|
||||||
|
if fi.isPointer && sfp.getPointer().isNil() { // Could be slice or string
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if fi.basicWidth > 0 {
|
||||||
|
switch {
|
||||||
|
case fi.basicWidth == 1 && !*sfp.toBool():
|
||||||
|
continue
|
||||||
|
case fi.basicWidth == 4 && *sfp.toUint32() == 0:
|
||||||
|
continue
|
||||||
|
case fi.basicWidth == 8 && *sfp.toUint64() == 0:
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dfp := dst.offset(fi.field)
|
||||||
|
fi.merge(dfp, sfp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Make this faster?
|
||||||
|
out := dst.asPointerTo(mi.typ).Elem()
|
||||||
|
in := src.asPointerTo(mi.typ).Elem()
|
||||||
|
if emIn, err := extendable(in.Addr().Interface()); err == nil {
|
||||||
|
emOut, _ := extendable(out.Addr().Interface())
|
||||||
|
mIn, muIn := emIn.extensionsRead()
|
||||||
|
if mIn != nil {
|
||||||
|
mOut := emOut.extensionsWrite()
|
||||||
|
muIn.Lock()
|
||||||
|
mergeExtension(mOut, mIn)
|
||||||
|
muIn.Unlock()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if mi.unrecognized.IsValid() {
|
||||||
|
if b := *src.offset(mi.unrecognized).toBytes(); len(b) > 0 {
|
||||||
|
*dst.offset(mi.unrecognized).toBytes() = append([]byte(nil), b...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mi *mergeInfo) computeMergeInfo() {
|
||||||
|
mi.lock.Lock()
|
||||||
|
defer mi.lock.Unlock()
|
||||||
|
if mi.initialized != 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t := mi.typ
|
||||||
|
n := t.NumField()
|
||||||
|
|
||||||
|
props := GetProperties(t)
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
f := t.Field(i)
|
||||||
|
if strings.HasPrefix(f.Name, "XXX_") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
mfi := mergeFieldInfo{field: toField(&f)}
|
||||||
|
tf := f.Type
|
||||||
|
|
||||||
|
// As an optimization, we can avoid the merge function call cost
|
||||||
|
// if we know for sure that the source will have no effect
|
||||||
|
// by checking if it is the zero value.
|
||||||
|
if unsafeAllowed {
|
||||||
|
switch tf.Kind() {
|
||||||
|
case reflect.Ptr, reflect.Slice, reflect.String:
|
||||||
|
// As a special case, we assume slices and strings are pointers
|
||||||
|
// since we know that the first field in the SliceSlice or
|
||||||
|
// StringHeader is a data pointer.
|
||||||
|
mfi.isPointer = true
|
||||||
|
case reflect.Bool:
|
||||||
|
mfi.basicWidth = 1
|
||||||
|
case reflect.Int32, reflect.Uint32, reflect.Float32:
|
||||||
|
mfi.basicWidth = 4
|
||||||
|
case reflect.Int64, reflect.Uint64, reflect.Float64:
|
||||||
|
mfi.basicWidth = 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap tf to get at its most basic type.
|
||||||
|
var isPointer, isSlice bool
|
||||||
|
if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
|
||||||
|
isSlice = true
|
||||||
|
tf = tf.Elem()
|
||||||
|
}
|
||||||
|
if tf.Kind() == reflect.Ptr {
|
||||||
|
isPointer = true
|
||||||
|
tf = tf.Elem()
|
||||||
|
}
|
||||||
|
if isPointer && isSlice && tf.Kind() != reflect.Struct {
|
||||||
|
panic("both pointer and slice for basic type in " + tf.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
switch tf.Kind() {
|
||||||
|
case reflect.Int32:
|
||||||
|
switch {
|
||||||
|
case isSlice: // E.g., []int32
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
// NOTE: toInt32Slice is not defined (see pointer_reflect.go).
|
||||||
|
/*
|
||||||
|
sfsp := src.toInt32Slice()
|
||||||
|
if *sfsp != nil {
|
||||||
|
dfsp := dst.toInt32Slice()
|
||||||
|
*dfsp = append(*dfsp, *sfsp...)
|
||||||
|
if *dfsp == nil {
|
||||||
|
*dfsp = []int64{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
sfs := src.getInt32Slice()
|
||||||
|
if sfs != nil {
|
||||||
|
dfs := dst.getInt32Slice()
|
||||||
|
dfs = append(dfs, sfs...)
|
||||||
|
if dfs == nil {
|
||||||
|
dfs = []int32{}
|
||||||
|
}
|
||||||
|
dst.setInt32Slice(dfs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case isPointer: // E.g., *int32
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
// NOTE: toInt32Ptr is not defined (see pointer_reflect.go).
|
||||||
|
/*
|
||||||
|
sfpp := src.toInt32Ptr()
|
||||||
|
if *sfpp != nil {
|
||||||
|
dfpp := dst.toInt32Ptr()
|
||||||
|
if *dfpp == nil {
|
||||||
|
*dfpp = Int32(**sfpp)
|
||||||
|
} else {
|
||||||
|
**dfpp = **sfpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
sfp := src.getInt32Ptr()
|
||||||
|
if sfp != nil {
|
||||||
|
dfp := dst.getInt32Ptr()
|
||||||
|
if dfp == nil {
|
||||||
|
dst.setInt32Ptr(*sfp)
|
||||||
|
} else {
|
||||||
|
*dfp = *sfp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., int32
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
if v := *src.toInt32(); v != 0 {
|
||||||
|
*dst.toInt32() = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Int64:
|
||||||
|
switch {
|
||||||
|
case isSlice: // E.g., []int64
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfsp := src.toInt64Slice()
|
||||||
|
if *sfsp != nil {
|
||||||
|
dfsp := dst.toInt64Slice()
|
||||||
|
*dfsp = append(*dfsp, *sfsp...)
|
||||||
|
if *dfsp == nil {
|
||||||
|
*dfsp = []int64{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case isPointer: // E.g., *int64
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfpp := src.toInt64Ptr()
|
||||||
|
if *sfpp != nil {
|
||||||
|
dfpp := dst.toInt64Ptr()
|
||||||
|
if *dfpp == nil {
|
||||||
|
*dfpp = Int64(**sfpp)
|
||||||
|
} else {
|
||||||
|
**dfpp = **sfpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., int64
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
if v := *src.toInt64(); v != 0 {
|
||||||
|
*dst.toInt64() = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Uint32:
|
||||||
|
switch {
|
||||||
|
case isSlice: // E.g., []uint32
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfsp := src.toUint32Slice()
|
||||||
|
if *sfsp != nil {
|
||||||
|
dfsp := dst.toUint32Slice()
|
||||||
|
*dfsp = append(*dfsp, *sfsp...)
|
||||||
|
if *dfsp == nil {
|
||||||
|
*dfsp = []uint32{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case isPointer: // E.g., *uint32
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfpp := src.toUint32Ptr()
|
||||||
|
if *sfpp != nil {
|
||||||
|
dfpp := dst.toUint32Ptr()
|
||||||
|
if *dfpp == nil {
|
||||||
|
*dfpp = Uint32(**sfpp)
|
||||||
|
} else {
|
||||||
|
**dfpp = **sfpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., uint32
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
if v := *src.toUint32(); v != 0 {
|
||||||
|
*dst.toUint32() = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Uint64:
|
||||||
|
switch {
|
||||||
|
case isSlice: // E.g., []uint64
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfsp := src.toUint64Slice()
|
||||||
|
if *sfsp != nil {
|
||||||
|
dfsp := dst.toUint64Slice()
|
||||||
|
*dfsp = append(*dfsp, *sfsp...)
|
||||||
|
if *dfsp == nil {
|
||||||
|
*dfsp = []uint64{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case isPointer: // E.g., *uint64
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfpp := src.toUint64Ptr()
|
||||||
|
if *sfpp != nil {
|
||||||
|
dfpp := dst.toUint64Ptr()
|
||||||
|
if *dfpp == nil {
|
||||||
|
*dfpp = Uint64(**sfpp)
|
||||||
|
} else {
|
||||||
|
**dfpp = **sfpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., uint64
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
if v := *src.toUint64(); v != 0 {
|
||||||
|
*dst.toUint64() = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Float32:
|
||||||
|
switch {
|
||||||
|
case isSlice: // E.g., []float32
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfsp := src.toFloat32Slice()
|
||||||
|
if *sfsp != nil {
|
||||||
|
dfsp := dst.toFloat32Slice()
|
||||||
|
*dfsp = append(*dfsp, *sfsp...)
|
||||||
|
if *dfsp == nil {
|
||||||
|
*dfsp = []float32{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case isPointer: // E.g., *float32
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfpp := src.toFloat32Ptr()
|
||||||
|
if *sfpp != nil {
|
||||||
|
dfpp := dst.toFloat32Ptr()
|
||||||
|
if *dfpp == nil {
|
||||||
|
*dfpp = Float32(**sfpp)
|
||||||
|
} else {
|
||||||
|
**dfpp = **sfpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., float32
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
if v := *src.toFloat32(); v != 0 {
|
||||||
|
*dst.toFloat32() = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Float64:
|
||||||
|
switch {
|
||||||
|
case isSlice: // E.g., []float64
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfsp := src.toFloat64Slice()
|
||||||
|
if *sfsp != nil {
|
||||||
|
dfsp := dst.toFloat64Slice()
|
||||||
|
*dfsp = append(*dfsp, *sfsp...)
|
||||||
|
if *dfsp == nil {
|
||||||
|
*dfsp = []float64{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case isPointer: // E.g., *float64
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfpp := src.toFloat64Ptr()
|
||||||
|
if *sfpp != nil {
|
||||||
|
dfpp := dst.toFloat64Ptr()
|
||||||
|
if *dfpp == nil {
|
||||||
|
*dfpp = Float64(**sfpp)
|
||||||
|
} else {
|
||||||
|
**dfpp = **sfpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., float64
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
if v := *src.toFloat64(); v != 0 {
|
||||||
|
*dst.toFloat64() = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Bool:
|
||||||
|
switch {
|
||||||
|
case isSlice: // E.g., []bool
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfsp := src.toBoolSlice()
|
||||||
|
if *sfsp != nil {
|
||||||
|
dfsp := dst.toBoolSlice()
|
||||||
|
*dfsp = append(*dfsp, *sfsp...)
|
||||||
|
if *dfsp == nil {
|
||||||
|
*dfsp = []bool{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case isPointer: // E.g., *bool
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfpp := src.toBoolPtr()
|
||||||
|
if *sfpp != nil {
|
||||||
|
dfpp := dst.toBoolPtr()
|
||||||
|
if *dfpp == nil {
|
||||||
|
*dfpp = Bool(**sfpp)
|
||||||
|
} else {
|
||||||
|
**dfpp = **sfpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., bool
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
if v := *src.toBool(); v {
|
||||||
|
*dst.toBool() = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.String:
|
||||||
|
switch {
|
||||||
|
case isSlice: // E.g., []string
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfsp := src.toStringSlice()
|
||||||
|
if *sfsp != nil {
|
||||||
|
dfsp := dst.toStringSlice()
|
||||||
|
*dfsp = append(*dfsp, *sfsp...)
|
||||||
|
if *dfsp == nil {
|
||||||
|
*dfsp = []string{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case isPointer: // E.g., *string
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sfpp := src.toStringPtr()
|
||||||
|
if *sfpp != nil {
|
||||||
|
dfpp := dst.toStringPtr()
|
||||||
|
if *dfpp == nil {
|
||||||
|
*dfpp = String(**sfpp)
|
||||||
|
} else {
|
||||||
|
**dfpp = **sfpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., string
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
if v := *src.toString(); v != "" {
|
||||||
|
*dst.toString() = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Slice:
|
||||||
|
isProto3 := props.Prop[i].proto3
|
||||||
|
switch {
|
||||||
|
case isPointer:
|
||||||
|
panic("bad pointer in byte slice case in " + tf.Name())
|
||||||
|
case tf.Elem().Kind() != reflect.Uint8:
|
||||||
|
panic("bad element kind in byte slice case in " + tf.Name())
|
||||||
|
case isSlice: // E.g., [][]byte
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sbsp := src.toBytesSlice()
|
||||||
|
if *sbsp != nil {
|
||||||
|
dbsp := dst.toBytesSlice()
|
||||||
|
for _, sb := range *sbsp {
|
||||||
|
if sb == nil {
|
||||||
|
*dbsp = append(*dbsp, nil)
|
||||||
|
} else {
|
||||||
|
*dbsp = append(*dbsp, append([]byte{}, sb...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if *dbsp == nil {
|
||||||
|
*dbsp = [][]byte{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., []byte
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sbp := src.toBytes()
|
||||||
|
if *sbp != nil {
|
||||||
|
dbp := dst.toBytes()
|
||||||
|
if !isProto3 || len(*sbp) > 0 {
|
||||||
|
*dbp = append([]byte{}, *sbp...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Struct:
|
||||||
|
switch {
|
||||||
|
case !isPointer:
|
||||||
|
mergeInfo := getMergeInfo(tf)
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
mergeInfo.merge(dst, src)
|
||||||
|
}
|
||||||
|
case isSlice: // E.g., []*pb.T
|
||||||
|
mergeInfo := getMergeInfo(tf)
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sps := src.getPointerSlice()
|
||||||
|
if sps != nil {
|
||||||
|
dps := dst.getPointerSlice()
|
||||||
|
for _, sp := range sps {
|
||||||
|
var dp pointer
|
||||||
|
if !sp.isNil() {
|
||||||
|
dp = valToPointer(reflect.New(tf))
|
||||||
|
mergeInfo.merge(dp, sp)
|
||||||
|
}
|
||||||
|
dps = append(dps, dp)
|
||||||
|
}
|
||||||
|
if dps == nil {
|
||||||
|
dps = []pointer{}
|
||||||
|
}
|
||||||
|
dst.setPointerSlice(dps)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: // E.g., *pb.T
|
||||||
|
mergeInfo := getMergeInfo(tf)
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sp := src.getPointer()
|
||||||
|
if !sp.isNil() {
|
||||||
|
dp := dst.getPointer()
|
||||||
|
if dp.isNil() {
|
||||||
|
dp = valToPointer(reflect.New(tf))
|
||||||
|
dst.setPointer(dp)
|
||||||
|
}
|
||||||
|
mergeInfo.merge(dp, sp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Map:
|
||||||
|
switch {
|
||||||
|
case isPointer || isSlice:
|
||||||
|
panic("bad pointer or slice in map case in " + tf.Name())
|
||||||
|
default: // E.g., map[K]V
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
sm := src.asPointerTo(tf).Elem()
|
||||||
|
if sm.Len() == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dm := dst.asPointerTo(tf).Elem()
|
||||||
|
if dm.IsNil() {
|
||||||
|
dm.Set(reflect.MakeMap(tf))
|
||||||
|
}
|
||||||
|
|
||||||
|
switch tf.Elem().Kind() {
|
||||||
|
case reflect.Ptr: // Proto struct (e.g., *T)
|
||||||
|
for _, key := range sm.MapKeys() {
|
||||||
|
val := sm.MapIndex(key)
|
||||||
|
val = reflect.ValueOf(Clone(val.Interface().(Message)))
|
||||||
|
dm.SetMapIndex(key, val)
|
||||||
|
}
|
||||||
|
case reflect.Slice: // E.g. Bytes type (e.g., []byte)
|
||||||
|
for _, key := range sm.MapKeys() {
|
||||||
|
val := sm.MapIndex(key)
|
||||||
|
val = reflect.ValueOf(append([]byte{}, val.Bytes()...))
|
||||||
|
dm.SetMapIndex(key, val)
|
||||||
|
}
|
||||||
|
default: // Basic type (e.g., string)
|
||||||
|
for _, key := range sm.MapKeys() {
|
||||||
|
val := sm.MapIndex(key)
|
||||||
|
dm.SetMapIndex(key, val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.Interface:
|
||||||
|
// Must be oneof field.
|
||||||
|
switch {
|
||||||
|
case isPointer || isSlice:
|
||||||
|
panic("bad pointer or slice in interface case in " + tf.Name())
|
||||||
|
default: // E.g., interface{}
|
||||||
|
// TODO: Make this faster?
|
||||||
|
mfi.merge = func(dst, src pointer) {
|
||||||
|
su := src.asPointerTo(tf).Elem()
|
||||||
|
if !su.IsNil() {
|
||||||
|
du := dst.asPointerTo(tf).Elem()
|
||||||
|
typ := su.Elem().Type()
|
||||||
|
if du.IsNil() || du.Elem().Type() != typ {
|
||||||
|
du.Set(reflect.New(typ.Elem())) // Initialize interface if empty
|
||||||
|
}
|
||||||
|
sv := su.Elem().Elem().Field(0)
|
||||||
|
if sv.Kind() == reflect.Ptr && sv.IsNil() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dv := du.Elem().Elem().Field(0)
|
||||||
|
if dv.Kind() == reflect.Ptr && dv.IsNil() {
|
||||||
|
dv.Set(reflect.New(sv.Type().Elem())) // Initialize proto message if empty
|
||||||
|
}
|
||||||
|
switch sv.Type().Kind() {
|
||||||
|
case reflect.Ptr: // Proto struct (e.g., *T)
|
||||||
|
Merge(dv.Interface().(Message), sv.Interface().(Message))
|
||||||
|
case reflect.Slice: // E.g. Bytes type (e.g., []byte)
|
||||||
|
dv.Set(reflect.ValueOf(append([]byte{}, sv.Bytes()...)))
|
||||||
|
default: // Basic type (e.g., string)
|
||||||
|
dv.Set(sv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("merger not found for type:%s", tf))
|
||||||
|
}
|
||||||
|
mi.fields = append(mi.fields, mfi)
|
||||||
|
}
|
||||||
|
|
||||||
|
mi.unrecognized = invalidField
|
||||||
|
if f, ok := t.FieldByName("XXX_unrecognized"); ok {
|
||||||
|
if f.Type != reflect.TypeOf([]byte{}) {
|
||||||
|
panic("expected XXX_unrecognized to be of type []byte")
|
||||||
|
}
|
||||||
|
mi.unrecognized = toField(&f)
|
||||||
|
}
|
||||||
|
|
||||||
|
atomic.StoreInt32(&mi.initialized, 1)
|
||||||
|
}
|
||||||
+2245
File diff suppressed because it is too large
Load Diff
+385
@@ -0,0 +1,385 @@
|
|||||||
|
// Protocol Buffers for Go with Gadgets
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
|
||||||
|
// http://github.com/gogo/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
package proto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
func makeUnmarshalMessage(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
// First read the message field to see if something is there.
|
||||||
|
// The semantics of multiple submessages are weird. Instead of
|
||||||
|
// the last one winning (as it is for all other fields), multiple
|
||||||
|
// submessages are merged.
|
||||||
|
v := f // gogo: changed from v := f.getPointer()
|
||||||
|
if v.isNil() {
|
||||||
|
v = valToPointer(reflect.New(sub.typ))
|
||||||
|
f.setPointer(v)
|
||||||
|
}
|
||||||
|
err := sub.unmarshal(v, b[:x])
|
||||||
|
if err != nil {
|
||||||
|
if r, ok := err.(*RequiredNotSetError); ok {
|
||||||
|
r.field = name + "." + r.field
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return b[x:], err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalMessageSlice(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
v := valToPointer(reflect.New(sub.typ))
|
||||||
|
err := sub.unmarshal(v, b[:x])
|
||||||
|
if err != nil {
|
||||||
|
if r, ok := err.(*RequiredNotSetError); ok {
|
||||||
|
r.field = name + "." + r.field
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.appendRef(v, sub.typ) // gogo: changed from f.appendPointer(v)
|
||||||
|
return b[x:], err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalCustomPtr(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
|
||||||
|
s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem()
|
||||||
|
s.Set(reflect.New(sub.typ))
|
||||||
|
m := s.Interface().(custom)
|
||||||
|
if err := m.Unmarshal(b[:x]); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalCustomSlice(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m := reflect.New(sub.typ)
|
||||||
|
c := m.Interface().(custom)
|
||||||
|
if err := c.Unmarshal(b[:x]); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
v := valToPointer(m)
|
||||||
|
f.appendRef(v, sub.typ)
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalCustom(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
|
||||||
|
m := f.asPointerTo(sub.typ).Interface().(custom)
|
||||||
|
if err := m.Unmarshal(b[:x]); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalTime(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m := ×tamp{}
|
||||||
|
if err := Unmarshal(b[:x], m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
t, err := timestampFromProto(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
s := f.asPointerTo(sub.typ).Elem()
|
||||||
|
s.Set(reflect.ValueOf(t))
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalTimePtr(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m := ×tamp{}
|
||||||
|
if err := Unmarshal(b[:x], m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
t, err := timestampFromProto(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem()
|
||||||
|
s.Set(reflect.ValueOf(&t))
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalTimePtrSlice(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m := ×tamp{}
|
||||||
|
if err := Unmarshal(b[:x], m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
t, err := timestampFromProto(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
slice := f.getSlice(reflect.PtrTo(sub.typ))
|
||||||
|
newSlice := reflect.Append(slice, reflect.ValueOf(&t))
|
||||||
|
slice.Set(newSlice)
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalTimeSlice(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m := ×tamp{}
|
||||||
|
if err := Unmarshal(b[:x], m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
t, err := timestampFromProto(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
slice := f.getSlice(sub.typ)
|
||||||
|
newSlice := reflect.Append(slice, reflect.ValueOf(t))
|
||||||
|
slice.Set(newSlice)
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalDurationPtr(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m := &duration{}
|
||||||
|
if err := Unmarshal(b[:x], m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
d, err := durationFromProto(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem()
|
||||||
|
s.Set(reflect.ValueOf(&d))
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalDuration(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m := &duration{}
|
||||||
|
if err := Unmarshal(b[:x], m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
d, err := durationFromProto(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
s := f.asPointerTo(sub.typ).Elem()
|
||||||
|
s.Set(reflect.ValueOf(d))
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalDurationPtrSlice(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m := &duration{}
|
||||||
|
if err := Unmarshal(b[:x], m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
d, err := durationFromProto(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
slice := f.getSlice(reflect.PtrTo(sub.typ))
|
||||||
|
newSlice := reflect.Append(slice, reflect.ValueOf(&d))
|
||||||
|
slice.Set(newSlice)
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUnmarshalDurationSlice(sub *unmarshalInfo, name string) unmarshaler {
|
||||||
|
return func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return nil, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m := &duration{}
|
||||||
|
if err := Unmarshal(b[:x], m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
d, err := durationFromProto(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
slice := f.getSlice(sub.typ)
|
||||||
|
newSlice := reflect.Append(slice, reflect.ValueOf(d))
|
||||||
|
slice.Set(newSlice)
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
Vendored
+1
-1
@@ -33,5 +33,5 @@ all: regenerate
|
|||||||
|
|
||||||
regenerate:
|
regenerate:
|
||||||
go install github.com/gogo/protobuf/protoc-min-version
|
go install github.com/gogo/protobuf/protoc-min-version
|
||||||
protoc-min-version --version="3.0.0" --gogo_out=. test.proto
|
protoc-min-version --version="3.0.0" --gogo_out=paths=source_relative:. test.proto
|
||||||
|
|
||||||
+5268
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+24
-2
@@ -33,7 +33,9 @@
|
|||||||
|
|
||||||
syntax = "proto2";
|
syntax = "proto2";
|
||||||
|
|
||||||
package testdata;
|
package test_proto;
|
||||||
|
|
||||||
|
option go_package = "github.com/gogo/protobuf/proto/test_proto";
|
||||||
|
|
||||||
enum FOO { FOO1 = 1; };
|
enum FOO { FOO1 = 1; };
|
||||||
|
|
||||||
@@ -96,6 +98,8 @@ message GoTest {
|
|||||||
required bytes F_Bytes_required = 101;
|
required bytes F_Bytes_required = 101;
|
||||||
required sint32 F_Sint32_required = 102;
|
required sint32 F_Sint32_required = 102;
|
||||||
required sint64 F_Sint64_required = 103;
|
required sint64 F_Sint64_required = 103;
|
||||||
|
required sfixed32 F_Sfixed32_required = 104;
|
||||||
|
required sfixed64 F_Sfixed64_required = 105;
|
||||||
|
|
||||||
// Repeated fields of all basic types
|
// Repeated fields of all basic types
|
||||||
repeated bool F_Bool_repeated = 20;
|
repeated bool F_Bool_repeated = 20;
|
||||||
@@ -111,6 +115,8 @@ message GoTest {
|
|||||||
repeated bytes F_Bytes_repeated = 201;
|
repeated bytes F_Bytes_repeated = 201;
|
||||||
repeated sint32 F_Sint32_repeated = 202;
|
repeated sint32 F_Sint32_repeated = 202;
|
||||||
repeated sint64 F_Sint64_repeated = 203;
|
repeated sint64 F_Sint64_repeated = 203;
|
||||||
|
repeated sfixed32 F_Sfixed32_repeated = 204;
|
||||||
|
repeated sfixed64 F_Sfixed64_repeated = 205;
|
||||||
|
|
||||||
// Optional fields of all basic types
|
// Optional fields of all basic types
|
||||||
optional bool F_Bool_optional = 30;
|
optional bool F_Bool_optional = 30;
|
||||||
@@ -126,6 +132,8 @@ message GoTest {
|
|||||||
optional bytes F_Bytes_optional = 301;
|
optional bytes F_Bytes_optional = 301;
|
||||||
optional sint32 F_Sint32_optional = 302;
|
optional sint32 F_Sint32_optional = 302;
|
||||||
optional sint64 F_Sint64_optional = 303;
|
optional sint64 F_Sint64_optional = 303;
|
||||||
|
optional sfixed32 F_Sfixed32_optional = 304;
|
||||||
|
optional sfixed64 F_Sfixed64_optional = 305;
|
||||||
|
|
||||||
// Default-valued fields of all basic types
|
// Default-valued fields of all basic types
|
||||||
optional bool F_Bool_defaulted = 40 [default=true];
|
optional bool F_Bool_defaulted = 40 [default=true];
|
||||||
@@ -141,6 +149,8 @@ message GoTest {
|
|||||||
optional bytes F_Bytes_defaulted = 401 [default="Bignose"];
|
optional bytes F_Bytes_defaulted = 401 [default="Bignose"];
|
||||||
optional sint32 F_Sint32_defaulted = 402 [default = -32];
|
optional sint32 F_Sint32_defaulted = 402 [default = -32];
|
||||||
optional sint64 F_Sint64_defaulted = 403 [default = -64];
|
optional sint64 F_Sint64_defaulted = 403 [default = -64];
|
||||||
|
optional sfixed32 F_Sfixed32_defaulted = 404 [default = -32];
|
||||||
|
optional sfixed64 F_Sfixed64_defaulted = 405 [default = -64];
|
||||||
|
|
||||||
// Packed repeated fields (no string or bytes).
|
// Packed repeated fields (no string or bytes).
|
||||||
repeated bool F_Bool_repeated_packed = 50 [packed=true];
|
repeated bool F_Bool_repeated_packed = 50 [packed=true];
|
||||||
@@ -154,6 +164,8 @@ message GoTest {
|
|||||||
repeated double F_Double_repeated_packed = 58 [packed=true];
|
repeated double F_Double_repeated_packed = 58 [packed=true];
|
||||||
repeated sint32 F_Sint32_repeated_packed = 502 [packed=true];
|
repeated sint32 F_Sint32_repeated_packed = 502 [packed=true];
|
||||||
repeated sint64 F_Sint64_repeated_packed = 503 [packed=true];
|
repeated sint64 F_Sint64_repeated_packed = 503 [packed=true];
|
||||||
|
repeated sfixed32 F_Sfixed32_repeated_packed = 504 [packed=true];
|
||||||
|
repeated sfixed64 F_Sfixed64_repeated_packed = 505 [packed=true];
|
||||||
|
|
||||||
// Required, repeated, and optional groups.
|
// Required, repeated, and optional groups.
|
||||||
required group RequiredGroup = 70 {
|
required group RequiredGroup = 70 {
|
||||||
@@ -285,10 +297,12 @@ message Ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
optional string data = 1;
|
optional string data = 1;
|
||||||
|
map<int32, int32> map_field = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
extend MyMessage {
|
extend MyMessage {
|
||||||
repeated string greeting = 106;
|
repeated string greeting = 106;
|
||||||
|
// leave field 200 unregistered for testing
|
||||||
}
|
}
|
||||||
|
|
||||||
message ComplexExtension {
|
message ComplexExtension {
|
||||||
@@ -342,7 +356,7 @@ extend DefaultsMessage {
|
|||||||
optional sfixed32 default_sfixed32 = 211 [default = 50];
|
optional sfixed32 default_sfixed32 = 211 [default = 50];
|
||||||
optional sfixed64 default_sfixed64 = 212 [default = 51];
|
optional sfixed64 default_sfixed64 = 212 [default = 51];
|
||||||
optional bool default_bool = 213 [default = true];
|
optional bool default_bool = 213 [default = true];
|
||||||
optional string default_string = 214 [default = "Hello, string"];
|
optional string default_string = 214 [default = "Hello, string,def=foo"];
|
||||||
optional bytes default_bytes = 215 [default = "Hello, bytes"];
|
optional bytes default_bytes = 215 [default = "Hello, bytes"];
|
||||||
optional DefaultsMessage.DefaultsEnum default_enum = 216 [default = ONE];
|
optional DefaultsMessage.DefaultsEnum default_enum = 216 [default = ONE];
|
||||||
}
|
}
|
||||||
@@ -546,3 +560,11 @@ message Communique {
|
|||||||
Strings msg = 10;
|
Strings msg = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message TestUTF8 {
|
||||||
|
optional string scalar = 1;
|
||||||
|
repeated string vector = 2;
|
||||||
|
oneof oneof { string field = 3; }
|
||||||
|
map<string, int64> map_key = 4;
|
||||||
|
map<int64, string> map_value = 5;
|
||||||
|
}
|
||||||
-4147
File diff suppressed because it is too large
Load Diff
-1737
File diff suppressed because it is too large
Load Diff
+27
-38
@@ -57,7 +57,6 @@ import (
|
|||||||
var (
|
var (
|
||||||
newline = []byte("\n")
|
newline = []byte("\n")
|
||||||
spaces = []byte(" ")
|
spaces = []byte(" ")
|
||||||
gtNewline = []byte(">\n")
|
|
||||||
endBraceNewline = []byte("}\n")
|
endBraceNewline = []byte("}\n")
|
||||||
backslashN = []byte{'\\', 'n'}
|
backslashN = []byte{'\\', 'n'}
|
||||||
backslashR = []byte{'\\', 'r'}
|
backslashR = []byte{'\\', 'r'}
|
||||||
@@ -177,11 +176,6 @@ func writeName(w *textWriter, props *Properties) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// raw is the interface satisfied by RawMessage.
|
|
||||||
type raw interface {
|
|
||||||
Bytes() []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func requiresQuotes(u string) bool {
|
func requiresQuotes(u string) bool {
|
||||||
// When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted.
|
// When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted.
|
||||||
for _, ch := range u {
|
for _, ch := range u {
|
||||||
@@ -276,6 +270,10 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
|
|||||||
props := sprops.Prop[i]
|
props := sprops.Prop[i]
|
||||||
name := st.Field(i).Name
|
name := st.Field(i).Name
|
||||||
|
|
||||||
|
if name == "XXX_NoUnkeyedLiteral" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(name, "XXX_") {
|
if strings.HasPrefix(name, "XXX_") {
|
||||||
// There are two XXX_ fields:
|
// There are two XXX_ fields:
|
||||||
// XXX_unrecognized []byte
|
// XXX_unrecognized []byte
|
||||||
@@ -366,7 +364,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := tm.writeAny(w, key, props.mkeyprop); err != nil {
|
if err := tm.writeAny(w, key, props.MapKeyProp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := w.WriteByte('\n'); err != nil {
|
if err := w.WriteByte('\n'); err != nil {
|
||||||
@@ -383,7 +381,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := tm.writeAny(w, val, props.mvalprop); err != nil {
|
if err := tm.writeAny(w, val, props.MapValProp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := w.WriteByte('\n'); err != nil {
|
if err := w.WriteByte('\n'); err != nil {
|
||||||
@@ -447,12 +445,6 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if b, ok := fv.Interface().(raw); ok {
|
|
||||||
if err := writeRaw(w, b.Bytes()); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(props.Enum) > 0 {
|
if len(props.Enum) > 0 {
|
||||||
if err := tm.writeEnum(w, fv, props); err != nil {
|
if err := tm.writeEnum(w, fv, props); err != nil {
|
||||||
@@ -475,7 +467,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
|
|||||||
pv = reflect.New(sv.Type())
|
pv = reflect.New(sv.Type())
|
||||||
pv.Elem().Set(sv)
|
pv.Elem().Set(sv)
|
||||||
}
|
}
|
||||||
if pv.Type().Implements(extensionRangeType) {
|
if _, err := extendable(pv.Interface()); err == nil {
|
||||||
if err := tm.writeExtensions(w, pv); err != nil {
|
if err := tm.writeExtensions(w, pv); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -484,27 +476,6 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// writeRaw writes an uninterpreted raw message.
|
|
||||||
func writeRaw(w *textWriter, b []byte) error {
|
|
||||||
if err := w.WriteByte('<'); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !w.compact {
|
|
||||||
if err := w.WriteByte('\n'); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
w.indent()
|
|
||||||
if err := writeUnknownStruct(w, b); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.unindent()
|
|
||||||
if err := w.WriteByte('>'); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// writeAny writes an arbitrary field.
|
// writeAny writes an arbitrary field.
|
||||||
func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
|
func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
|
||||||
v = reflect.Indirect(v)
|
v = reflect.Indirect(v)
|
||||||
@@ -605,6 +576,19 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.indent()
|
w.indent()
|
||||||
|
if v.CanAddr() {
|
||||||
|
// Calling v.Interface on a struct causes the reflect package to
|
||||||
|
// copy the entire struct. This is racy with the new Marshaler
|
||||||
|
// since we atomically update the XXX_sizecache.
|
||||||
|
//
|
||||||
|
// Thus, we retrieve a pointer to the struct if possible to avoid
|
||||||
|
// a race since v.Interface on the pointer doesn't copy the struct.
|
||||||
|
//
|
||||||
|
// If v is not addressable, then we are not worried about a race
|
||||||
|
// since it implies that the binary Marshaler cannot possibly be
|
||||||
|
// mutating this value.
|
||||||
|
v = v.Addr()
|
||||||
|
}
|
||||||
if etm, ok := v.Interface().(encoding.TextMarshaler); ok {
|
if etm, ok := v.Interface().(encoding.TextMarshaler); ok {
|
||||||
text, err := etm.MarshalText()
|
text, err := etm.MarshalText()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -613,8 +597,13 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
|
|||||||
if _, err = w.Write(text); err != nil {
|
if _, err = w.Write(text); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if err := tm.writeStruct(w, v); err != nil {
|
} else {
|
||||||
return err
|
if v.Kind() == reflect.Ptr {
|
||||||
|
v = v.Elem()
|
||||||
|
}
|
||||||
|
if err := tm.writeStruct(w, v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
w.unindent()
|
w.unindent()
|
||||||
if err := w.WriteByte(ket); err != nil {
|
if err := w.WriteByte(ket); err != nil {
|
||||||
|
|||||||
+54
-49
@@ -212,7 +212,6 @@ func (p *textParser) advance() {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
errBadUTF8 = errors.New("proto: bad UTF-8")
|
errBadUTF8 = errors.New("proto: bad UTF-8")
|
||||||
errBadHex = errors.New("proto: bad hexadecimal")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func unquoteC(s string, quote rune) (string, error) {
|
func unquoteC(s string, quote rune) (string, error) {
|
||||||
@@ -283,60 +282,47 @@ func unescape(s string) (ch string, tail string, err error) {
|
|||||||
return "?", s, nil // trigraph workaround
|
return "?", s, nil // trigraph workaround
|
||||||
case '\'', '"', '\\':
|
case '\'', '"', '\\':
|
||||||
return string(r), s, nil
|
return string(r), s, nil
|
||||||
case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X':
|
case '0', '1', '2', '3', '4', '5', '6', '7':
|
||||||
if len(s) < 2 {
|
if len(s) < 2 {
|
||||||
return "", "", fmt.Errorf(`\%c requires 2 following digits`, r)
|
return "", "", fmt.Errorf(`\%c requires 2 following digits`, r)
|
||||||
}
|
}
|
||||||
base := 8
|
ss := string(r) + s[:2]
|
||||||
ss := s[:2]
|
|
||||||
s = s[2:]
|
s = s[2:]
|
||||||
if r == 'x' || r == 'X' {
|
i, err := strconv.ParseUint(ss, 8, 8)
|
||||||
base = 16
|
|
||||||
} else {
|
|
||||||
ss = string(r) + ss
|
|
||||||
}
|
|
||||||
i, err := strconv.ParseUint(ss, base, 8)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", fmt.Errorf(`\%s contains non-octal digits`, ss)
|
||||||
}
|
}
|
||||||
return string([]byte{byte(i)}), s, nil
|
return string([]byte{byte(i)}), s, nil
|
||||||
case 'u', 'U':
|
case 'x', 'X', 'u', 'U':
|
||||||
n := 4
|
var n int
|
||||||
if r == 'U' {
|
switch r {
|
||||||
|
case 'x', 'X':
|
||||||
|
n = 2
|
||||||
|
case 'u':
|
||||||
|
n = 4
|
||||||
|
case 'U':
|
||||||
n = 8
|
n = 8
|
||||||
}
|
}
|
||||||
if len(s) < n {
|
if len(s) < n {
|
||||||
return "", "", fmt.Errorf(`\%c requires %d digits`, r, n)
|
return "", "", fmt.Errorf(`\%c requires %d following digits`, r, n)
|
||||||
}
|
|
||||||
|
|
||||||
bs := make([]byte, n/2)
|
|
||||||
for i := 0; i < n; i += 2 {
|
|
||||||
a, ok1 := unhex(s[i])
|
|
||||||
b, ok2 := unhex(s[i+1])
|
|
||||||
if !ok1 || !ok2 {
|
|
||||||
return "", "", errBadHex
|
|
||||||
}
|
|
||||||
bs[i/2] = a<<4 | b
|
|
||||||
}
|
}
|
||||||
|
ss := s[:n]
|
||||||
s = s[n:]
|
s = s[n:]
|
||||||
return string(bs), s, nil
|
i, err := strconv.ParseUint(ss, 16, 64)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", fmt.Errorf(`\%c%s contains non-hexadecimal digits`, r, ss)
|
||||||
|
}
|
||||||
|
if r == 'x' || r == 'X' {
|
||||||
|
return string([]byte{byte(i)}), s, nil
|
||||||
|
}
|
||||||
|
if i > utf8.MaxRune {
|
||||||
|
return "", "", fmt.Errorf(`\%c%s is not a valid Unicode code point`, r, ss)
|
||||||
|
}
|
||||||
|
return string(i), s, nil
|
||||||
}
|
}
|
||||||
return "", "", fmt.Errorf(`unknown escape \%c`, r)
|
return "", "", fmt.Errorf(`unknown escape \%c`, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adapted from src/pkg/strconv/quote.go.
|
|
||||||
func unhex(b byte) (v byte, ok bool) {
|
|
||||||
switch {
|
|
||||||
case '0' <= b && b <= '9':
|
|
||||||
return b - '0', true
|
|
||||||
case 'a' <= b && b <= 'f':
|
|
||||||
return b - 'a' + 10, true
|
|
||||||
case 'A' <= b && b <= 'F':
|
|
||||||
return b - 'A' + 10, true
|
|
||||||
}
|
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Back off the parser by one token. Can only be done between calls to next().
|
// Back off the parser by one token. Can only be done between calls to next().
|
||||||
// It makes the next advance() a no-op.
|
// It makes the next advance() a no-op.
|
||||||
func (p *textParser) back() { p.backed = true }
|
func (p *textParser) back() { p.backed = true }
|
||||||
@@ -650,17 +636,17 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error {
|
|||||||
if err := p.consumeToken(":"); err != nil {
|
if err := p.consumeToken(":"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := p.readAny(key, props.mkeyprop); err != nil {
|
if err := p.readAny(key, props.MapKeyProp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := p.consumeOptionalSeparator(); err != nil {
|
if err := p.consumeOptionalSeparator(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case "value":
|
case "value":
|
||||||
if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil {
|
if err := p.checkForColon(props.MapValProp, dst.Type().Elem()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := p.readAny(val, props.mvalprop); err != nil {
|
if err := p.readAny(val, props.MapValProp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := p.consumeOptionalSeparator(); err != nil {
|
if err := p.consumeOptionalSeparator(); err != nil {
|
||||||
@@ -734,6 +720,9 @@ func (p *textParser) consumeExtName() (string, error) {
|
|||||||
if tok.err != nil {
|
if tok.err != nil {
|
||||||
return "", p.errorf("unrecognized type_url or extension name: %s", tok.err)
|
return "", p.errorf("unrecognized type_url or extension name: %s", tok.err)
|
||||||
}
|
}
|
||||||
|
if p.done && tok.value != "]" {
|
||||||
|
return "", p.errorf("unclosed type_url or extension name")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return strings.Join(parts, ""), nil
|
return strings.Join(parts, ""), nil
|
||||||
}
|
}
|
||||||
@@ -934,6 +923,16 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
|
|||||||
fv.SetFloat(f)
|
fv.SetFloat(f)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
case reflect.Int8:
|
||||||
|
if x, err := strconv.ParseInt(tok.value, 0, 8); err == nil {
|
||||||
|
fv.SetInt(x)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
case reflect.Int16:
|
||||||
|
if x, err := strconv.ParseInt(tok.value, 0, 16); err == nil {
|
||||||
|
fv.SetInt(x)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
case reflect.Int32:
|
case reflect.Int32:
|
||||||
if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil {
|
if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil {
|
||||||
fv.SetInt(x)
|
fv.SetInt(x)
|
||||||
@@ -981,9 +980,19 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
|
|||||||
}
|
}
|
||||||
// TODO: Handle nested messages which implement encoding.TextUnmarshaler.
|
// TODO: Handle nested messages which implement encoding.TextUnmarshaler.
|
||||||
return p.readStruct(fv, terminator)
|
return p.readStruct(fv, terminator)
|
||||||
|
case reflect.Uint8:
|
||||||
|
if x, err := strconv.ParseUint(tok.value, 0, 8); err == nil {
|
||||||
|
fv.SetUint(x)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
case reflect.Uint16:
|
||||||
|
if x, err := strconv.ParseUint(tok.value, 0, 16); err == nil {
|
||||||
|
fv.SetUint(x)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
case reflect.Uint32:
|
case reflect.Uint32:
|
||||||
if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
|
if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
|
||||||
fv.SetUint(x)
|
fv.SetUint(uint64(x))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
case reflect.Uint64:
|
case reflect.Uint64:
|
||||||
@@ -1001,13 +1010,9 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
|
|||||||
// UnmarshalText returns *RequiredNotSetError.
|
// UnmarshalText returns *RequiredNotSetError.
|
||||||
func UnmarshalText(s string, pb Message) error {
|
func UnmarshalText(s string, pb Message) error {
|
||||||
if um, ok := pb.(encoding.TextUnmarshaler); ok {
|
if um, ok := pb.(encoding.TextUnmarshaler); ok {
|
||||||
err := um.UnmarshalText([]byte(s))
|
return um.UnmarshalText([]byte(s))
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
pb.Reset()
|
pb.Reset()
|
||||||
v := reflect.ValueOf(pb)
|
v := reflect.ValueOf(pb)
|
||||||
if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil {
|
return newTextParser(s).readStruct(v.Elem(), "")
|
||||||
return pe
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
-180
@@ -47,183 +47,3 @@ func (*timestamp) String() string { return "timestamp<string>" }
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterType((*timestamp)(nil), "gogo.protobuf.proto.timestamp")
|
RegisterType((*timestamp)(nil), "gogo.protobuf.proto.timestamp")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Buffer) decTimestamp() (time.Time, error) {
|
|
||||||
b, err := o.DecodeRawBytes(true)
|
|
||||||
if err != nil {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
tproto := ×tamp{}
|
|
||||||
if err := Unmarshal(b, tproto); err != nil {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
return timestampFromProto(tproto)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_time(p *Properties, base structPointer) error {
|
|
||||||
t, err := o.decTimestamp()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
setPtrCustomType(base, p.field, &t)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_ref_time(p *Properties, base structPointer) error {
|
|
||||||
t, err := o.decTimestamp()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
setCustomType(base, p.field, &t)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_slice_time(p *Properties, base structPointer) error {
|
|
||||||
t, err := o.decTimestamp()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
newBas := appendStructPointer(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType)))
|
|
||||||
var zero field
|
|
||||||
setPtrCustomType(newBas, zero, &t)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) dec_slice_ref_time(p *Properties, base structPointer) error {
|
|
||||||
t, err := o.decTimestamp()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
newBas := appendStructPointer(base, p.field, reflect.SliceOf(timeType))
|
|
||||||
var zero field
|
|
||||||
setCustomType(newBas, zero, &t)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_time(p *Properties, base structPointer) (n int) {
|
|
||||||
structp := structPointer_GetStructPointer(base, p.field)
|
|
||||||
if structPointer_IsNil(structp) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
tim := structPointer_Interface(structp, timeType).(*time.Time)
|
|
||||||
t, err := timestampProto(*tim)
|
|
||||||
if err != nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
size := Size(t)
|
|
||||||
return size + sizeVarint(uint64(size)) + len(p.tagcode)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_time(p *Properties, base structPointer) error {
|
|
||||||
structp := structPointer_GetStructPointer(base, p.field)
|
|
||||||
if structPointer_IsNil(structp) {
|
|
||||||
return ErrNil
|
|
||||||
}
|
|
||||||
tim := structPointer_Interface(structp, timeType).(*time.Time)
|
|
||||||
t, err := timestampProto(*tim)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
data, err := Marshal(t)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_ref_time(p *Properties, base structPointer) (n int) {
|
|
||||||
tim := structPointer_InterfaceAt(base, p.field, timeType).(*time.Time)
|
|
||||||
t, err := timestampProto(*tim)
|
|
||||||
if err != nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
size := Size(t)
|
|
||||||
return size + sizeVarint(uint64(size)) + len(p.tagcode)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_ref_time(p *Properties, base structPointer) error {
|
|
||||||
tim := structPointer_InterfaceAt(base, p.field, timeType).(*time.Time)
|
|
||||||
t, err := timestampProto(*tim)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
data, err := Marshal(t)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_slice_time(p *Properties, base structPointer) (n int) {
|
|
||||||
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType))).(*[]*time.Time)
|
|
||||||
tims := *ptims
|
|
||||||
for i := 0; i < len(tims); i++ {
|
|
||||||
if tims[i] == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
tproto, err := timestampProto(*tims[i])
|
|
||||||
if err != nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
size := Size(tproto)
|
|
||||||
n += len(p.tagcode) + size + sizeVarint(uint64(size))
|
|
||||||
}
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_slice_time(p *Properties, base structPointer) error {
|
|
||||||
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType))).(*[]*time.Time)
|
|
||||||
tims := *ptims
|
|
||||||
for i := 0; i < len(tims); i++ {
|
|
||||||
if tims[i] == nil {
|
|
||||||
return errRepeatedHasNil
|
|
||||||
}
|
|
||||||
tproto, err := timestampProto(*tims[i])
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
data, err := Marshal(tproto)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func size_slice_ref_time(p *Properties, base structPointer) (n int) {
|
|
||||||
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(timeType)).(*[]time.Time)
|
|
||||||
tims := *ptims
|
|
||||||
for i := 0; i < len(tims); i++ {
|
|
||||||
tproto, err := timestampProto(tims[i])
|
|
||||||
if err != nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
size := Size(tproto)
|
|
||||||
n += len(p.tagcode) + size + sizeVarint(uint64(size))
|
|
||||||
}
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Buffer) enc_slice_ref_time(p *Properties, base structPointer) error {
|
|
||||||
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(timeType)).(*[]time.Time)
|
|
||||||
tims := *ptims
|
|
||||||
for i := 0; i < len(tims); i++ {
|
|
||||||
tproto, err := timestampProto(tims[i])
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
data, err := Marshal(tproto)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
o.buf = append(o.buf, p.tagcode...)
|
|
||||||
o.EncodeRawBytes(data)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
+1888
File diff suppressed because it is too large
Load Diff
+113
@@ -0,0 +1,113 @@
|
|||||||
|
// Protocol Buffers for Go with Gadgets
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
|
||||||
|
// http://github.com/gogo/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
package proto
|
||||||
|
|
||||||
|
type float64Value struct {
|
||||||
|
Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *float64Value) Reset() { *m = float64Value{} }
|
||||||
|
func (*float64Value) ProtoMessage() {}
|
||||||
|
func (*float64Value) String() string { return "float64<string>" }
|
||||||
|
|
||||||
|
type float32Value struct {
|
||||||
|
Value float32 `protobuf:"fixed32,1,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *float32Value) Reset() { *m = float32Value{} }
|
||||||
|
func (*float32Value) ProtoMessage() {}
|
||||||
|
func (*float32Value) String() string { return "float32<string>" }
|
||||||
|
|
||||||
|
type int64Value struct {
|
||||||
|
Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *int64Value) Reset() { *m = int64Value{} }
|
||||||
|
func (*int64Value) ProtoMessage() {}
|
||||||
|
func (*int64Value) String() string { return "int64<string>" }
|
||||||
|
|
||||||
|
type uint64Value struct {
|
||||||
|
Value uint64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *uint64Value) Reset() { *m = uint64Value{} }
|
||||||
|
func (*uint64Value) ProtoMessage() {}
|
||||||
|
func (*uint64Value) String() string { return "uint64<string>" }
|
||||||
|
|
||||||
|
type int32Value struct {
|
||||||
|
Value int32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *int32Value) Reset() { *m = int32Value{} }
|
||||||
|
func (*int32Value) ProtoMessage() {}
|
||||||
|
func (*int32Value) String() string { return "int32<string>" }
|
||||||
|
|
||||||
|
type uint32Value struct {
|
||||||
|
Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *uint32Value) Reset() { *m = uint32Value{} }
|
||||||
|
func (*uint32Value) ProtoMessage() {}
|
||||||
|
func (*uint32Value) String() string { return "uint32<string>" }
|
||||||
|
|
||||||
|
type boolValue struct {
|
||||||
|
Value bool `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *boolValue) Reset() { *m = boolValue{} }
|
||||||
|
func (*boolValue) ProtoMessage() {}
|
||||||
|
func (*boolValue) String() string { return "bool<string>" }
|
||||||
|
|
||||||
|
type stringValue struct {
|
||||||
|
Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *stringValue) Reset() { *m = stringValue{} }
|
||||||
|
func (*stringValue) ProtoMessage() {}
|
||||||
|
func (*stringValue) String() string { return "string<string>" }
|
||||||
|
|
||||||
|
type bytesValue struct {
|
||||||
|
Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *bytesValue) Reset() { *m = bytesValue{} }
|
||||||
|
func (*bytesValue) ProtoMessage() {}
|
||||||
|
func (*bytesValue) String() string { return "[]byte<string>" }
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
RegisterType((*float64Value)(nil), "gogo.protobuf.proto.DoubleValue")
|
||||||
|
RegisterType((*float32Value)(nil), "gogo.protobuf.proto.FloatValue")
|
||||||
|
RegisterType((*int64Value)(nil), "gogo.protobuf.proto.Int64Value")
|
||||||
|
RegisterType((*uint64Value)(nil), "gogo.protobuf.proto.UInt64Value")
|
||||||
|
RegisterType((*int32Value)(nil), "gogo.protobuf.proto.Int32Value")
|
||||||
|
RegisterType((*uint32Value)(nil), "gogo.protobuf.proto.UInt32Value")
|
||||||
|
RegisterType((*boolValue)(nil), "gogo.protobuf.proto.BoolValue")
|
||||||
|
RegisterType((*stringValue)(nil), "gogo.protobuf.proto.StringValue")
|
||||||
|
RegisterType((*bytesValue)(nil), "gogo.protobuf.proto.BytesValue")
|
||||||
|
}
|
||||||
+702
-176
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+4
-32
@@ -1,43 +1,15 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: descriptor.proto
|
// source: descriptor.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package descriptor is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
descriptor.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
FileDescriptorSet
|
|
||||||
FileDescriptorProto
|
|
||||||
DescriptorProto
|
|
||||||
ExtensionRangeOptions
|
|
||||||
FieldDescriptorProto
|
|
||||||
OneofDescriptorProto
|
|
||||||
EnumDescriptorProto
|
|
||||||
EnumValueDescriptorProto
|
|
||||||
ServiceDescriptorProto
|
|
||||||
MethodDescriptorProto
|
|
||||||
FileOptions
|
|
||||||
MessageOptions
|
|
||||||
FieldOptions
|
|
||||||
OneofOptions
|
|
||||||
EnumOptions
|
|
||||||
EnumValueOptions
|
|
||||||
ServiceOptions
|
|
||||||
MethodOptions
|
|
||||||
UninterpretedOption
|
|
||||||
SourceCodeInfo
|
|
||||||
GeneratedCodeInfo
|
|
||||||
*/
|
|
||||||
package descriptor
|
package descriptor
|
||||||
|
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import strings "strings"
|
import strings "strings"
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
|
||||||
import sort "sort"
|
import sort "sort"
|
||||||
import strconv "strconv"
|
import strconv "strconv"
|
||||||
import reflect "reflect"
|
import reflect "reflect"
|
||||||
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
import math "math"
|
import math "math"
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
@@ -752,8 +724,8 @@ func valueToGoStringDescriptor(v interface{}, typ string) string {
|
|||||||
pv := reflect.Indirect(rv).Interface()
|
pv := reflect.Indirect(rv).Interface()
|
||||||
return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
|
return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
|
||||||
}
|
}
|
||||||
func extensionToGoStringDescriptor(m proto.Message) string {
|
func extensionToGoStringDescriptor(m github_com_gogo_protobuf_proto.Message) string {
|
||||||
e := proto.GetUnsafeExtensionsMap(m)
|
e := github_com_gogo_protobuf_proto.GetUnsafeExtensionsMap(m)
|
||||||
if e == nil {
|
if e == nil {
|
||||||
return "nil"
|
return "nil"
|
||||||
}
|
}
|
||||||
|
|||||||
+1919
-1402
File diff suppressed because it is too large
Load Diff
+23
-10
@@ -118,7 +118,7 @@ func (this *pluginImports) NewImport(pkg string) Single {
|
|||||||
func (this *pluginImports) GenerateImports(file *FileDescriptor) {
|
func (this *pluginImports) GenerateImports(file *FileDescriptor) {
|
||||||
for _, s := range this.singles {
|
for _, s := range this.singles {
|
||||||
if s.IsUsed() {
|
if s.IsUsed() {
|
||||||
this.generator.PrintImport(s.Name(), s.Location())
|
this.generator.PrintImport(GoPackageName(s.Name()), GoImportPath(s.Location()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ type importedPackage struct {
|
|||||||
importPrefix string
|
importPrefix string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newImportedPackage(importPrefix, pkg string) *importedPackage {
|
func newImportedPackage(importPrefix string, pkg string) *importedPackage {
|
||||||
return &importedPackage{
|
return &importedPackage{
|
||||||
pkg: pkg,
|
pkg: pkg,
|
||||||
importPrefix: importPrefix,
|
importPrefix: importPrefix,
|
||||||
@@ -146,7 +146,7 @@ func newImportedPackage(importPrefix, pkg string) *importedPackage {
|
|||||||
|
|
||||||
func (this *importedPackage) Use() string {
|
func (this *importedPackage) Use() string {
|
||||||
if !this.used {
|
if !this.used {
|
||||||
this.name = RegisterUniquePackageName(this.pkg, nil)
|
this.name = string(cleanPackageName(this.pkg))
|
||||||
this.used = true
|
this.used = true
|
||||||
}
|
}
|
||||||
return this.name
|
return this.name
|
||||||
@@ -182,7 +182,7 @@ func (g *Generator) GetFieldName(message *Descriptor, field *descriptor.FieldDes
|
|||||||
return fieldname + "_"
|
return fieldname + "_"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !gogoproto.IsProtoSizer(message.file, message.DescriptorProto) {
|
if !gogoproto.IsProtoSizer(message.file.FileDescriptorProto, message.DescriptorProto) {
|
||||||
if fieldname == "Size" {
|
if fieldname == "Size" {
|
||||||
return fieldname + "_"
|
return fieldname + "_"
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ func (g *Generator) GetOneOfFieldName(message *Descriptor, field *descriptor.Fie
|
|||||||
return fieldname + "_"
|
return fieldname + "_"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !gogoproto.IsProtoSizer(message.file, message.DescriptorProto) {
|
if !gogoproto.IsProtoSizer(message.file.FileDescriptorProto, message.DescriptorProto) {
|
||||||
if fieldname == "Size" {
|
if fieldname == "Size" {
|
||||||
return fieldname + "_"
|
return fieldname + "_"
|
||||||
}
|
}
|
||||||
@@ -262,6 +262,13 @@ func (g *Generator) GetMapValueField(field, valField *descriptor.FieldDescriptor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wktptr := gogoproto.IsWktPtr(field)
|
||||||
|
if wktptr {
|
||||||
|
if err := proto.SetExtension(valField.Options, gogoproto.E_Wktpointer, &wktptr); err != nil {
|
||||||
|
g.Fail(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if valType := gogoproto.GetCastValue(field); len(valType) > 0 {
|
if valType := gogoproto.GetCastValue(field); len(valType) > 0 {
|
||||||
if err := proto.SetExtension(valField.Options, gogoproto.E_Casttype, &valType); err != nil {
|
if err := proto.SetExtension(valField.Options, gogoproto.E_Casttype, &valType); err != nil {
|
||||||
g.Fail(err.Error())
|
g.Fail(err.Error())
|
||||||
@@ -333,20 +340,22 @@ func (g *Generator) GeneratePlugin(p Plugin) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
g.Response.File = append(g.Response.File, &plugin.CodeGeneratorResponse_File{
|
g.Response.File = append(g.Response.File, &plugin.CodeGeneratorResponse_File{
|
||||||
Name: proto.String(file.goFileName()),
|
Name: proto.String(file.goFileName(g.pathType)),
|
||||||
Content: proto.String(g.String()),
|
Content: proto.String(g.String()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Generator) SetFile(file *descriptor.FileDescriptorProto) {
|
func (g *Generator) SetFile(filename string) {
|
||||||
g.file = g.FileOf(file)
|
g.file = g.fileByName(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Generator) generatePlugin(file *FileDescriptor, p Plugin) {
|
func (g *Generator) generatePlugin(file *FileDescriptor, p Plugin) {
|
||||||
g.writtenImports = make(map[string]bool)
|
g.writtenImports = make(map[string]bool)
|
||||||
g.file = g.FileOf(file.FileDescriptorProto)
|
g.usedPackages = make(map[GoImportPath]bool)
|
||||||
g.usedPackages = make(map[string]bool)
|
g.packageNames = make(map[GoImportPath]GoPackageName)
|
||||||
|
g.usedPackageNames = make(map[GoPackageName]bool)
|
||||||
|
g.file = file
|
||||||
|
|
||||||
// Run the plugins before the imports so we know which imports are necessary.
|
// Run the plugins before the imports so we know which imports are necessary.
|
||||||
p.Generate(file)
|
p.Generate(file)
|
||||||
@@ -445,3 +454,7 @@ func (g *Generator) useTypes() string {
|
|||||||
g.customImports = append(g.customImports, "github.com/gogo/protobuf/types")
|
g.customImports = append(g.customImports, "github.com/gogo/protobuf/types")
|
||||||
return pkg
|
return pkg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *FileDescriptor) GoPackageName() string {
|
||||||
|
return string(d.packageName)
|
||||||
|
}
|
||||||
|
|||||||
Generated
Vendored
+117
@@ -0,0 +1,117 @@
|
|||||||
|
// Go support for Protocol Buffers - Google's data interchange format
|
||||||
|
//
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// https://github.com/golang/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package remap handles tracking the locations of Go tokens in a source text
|
||||||
|
across a rewrite by the Go formatter.
|
||||||
|
*/
|
||||||
|
package remap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"go/scanner"
|
||||||
|
"go/token"
|
||||||
|
)
|
||||||
|
|
||||||
|
// A Location represents a span of byte offsets in the source text.
|
||||||
|
type Location struct {
|
||||||
|
Pos, End int // End is exclusive
|
||||||
|
}
|
||||||
|
|
||||||
|
// A Map represents a mapping between token locations in an input source text
|
||||||
|
// and locations in the correspnding output text.
|
||||||
|
type Map map[Location]Location
|
||||||
|
|
||||||
|
// Find reports whether the specified span is recorded by m, and if so returns
|
||||||
|
// the new location it was mapped to. If the input span was not found, the
|
||||||
|
// returned location is the same as the input.
|
||||||
|
func (m Map) Find(pos, end int) (Location, bool) {
|
||||||
|
key := Location{
|
||||||
|
Pos: pos,
|
||||||
|
End: end,
|
||||||
|
}
|
||||||
|
if loc, ok := m[key]; ok {
|
||||||
|
return loc, true
|
||||||
|
}
|
||||||
|
return key, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Map) add(opos, oend, npos, nend int) {
|
||||||
|
m[Location{Pos: opos, End: oend}] = Location{Pos: npos, End: nend}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute constructs a location mapping from input to output. An error is
|
||||||
|
// reported if any of the tokens of output cannot be mapped.
|
||||||
|
func Compute(input, output []byte) (Map, error) {
|
||||||
|
itok := tokenize(input)
|
||||||
|
otok := tokenize(output)
|
||||||
|
if len(itok) != len(otok) {
|
||||||
|
return nil, fmt.Errorf("wrong number of tokens, %d ≠ %d", len(itok), len(otok))
|
||||||
|
}
|
||||||
|
m := make(Map)
|
||||||
|
for i, ti := range itok {
|
||||||
|
to := otok[i]
|
||||||
|
if ti.Token != to.Token {
|
||||||
|
return nil, fmt.Errorf("token %d type mismatch: %s ≠ %s", i+1, ti, to)
|
||||||
|
}
|
||||||
|
m.add(ti.pos, ti.end, to.pos, to.end)
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// tokinfo records the span and type of a source token.
|
||||||
|
type tokinfo struct {
|
||||||
|
pos, end int
|
||||||
|
token.Token
|
||||||
|
}
|
||||||
|
|
||||||
|
func tokenize(src []byte) []tokinfo {
|
||||||
|
fs := token.NewFileSet()
|
||||||
|
var s scanner.Scanner
|
||||||
|
s.Init(fs.AddFile("src", fs.Base(), len(src)), src, nil, scanner.ScanComments)
|
||||||
|
var info []tokinfo
|
||||||
|
for {
|
||||||
|
pos, next, lit := s.Scan()
|
||||||
|
switch next {
|
||||||
|
case token.SEMICOLON:
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
info = append(info, tokinfo{
|
||||||
|
pos: int(pos - 1),
|
||||||
|
end: int(pos + token.Pos(len(lit)) - 1),
|
||||||
|
Token: next,
|
||||||
|
})
|
||||||
|
if next == token.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return info
|
||||||
|
}
|
||||||
+35
-13
@@ -36,6 +36,7 @@ package grpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -128,20 +129,24 @@ func (g *grpc) GenerateImports(file *generator.FileDescriptor) {
|
|||||||
if len(file.FileDescriptorProto.Service) == 0 {
|
if len(file.FileDescriptorProto.Service) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
imports := generator.NewPluginImports(g.gen)
|
g.P("import (")
|
||||||
for _, i := range []string{contextPkgPath, grpcPkgPath} {
|
g.P(contextPkg, " ", generator.GoImportPath(path.Join(string(g.gen.ImportPrefix), contextPkgPath)))
|
||||||
imports.NewImport(i).Use()
|
g.P(grpcPkg, " ", generator.GoImportPath(path.Join(string(g.gen.ImportPrefix), grpcPkgPath)))
|
||||||
}
|
g.P(")")
|
||||||
imports.GenerateImports(file)
|
g.P()
|
||||||
}
|
}
|
||||||
|
|
||||||
// reservedClientName records whether a client name is reserved on the client side.
|
// reservedClientName records whether a client name is reserved on the client side.
|
||||||
var reservedClientName = map[string]bool{
|
var reservedClientName = map[string]bool{
|
||||||
// TODO: do we need any in gRPC?
|
// TODO: do we need any in gRPC?
|
||||||
}
|
}
|
||||||
|
|
||||||
func unexport(s string) string { return strings.ToLower(s[:1]) + s[1:] }
|
func unexport(s string) string { return strings.ToLower(s[:1]) + s[1:] }
|
||||||
|
|
||||||
|
// deprecationComment is the standard comment added to deprecated
|
||||||
|
// messages, fields, enums, and enum values.
|
||||||
|
var deprecationComment = "// Deprecated: Do not use."
|
||||||
|
|
||||||
// generateService generates all the code for the named service.
|
// generateService generates all the code for the named service.
|
||||||
func (g *grpc) generateService(file *generator.FileDescriptor, service *pb.ServiceDescriptorProto, index int) {
|
func (g *grpc) generateService(file *generator.FileDescriptor, service *pb.ServiceDescriptorProto, index int) {
|
||||||
path := fmt.Sprintf("6,%d", index) // 6 means service.
|
path := fmt.Sprintf("6,%d", index) // 6 means service.
|
||||||
@@ -152,12 +157,18 @@ func (g *grpc) generateService(file *generator.FileDescriptor, service *pb.Servi
|
|||||||
fullServName = pkg + "." + fullServName
|
fullServName = pkg + "." + fullServName
|
||||||
}
|
}
|
||||||
servName := generator.CamelCase(origServName)
|
servName := generator.CamelCase(origServName)
|
||||||
|
deprecated := service.GetOptions().GetDeprecated()
|
||||||
|
|
||||||
g.P()
|
g.P()
|
||||||
g.P("// Client API for ", servName, " service")
|
g.P(fmt.Sprintf(`// %sClient is the client API for %s service.
|
||||||
g.P()
|
//
|
||||||
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.`, servName, servName))
|
||||||
|
|
||||||
// Client interface.
|
// Client interface.
|
||||||
|
if deprecated {
|
||||||
|
g.P("//")
|
||||||
|
g.P(deprecationComment)
|
||||||
|
}
|
||||||
g.P("type ", servName, "Client interface {")
|
g.P("type ", servName, "Client interface {")
|
||||||
for i, method := range service.Method {
|
for i, method := range service.Method {
|
||||||
g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service.
|
g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service.
|
||||||
@@ -173,6 +184,9 @@ func (g *grpc) generateService(file *generator.FileDescriptor, service *pb.Servi
|
|||||||
g.P()
|
g.P()
|
||||||
|
|
||||||
// NewClient factory.
|
// NewClient factory.
|
||||||
|
if deprecated {
|
||||||
|
g.P(deprecationComment)
|
||||||
|
}
|
||||||
g.P("func New", servName, "Client (cc *", grpcPkg, ".ClientConn) ", servName, "Client {")
|
g.P("func New", servName, "Client (cc *", grpcPkg, ".ClientConn) ", servName, "Client {")
|
||||||
g.P("return &", unexport(servName), "Client{cc}")
|
g.P("return &", unexport(servName), "Client{cc}")
|
||||||
g.P("}")
|
g.P("}")
|
||||||
@@ -195,11 +209,13 @@ func (g *grpc) generateService(file *generator.FileDescriptor, service *pb.Servi
|
|||||||
g.generateClientMethod(servName, fullServName, serviceDescVar, method, descExpr)
|
g.generateClientMethod(servName, fullServName, serviceDescVar, method, descExpr)
|
||||||
}
|
}
|
||||||
|
|
||||||
g.P("// Server API for ", servName, " service")
|
|
||||||
g.P()
|
|
||||||
|
|
||||||
// Server interface.
|
// Server interface.
|
||||||
serverType := servName + "Server"
|
serverType := servName + "Server"
|
||||||
|
g.P("// ", serverType, " is the server API for ", servName, " service.")
|
||||||
|
if deprecated {
|
||||||
|
g.P("//")
|
||||||
|
g.P(deprecationComment)
|
||||||
|
}
|
||||||
g.P("type ", serverType, " interface {")
|
g.P("type ", serverType, " interface {")
|
||||||
for i, method := range service.Method {
|
for i, method := range service.Method {
|
||||||
g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service.
|
g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service.
|
||||||
@@ -209,6 +225,9 @@ func (g *grpc) generateService(file *generator.FileDescriptor, service *pb.Servi
|
|||||||
g.P()
|
g.P()
|
||||||
|
|
||||||
// Server registration.
|
// Server registration.
|
||||||
|
if deprecated {
|
||||||
|
g.P(deprecationComment)
|
||||||
|
}
|
||||||
g.P("func Register", servName, "Server(s *", grpcPkg, ".Server, srv ", serverType, ") {")
|
g.P("func Register", servName, "Server(s *", grpcPkg, ".Server, srv ", serverType, ") {")
|
||||||
g.P("s.RegisterService(&", serviceDescVar, `, srv)`)
|
g.P("s.RegisterService(&", serviceDescVar, `, srv)`)
|
||||||
g.P("}")
|
g.P("}")
|
||||||
@@ -282,11 +301,14 @@ func (g *grpc) generateClientMethod(servName, fullServName, serviceDescVar strin
|
|||||||
inType := g.typeName(method.GetInputType())
|
inType := g.typeName(method.GetInputType())
|
||||||
outType := g.typeName(method.GetOutputType())
|
outType := g.typeName(method.GetOutputType())
|
||||||
|
|
||||||
|
if method.GetOptions().GetDeprecated() {
|
||||||
|
g.P(deprecationComment)
|
||||||
|
}
|
||||||
g.P("func (c *", unexport(servName), "Client) ", g.generateClientSignature(servName, method), "{")
|
g.P("func (c *", unexport(servName), "Client) ", g.generateClientSignature(servName, method), "{")
|
||||||
if !method.GetServerStreaming() && !method.GetClientStreaming() {
|
if !method.GetServerStreaming() && !method.GetClientStreaming() {
|
||||||
g.P("out := new(", outType, ")")
|
g.P("out := new(", outType, ")")
|
||||||
// TODO: Pass descExpr to Invoke.
|
// TODO: Pass descExpr to Invoke.
|
||||||
g.P("err := ", grpcPkg, `.Invoke(ctx, "`, sname, `", in, out, c.cc, opts...)`)
|
g.P(`err := c.cc.Invoke(ctx, "`, sname, `", in, out, opts...)`)
|
||||||
g.P("if err != nil { return nil, err }")
|
g.P("if err != nil { return nil, err }")
|
||||||
g.P("return out, nil")
|
g.P("return out, nil")
|
||||||
g.P("}")
|
g.P("}")
|
||||||
@@ -294,7 +316,7 @@ func (g *grpc) generateClientMethod(servName, fullServName, serviceDescVar strin
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
streamType := unexport(servName) + methName + "Client"
|
streamType := unexport(servName) + methName + "Client"
|
||||||
g.P("stream, err := ", grpcPkg, ".NewClientStream(ctx, ", descExpr, `, c.cc, "`, sname, `", opts...)`)
|
g.P("stream, err := c.cc.NewStream(ctx, ", descExpr, `, "`, sname, `", opts...)`)
|
||||||
g.P("if err != nil { return nil, err }")
|
g.P("if err != nil { return nil, err }")
|
||||||
g.P("x := &", streamType, "{stream}")
|
g.P("x := &", streamType, "{stream}")
|
||||||
if !method.GetClientStreaming() {
|
if !method.GetClientStreaming() {
|
||||||
|
|||||||
+109
-38
@@ -1,23 +1,12 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: plugin.proto
|
// source: plugin.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package plugin_go is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
plugin.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
Version
|
|
||||||
CodeGeneratorRequest
|
|
||||||
CodeGeneratorResponse
|
|
||||||
*/
|
|
||||||
package plugin_go
|
package plugin_go
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
import descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
var _ = proto.Marshal
|
var _ = proto.Marshal
|
||||||
@@ -37,14 +26,35 @@ type Version struct {
|
|||||||
Patch *int32 `protobuf:"varint,3,opt,name=patch" json:"patch,omitempty"`
|
Patch *int32 `protobuf:"varint,3,opt,name=patch" json:"patch,omitempty"`
|
||||||
// A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
|
// A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
|
||||||
// be empty for mainline stable releases.
|
// be empty for mainline stable releases.
|
||||||
Suffix *string `protobuf:"bytes,4,opt,name=suffix" json:"suffix,omitempty"`
|
Suffix *string `protobuf:"bytes,4,opt,name=suffix" json:"suffix,omitempty"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Version) Reset() { *m = Version{} }
|
func (m *Version) Reset() { *m = Version{} }
|
||||||
func (m *Version) String() string { return proto.CompactTextString(m) }
|
func (m *Version) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Version) ProtoMessage() {}
|
func (*Version) ProtoMessage() {}
|
||||||
func (*Version) Descriptor() ([]byte, []int) { return fileDescriptorPlugin, []int{0} }
|
func (*Version) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_plugin_ac234f81c61f07b3, []int{0}
|
||||||
|
}
|
||||||
|
func (m *Version) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Version.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Version) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Version.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *Version) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Version.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *Version) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Version.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Version) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Version.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Version proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *Version) GetMajor() int32 {
|
func (m *Version) GetMajor() int32 {
|
||||||
if m != nil && m.Major != nil {
|
if m != nil && m.Major != nil {
|
||||||
@@ -96,16 +106,37 @@ type CodeGeneratorRequest struct {
|
|||||||
//
|
//
|
||||||
// Type names of fields and extensions in the FileDescriptorProto are always
|
// Type names of fields and extensions in the FileDescriptorProto are always
|
||||||
// fully qualified.
|
// fully qualified.
|
||||||
ProtoFile []*google_protobuf.FileDescriptorProto `protobuf:"bytes,15,rep,name=proto_file,json=protoFile" json:"proto_file,omitempty"`
|
ProtoFile []*descriptor.FileDescriptorProto `protobuf:"bytes,15,rep,name=proto_file,json=protoFile" json:"proto_file,omitempty"`
|
||||||
// The version number of protocol compiler.
|
// The version number of protocol compiler.
|
||||||
CompilerVersion *Version `protobuf:"bytes,3,opt,name=compiler_version,json=compilerVersion" json:"compiler_version,omitempty"`
|
CompilerVersion *Version `protobuf:"bytes,3,opt,name=compiler_version,json=compilerVersion" json:"compiler_version,omitempty"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CodeGeneratorRequest) Reset() { *m = CodeGeneratorRequest{} }
|
func (m *CodeGeneratorRequest) Reset() { *m = CodeGeneratorRequest{} }
|
||||||
func (m *CodeGeneratorRequest) String() string { return proto.CompactTextString(m) }
|
func (m *CodeGeneratorRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*CodeGeneratorRequest) ProtoMessage() {}
|
func (*CodeGeneratorRequest) ProtoMessage() {}
|
||||||
func (*CodeGeneratorRequest) Descriptor() ([]byte, []int) { return fileDescriptorPlugin, []int{1} }
|
func (*CodeGeneratorRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_plugin_ac234f81c61f07b3, []int{1}
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_CodeGeneratorRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_CodeGeneratorRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *CodeGeneratorRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_CodeGeneratorRequest.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_CodeGeneratorRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_CodeGeneratorRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_CodeGeneratorRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *CodeGeneratorRequest) GetFileToGenerate() []string {
|
func (m *CodeGeneratorRequest) GetFileToGenerate() []string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@@ -121,7 +152,7 @@ func (m *CodeGeneratorRequest) GetParameter() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CodeGeneratorRequest) GetProtoFile() []*google_protobuf.FileDescriptorProto {
|
func (m *CodeGeneratorRequest) GetProtoFile() []*descriptor.FileDescriptorProto {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.ProtoFile
|
return m.ProtoFile
|
||||||
}
|
}
|
||||||
@@ -145,15 +176,36 @@ type CodeGeneratorResponse struct {
|
|||||||
// problem in protoc itself -- such as the input CodeGeneratorRequest being
|
// problem in protoc itself -- such as the input CodeGeneratorRequest being
|
||||||
// unparseable -- should be reported by writing a message to stderr and
|
// unparseable -- should be reported by writing a message to stderr and
|
||||||
// exiting with a non-zero status code.
|
// exiting with a non-zero status code.
|
||||||
Error *string `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"`
|
Error *string `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"`
|
||||||
File []*CodeGeneratorResponse_File `protobuf:"bytes,15,rep,name=file" json:"file,omitempty"`
|
File []*CodeGeneratorResponse_File `protobuf:"bytes,15,rep,name=file" json:"file,omitempty"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CodeGeneratorResponse) Reset() { *m = CodeGeneratorResponse{} }
|
func (m *CodeGeneratorResponse) Reset() { *m = CodeGeneratorResponse{} }
|
||||||
func (m *CodeGeneratorResponse) String() string { return proto.CompactTextString(m) }
|
func (m *CodeGeneratorResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*CodeGeneratorResponse) ProtoMessage() {}
|
func (*CodeGeneratorResponse) ProtoMessage() {}
|
||||||
func (*CodeGeneratorResponse) Descriptor() ([]byte, []int) { return fileDescriptorPlugin, []int{2} }
|
func (*CodeGeneratorResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_plugin_ac234f81c61f07b3, []int{2}
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorResponse) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_CodeGeneratorResponse.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_CodeGeneratorResponse.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *CodeGeneratorResponse) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_CodeGeneratorResponse.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorResponse) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_CodeGeneratorResponse.Size(m)
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorResponse) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_CodeGeneratorResponse.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_CodeGeneratorResponse proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *CodeGeneratorResponse) GetError() string {
|
func (m *CodeGeneratorResponse) GetError() string {
|
||||||
if m != nil && m.Error != nil {
|
if m != nil && m.Error != nil {
|
||||||
@@ -222,16 +274,35 @@ type CodeGeneratorResponse_File struct {
|
|||||||
// If |insertion_point| is present, |name| must also be present.
|
// If |insertion_point| is present, |name| must also be present.
|
||||||
InsertionPoint *string `protobuf:"bytes,2,opt,name=insertion_point,json=insertionPoint" json:"insertion_point,omitempty"`
|
InsertionPoint *string `protobuf:"bytes,2,opt,name=insertion_point,json=insertionPoint" json:"insertion_point,omitempty"`
|
||||||
// The file contents.
|
// The file contents.
|
||||||
Content *string `protobuf:"bytes,15,opt,name=content" json:"content,omitempty"`
|
Content *string `protobuf:"bytes,15,opt,name=content" json:"content,omitempty"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CodeGeneratorResponse_File) Reset() { *m = CodeGeneratorResponse_File{} }
|
func (m *CodeGeneratorResponse_File) Reset() { *m = CodeGeneratorResponse_File{} }
|
||||||
func (m *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(m) }
|
func (m *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(m) }
|
||||||
func (*CodeGeneratorResponse_File) ProtoMessage() {}
|
func (*CodeGeneratorResponse_File) ProtoMessage() {}
|
||||||
func (*CodeGeneratorResponse_File) Descriptor() ([]byte, []int) {
|
func (*CodeGeneratorResponse_File) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptorPlugin, []int{2, 0}
|
return fileDescriptor_plugin_ac234f81c61f07b3, []int{2, 0}
|
||||||
}
|
}
|
||||||
|
func (m *CodeGeneratorResponse_File) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_CodeGeneratorResponse_File.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorResponse_File) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_CodeGeneratorResponse_File.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *CodeGeneratorResponse_File) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_CodeGeneratorResponse_File.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorResponse_File) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_CodeGeneratorResponse_File.Size(m)
|
||||||
|
}
|
||||||
|
func (m *CodeGeneratorResponse_File) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_CodeGeneratorResponse_File.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_CodeGeneratorResponse_File proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *CodeGeneratorResponse_File) GetName() string {
|
func (m *CodeGeneratorResponse_File) GetName() string {
|
||||||
if m != nil && m.Name != nil {
|
if m != nil && m.Name != nil {
|
||||||
@@ -261,9 +332,9 @@ func init() {
|
|||||||
proto.RegisterType((*CodeGeneratorResponse_File)(nil), "google.protobuf.compiler.CodeGeneratorResponse.File")
|
proto.RegisterType((*CodeGeneratorResponse_File)(nil), "google.protobuf.compiler.CodeGeneratorResponse.File")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("plugin.proto", fileDescriptorPlugin) }
|
func init() { proto.RegisterFile("plugin.proto", fileDescriptor_plugin_ac234f81c61f07b3) }
|
||||||
|
|
||||||
var fileDescriptorPlugin = []byte{
|
var fileDescriptor_plugin_ac234f81c61f07b3 = []byte{
|
||||||
// 383 bytes of a gzipped FileDescriptorProto
|
// 383 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcd, 0x6a, 0xd5, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcd, 0x6a, 0xd5, 0x40,
|
||||||
0x14, 0xc7, 0x89, 0x37, 0xb5, 0xe4, 0xb4, 0x34, 0x65, 0xa8, 0x32, 0x94, 0x2e, 0xe2, 0x45, 0x30,
|
0x14, 0xc7, 0x89, 0x37, 0xb5, 0xe4, 0xb4, 0x34, 0x65, 0xa8, 0x32, 0x94, 0x2e, 0xe2, 0x45, 0x30,
|
||||||
|
|||||||
+2
-2
@@ -29,8 +29,8 @@
|
|||||||
regenerate:
|
regenerate:
|
||||||
go install github.com/gogo/protobuf/protoc-gen-gogo
|
go install github.com/gogo/protobuf/protoc-gen-gogo
|
||||||
go install github.com/gogo/protobuf/protoc-gen-combo
|
go install github.com/gogo/protobuf/protoc-gen-combo
|
||||||
protoc --gogo_out=. --proto_path=../:../../../../:../protobuf/:. thetest.proto
|
protoc --gogo_out=. --proto_path=../protobuf/:../:../../../../:. thetest.proto
|
||||||
protoc-gen-combo --default=false --gogo_out=. --proto_path=../:../../../../:../protobuf/:. thetest.proto
|
protoc-gen-combo --default=false --gogo_out=. --proto_path=../protobuf/:../:../../../../:. thetest.proto
|
||||||
cp uuid.go ./combos/both/
|
cp uuid.go ./combos/both/
|
||||||
cp uuid.go ./combos/marshaler/
|
cp uuid.go ./combos/marshaler/
|
||||||
cp uuid.go ./combos/unmarshaler/
|
cp uuid.go ./combos/unmarshaler/
|
||||||
|
|||||||
+1
-1
@@ -29,4 +29,4 @@
|
|||||||
regenerate:
|
regenerate:
|
||||||
go install github.com/gogo/protobuf/protoc-gen-combo
|
go install github.com/gogo/protobuf/protoc-gen-combo
|
||||||
go install github.com/gogo/protobuf/protoc-gen-gogo
|
go install github.com/gogo/protobuf/protoc-gen-gogo
|
||||||
protoc-gen-combo --gogo_out=. --version="3.0.0" --proto_path=../../../../../:../../protobuf/:. casttype.proto
|
protoc-gen-combo --gogo_out=. --version="3.0.0" --proto_path=../../protobuf/:../../../../../:. casttype.proto
|
||||||
|
|||||||
+4332
-1547
File diff suppressed because it is too large
Load Diff
+4
@@ -47,6 +47,10 @@ func PutLittleEndianUint64(b []byte, offset int, v uint64) {
|
|||||||
|
|
||||||
type Uuid []byte
|
type Uuid []byte
|
||||||
|
|
||||||
|
func (uuid Uuid) Bytes() []byte {
|
||||||
|
return uuid
|
||||||
|
}
|
||||||
|
|
||||||
func (uuid Uuid) Marshal() ([]byte, error) {
|
func (uuid Uuid) Marshal() ([]byte, error) {
|
||||||
if len(uuid) == 0 {
|
if len(uuid) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
+1
-1
@@ -27,4 +27,4 @@
|
|||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
regenerate:
|
regenerate:
|
||||||
(protoc -I=. -I=$(GOPATH)/src -I=$(GOPATH)/src/github.com/gogo/protobuf/protobuf --gogo_out=. example.proto)
|
(protoc -I=. -I=$(GOPATH)/src/github.com/gogo/protobuf/protobuf -I=$(GOPATH)/src --gogo_out=. example.proto)
|
||||||
|
|||||||
+545
-321
File diff suppressed because it is too large
Load Diff
+4
@@ -0,0 +1,4 @@
|
|||||||
|
regenerate:
|
||||||
|
go install github.com/gogo/protobuf/protoc-gen-gogo
|
||||||
|
go install github.com/gogo/protobuf/protoc-min-version
|
||||||
|
protoc-min-version --version="3.0.0" --proto_path=../../../../../../:../../../protobuf/:. --gogo_out=. a.proto
|
||||||
+446
@@ -0,0 +1,446 @@
|
|||||||
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
|
// source: a.proto
|
||||||
|
|
||||||
|
package imported
|
||||||
|
|
||||||
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
|
import fmt "fmt"
|
||||||
|
import math "math"
|
||||||
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
|
|
||||||
|
import bytes "bytes"
|
||||||
|
|
||||||
|
import io "io"
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
|
type A struct {
|
||||||
|
F1 string `protobuf:"bytes,1,opt,name=f1,proto3" json:"f1,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *A) Reset() { *m = A{} }
|
||||||
|
func (m *A) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*A) ProtoMessage() {}
|
||||||
|
func (*A) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_a_b3350f4009dfb5d2, []int{0}
|
||||||
|
}
|
||||||
|
func (m *A) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *A) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_A.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *A) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_A.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *A) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *A) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_A.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_A proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *A) GetF1() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.F1
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*A)(nil), "imported.A")
|
||||||
|
}
|
||||||
|
func (this *A) Equal(that interface{}) bool {
|
||||||
|
if that == nil {
|
||||||
|
return this == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
that1, ok := that.(*A)
|
||||||
|
if !ok {
|
||||||
|
that2, ok := that.(A)
|
||||||
|
if ok {
|
||||||
|
that1 = &that2
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if that1 == nil {
|
||||||
|
return this == nil
|
||||||
|
} else if this == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if this.F1 != that1.F1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
func (m *A) Marshal() (dAtA []byte, err error) {
|
||||||
|
size := m.Size()
|
||||||
|
dAtA = make([]byte, size)
|
||||||
|
n, err := m.MarshalTo(dAtA)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dAtA[:n], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *A) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
var i int
|
||||||
|
_ = i
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if len(m.F1) > 0 {
|
||||||
|
dAtA[i] = 0xa
|
||||||
|
i++
|
||||||
|
i = encodeVarintA(dAtA, i, uint64(len(m.F1)))
|
||||||
|
i += copy(dAtA[i:], m.F1)
|
||||||
|
}
|
||||||
|
if m.XXX_unrecognized != nil {
|
||||||
|
i += copy(dAtA[i:], m.XXX_unrecognized)
|
||||||
|
}
|
||||||
|
return i, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func encodeVarintA(dAtA []byte, offset int, v uint64) int {
|
||||||
|
for v >= 1<<7 {
|
||||||
|
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||||
|
v >>= 7
|
||||||
|
offset++
|
||||||
|
}
|
||||||
|
dAtA[offset] = uint8(v)
|
||||||
|
return offset + 1
|
||||||
|
}
|
||||||
|
func NewPopulatedA(r randyA, easy bool) *A {
|
||||||
|
this := &A{}
|
||||||
|
this.F1 = string(randStringA(r))
|
||||||
|
if !easy && r.Intn(10) != 0 {
|
||||||
|
this.XXX_unrecognized = randUnrecognizedA(r, 2)
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
type randyA interface {
|
||||||
|
Float32() float32
|
||||||
|
Float64() float64
|
||||||
|
Int63() int64
|
||||||
|
Int31() int32
|
||||||
|
Uint32() uint32
|
||||||
|
Intn(n int) int
|
||||||
|
}
|
||||||
|
|
||||||
|
func randUTF8RuneA(r randyA) rune {
|
||||||
|
ru := r.Intn(62)
|
||||||
|
if ru < 10 {
|
||||||
|
return rune(ru + 48)
|
||||||
|
} else if ru < 36 {
|
||||||
|
return rune(ru + 55)
|
||||||
|
}
|
||||||
|
return rune(ru + 61)
|
||||||
|
}
|
||||||
|
func randStringA(r randyA) string {
|
||||||
|
v1 := r.Intn(100)
|
||||||
|
tmps := make([]rune, v1)
|
||||||
|
for i := 0; i < v1; i++ {
|
||||||
|
tmps[i] = randUTF8RuneA(r)
|
||||||
|
}
|
||||||
|
return string(tmps)
|
||||||
|
}
|
||||||
|
func randUnrecognizedA(r randyA, maxFieldNumber int) (dAtA []byte) {
|
||||||
|
l := r.Intn(5)
|
||||||
|
for i := 0; i < l; i++ {
|
||||||
|
wire := r.Intn(4)
|
||||||
|
if wire == 3 {
|
||||||
|
wire = 5
|
||||||
|
}
|
||||||
|
fieldNumber := maxFieldNumber + r.Intn(100)
|
||||||
|
dAtA = randFieldA(dAtA, r, fieldNumber, wire)
|
||||||
|
}
|
||||||
|
return dAtA
|
||||||
|
}
|
||||||
|
func randFieldA(dAtA []byte, r randyA, fieldNumber int, wire int) []byte {
|
||||||
|
key := uint32(fieldNumber)<<3 | uint32(wire)
|
||||||
|
switch wire {
|
||||||
|
case 0:
|
||||||
|
dAtA = encodeVarintPopulateA(dAtA, uint64(key))
|
||||||
|
v2 := r.Int63()
|
||||||
|
if r.Intn(2) == 0 {
|
||||||
|
v2 *= -1
|
||||||
|
}
|
||||||
|
dAtA = encodeVarintPopulateA(dAtA, uint64(v2))
|
||||||
|
case 1:
|
||||||
|
dAtA = encodeVarintPopulateA(dAtA, uint64(key))
|
||||||
|
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
|
||||||
|
case 2:
|
||||||
|
dAtA = encodeVarintPopulateA(dAtA, uint64(key))
|
||||||
|
ll := r.Intn(100)
|
||||||
|
dAtA = encodeVarintPopulateA(dAtA, uint64(ll))
|
||||||
|
for j := 0; j < ll; j++ {
|
||||||
|
dAtA = append(dAtA, byte(r.Intn(256)))
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
dAtA = encodeVarintPopulateA(dAtA, uint64(key))
|
||||||
|
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
|
||||||
|
}
|
||||||
|
return dAtA
|
||||||
|
}
|
||||||
|
func encodeVarintPopulateA(dAtA []byte, v uint64) []byte {
|
||||||
|
for v >= 1<<7 {
|
||||||
|
dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
|
||||||
|
v >>= 7
|
||||||
|
}
|
||||||
|
dAtA = append(dAtA, uint8(v))
|
||||||
|
return dAtA
|
||||||
|
}
|
||||||
|
func (m *A) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
l = len(m.F1)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovA(uint64(l))
|
||||||
|
}
|
||||||
|
if m.XXX_unrecognized != nil {
|
||||||
|
n += len(m.XXX_unrecognized)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func sovA(x uint64) (n int) {
|
||||||
|
for {
|
||||||
|
n++
|
||||||
|
x >>= 7
|
||||||
|
if x == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
func sozA(x uint64) (n int) {
|
||||||
|
return sovA(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||||
|
}
|
||||||
|
func (m *A) Unmarshal(dAtA []byte) error {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
preIndex := iNdEx
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowA
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= (uint64(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNum := int32(wire >> 3)
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
if wireType == 4 {
|
||||||
|
return fmt.Errorf("proto: A: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: A: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field F1", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowA
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= (uint64(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthA
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.F1 = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
|
default:
|
||||||
|
iNdEx = preIndex
|
||||||
|
skippy, err := skipA(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if skippy < 0 {
|
||||||
|
return ErrInvalidLengthA
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if iNdEx > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func skipA(dAtA []byte) (n int, err error) {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return 0, ErrIntOverflowA
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= (uint64(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
switch wireType {
|
||||||
|
case 0:
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return 0, ErrIntOverflowA
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx++
|
||||||
|
if dAtA[iNdEx-1] < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return iNdEx, nil
|
||||||
|
case 1:
|
||||||
|
iNdEx += 8
|
||||||
|
return iNdEx, nil
|
||||||
|
case 2:
|
||||||
|
var length int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return 0, ErrIntOverflowA
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
length |= (int(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iNdEx += length
|
||||||
|
if length < 0 {
|
||||||
|
return 0, ErrInvalidLengthA
|
||||||
|
}
|
||||||
|
return iNdEx, nil
|
||||||
|
case 3:
|
||||||
|
for {
|
||||||
|
var innerWire uint64
|
||||||
|
var start int = iNdEx
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return 0, ErrIntOverflowA
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
innerWire |= (uint64(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
innerWireType := int(innerWire & 0x7)
|
||||||
|
if innerWireType == 4 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
next, err := skipA(dAtA[start:])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
iNdEx = start + next
|
||||||
|
}
|
||||||
|
return iNdEx, nil
|
||||||
|
case 4:
|
||||||
|
return iNdEx, nil
|
||||||
|
case 5:
|
||||||
|
iNdEx += 4
|
||||||
|
return iNdEx, nil
|
||||||
|
default:
|
||||||
|
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
panic("unreachable")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrInvalidLengthA = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||||
|
ErrIntOverflowA = fmt.Errorf("proto: integer overflow")
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("a.proto", fileDescriptor_a_b3350f4009dfb5d2) }
|
||||||
|
|
||||||
|
var fileDescriptor_a_b3350f4009dfb5d2 = []byte{
|
||||||
|
// 127 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x62, 0x4f, 0xd4, 0x2b, 0x28,
|
||||||
|
0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xc8, 0xcc, 0x2d, 0xc8, 0x2f, 0x2a, 0x49, 0x4d, 0x91, 0xd2, 0x4d,
|
||||||
|
0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0x4f, 0xcf, 0xd7, 0x07,
|
||||||
|
0x2b, 0x48, 0x2a, 0x4d, 0x03, 0xf3, 0xc0, 0x1c, 0x30, 0x0b, 0xa2, 0x51, 0x49, 0x98, 0x8b, 0xd1,
|
||||||
|
0x51, 0x88, 0x8f, 0x8b, 0x29, 0xcd, 0x50, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x88, 0x29, 0xcd,
|
||||||
|
0xd0, 0x49, 0xe2, 0xc7, 0x43, 0x39, 0xc6, 0x15, 0x8f, 0xe4, 0x18, 0x77, 0x3c, 0x92, 0x63, 0x3c,
|
||||||
|
0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x93, 0xd8, 0xc0, 0xba,
|
||||||
|
0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x70, 0x12, 0x2a, 0xca, 0x79, 0x00, 0x00, 0x00,
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package imported;
|
||||||
|
|
||||||
|
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
|
||||||
|
|
||||||
|
option (gogoproto.sizer_all) = true;
|
||||||
|
option (gogoproto.marshaler_all) = true;
|
||||||
|
option (gogoproto.unmarshaler_all) = true;
|
||||||
|
option (gogoproto.testgen_all) = true;
|
||||||
|
option (gogoproto.populate_all) = true;
|
||||||
|
option (gogoproto.equal_all) = true;
|
||||||
|
|
||||||
|
message A {
|
||||||
|
string f1 = 1;
|
||||||
|
}
|
||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
package imported
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/gogo/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
type B struct {
|
||||||
|
A
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b B) Equal(other B) bool {
|
||||||
|
return b.A.Equal(other.A)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b B) Size() int {
|
||||||
|
return b.A.Size()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPopulatedB(r randyA) *B {
|
||||||
|
a := NewPopulatedA(r, true)
|
||||||
|
if a == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &B{*a}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b B) Marshal() ([]byte, error) {
|
||||||
|
return proto.Marshal(&b.A)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *B) Unmarshal(data []byte) error {
|
||||||
|
a := &A{}
|
||||||
|
err := proto.Unmarshal(data, a)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b.A = *a
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b B) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(b.A)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *B) UnmarshalJSON(data []byte) error {
|
||||||
|
a := &A{}
|
||||||
|
err := json.Unmarshal(data, a)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*b = B{A: *a}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
+28
-16
@@ -1,15 +1,6 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: subpkg/subproto.proto
|
// source: subpkg/subproto.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package subpkg is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
subpkg/subproto.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
SubObject
|
|
||||||
*/
|
|
||||||
package subpkg
|
package subpkg
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
@@ -29,21 +20,42 @@ var _ = math.Inf
|
|||||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type SubObject struct {
|
type SubObject struct {
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SubObject) Reset() { *m = SubObject{} }
|
func (m *SubObject) Reset() { *m = SubObject{} }
|
||||||
func (m *SubObject) String() string { return proto.CompactTextString(m) }
|
func (m *SubObject) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SubObject) ProtoMessage() {}
|
func (*SubObject) ProtoMessage() {}
|
||||||
func (*SubObject) Descriptor() ([]byte, []int) { return fileDescriptorSubproto, []int{0} }
|
func (*SubObject) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_subproto_094c5f22e1aecb1e, []int{0}
|
||||||
|
}
|
||||||
|
func (m *SubObject) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_SubObject.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *SubObject) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_SubObject.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *SubObject) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_SubObject.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *SubObject) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_SubObject.Size(m)
|
||||||
|
}
|
||||||
|
func (m *SubObject) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_SubObject.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_SubObject proto.InternalMessageInfo
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*SubObject)(nil), "subpkg.SubObject")
|
proto.RegisterType((*SubObject)(nil), "subpkg.SubObject")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("subpkg/subproto.proto", fileDescriptorSubproto) }
|
func init() { proto.RegisterFile("subpkg/subproto.proto", fileDescriptor_subproto_094c5f22e1aecb1e) }
|
||||||
|
|
||||||
var fileDescriptorSubproto = []byte{
|
var fileDescriptor_subproto_094c5f22e1aecb1e = []byte{
|
||||||
// 88 bytes of a gzipped FileDescriptorProto
|
// 88 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x2e, 0x4d, 0x2a,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x2e, 0x4d, 0x2a,
|
||||||
0xc8, 0x4e, 0xd7, 0x07, 0x51, 0x45, 0xf9, 0x25, 0xf9, 0x7a, 0x60, 0x52, 0x88, 0x0d, 0x22, 0x2c,
|
0xc8, 0x4e, 0xd7, 0x07, 0x51, 0x45, 0xf9, 0x25, 0xf9, 0x7a, 0x60, 0x52, 0x88, 0x0d, 0x22, 0x2c,
|
||||||
|
|||||||
+41
-19
@@ -1,27 +1,20 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: proto/proto.proto
|
// source: proto/proto.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package proto is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
proto/proto.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
Subject
|
|
||||||
*/
|
|
||||||
package proto
|
package proto
|
||||||
|
|
||||||
import proto1 "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
import _ "github.com/gogo/protobuf/gogoproto"
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
|
|
||||||
|
import bytes "bytes"
|
||||||
|
|
||||||
import strings "strings"
|
import strings "strings"
|
||||||
import reflect "reflect"
|
import reflect "reflect"
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
var _ = proto1.Marshal
|
var _ = proto.Marshal
|
||||||
var _ = fmt.Errorf
|
var _ = fmt.Errorf
|
||||||
var _ = math.Inf
|
var _ = math.Inf
|
||||||
|
|
||||||
@@ -29,18 +22,40 @@ var _ = math.Inf
|
|||||||
// is compatible with the proto package it is being compiled against.
|
// is compatible with the proto package it is being compiled against.
|
||||||
// A compilation error at this line likely means your copy of the
|
// A compilation error at this line likely means your copy of the
|
||||||
// proto package needs to be updated.
|
// proto package needs to be updated.
|
||||||
const _ = proto1.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type Subject struct {
|
type Subject struct {
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Subject) Reset() { *m = Subject{} }
|
func (m *Subject) Reset() { *m = Subject{} }
|
||||||
func (m *Subject) String() string { return proto1.CompactTextString(m) }
|
func (m *Subject) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Subject) ProtoMessage() {}
|
func (*Subject) ProtoMessage() {}
|
||||||
func (*Subject) Descriptor() ([]byte, []int) { return fileDescriptorProto, []int{0} }
|
func (*Subject) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_proto_2eb405ba8c57e5a9, []int{0}
|
||||||
|
}
|
||||||
|
func (m *Subject) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Subject.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Subject) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Subject.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *Subject) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Subject.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *Subject) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Subject.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Subject) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Subject.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Subject proto.InternalMessageInfo
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto1.RegisterType((*Subject)(nil), "proto.Subject")
|
proto.RegisterType((*Subject)(nil), "proto.Subject")
|
||||||
}
|
}
|
||||||
func (this *Subject) Equal(that interface{}) bool {
|
func (this *Subject) Equal(that interface{}) bool {
|
||||||
if that == nil {
|
if that == nil {
|
||||||
@@ -61,6 +76,9 @@ func (this *Subject) Equal(that interface{}) bool {
|
|||||||
} else if this == nil {
|
} else if this == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
func (this *Subject) GoString() string {
|
func (this *Subject) GoString() string {
|
||||||
@@ -69,6 +87,9 @@ func (this *Subject) GoString() string {
|
|||||||
}
|
}
|
||||||
s := make([]string, 0, 4)
|
s := make([]string, 0, 4)
|
||||||
s = append(s, "&proto.Subject{")
|
s = append(s, "&proto.Subject{")
|
||||||
|
if this.XXX_unrecognized != nil {
|
||||||
|
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
|
||||||
|
}
|
||||||
s = append(s, "}")
|
s = append(s, "}")
|
||||||
return strings.Join(s, "")
|
return strings.Join(s, "")
|
||||||
}
|
}
|
||||||
@@ -83,6 +104,7 @@ func valueToGoStringProto(v interface{}, typ string) string {
|
|||||||
func NewPopulatedSubject(r randyProto, easy bool) *Subject {
|
func NewPopulatedSubject(r randyProto, easy bool) *Subject {
|
||||||
this := &Subject{}
|
this := &Subject{}
|
||||||
if !easy && r.Intn(10) != 0 {
|
if !easy && r.Intn(10) != 0 {
|
||||||
|
this.XXX_unrecognized = randUnrecognizedProto(r, 1)
|
||||||
}
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@@ -160,9 +182,9 @@ func encodeVarintPopulateProto(dAtA []byte, v uint64) []byte {
|
|||||||
return dAtA
|
return dAtA
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto1.RegisterFile("proto/proto.proto", fileDescriptorProto) }
|
func init() { proto.RegisterFile("proto/proto.proto", fileDescriptor_proto_2eb405ba8c57e5a9) }
|
||||||
|
|
||||||
var fileDescriptorProto = []byte{
|
var fileDescriptor_proto_2eb405ba8c57e5a9 = []byte{
|
||||||
// 103 bytes of a gzipped FileDescriptorProto
|
// 103 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x28, 0xca, 0x2f,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x28, 0xca, 0x2f,
|
||||||
0xc9, 0xd7, 0x07, 0x93, 0x7a, 0x60, 0x52, 0x88, 0x15, 0x4c, 0x49, 0xe9, 0xa6, 0x67, 0x96, 0x64,
|
0xc9, 0xd7, 0x07, 0x93, 0x7a, 0x60, 0x52, 0x88, 0x15, 0x4c, 0x49, 0xe9, 0xa6, 0x67, 0x96, 0x64,
|
||||||
|
|||||||
+37
-15
@@ -1,15 +1,6 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: sortkeys/sortable.proto
|
// source: sortkeys/sortable.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package sortkeys is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
sortkeys/sortable.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
Object
|
|
||||||
*/
|
|
||||||
package sortkeys
|
package sortkeys
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
@@ -17,6 +8,8 @@ import fmt "fmt"
|
|||||||
import math "math"
|
import math "math"
|
||||||
import _ "github.com/gogo/protobuf/gogoproto"
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
|
|
||||||
|
import bytes "bytes"
|
||||||
|
|
||||||
import strings "strings"
|
import strings "strings"
|
||||||
import reflect "reflect"
|
import reflect "reflect"
|
||||||
|
|
||||||
@@ -32,12 +25,34 @@ var _ = math.Inf
|
|||||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type Object struct {
|
type Object struct {
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Object) Reset() { *m = Object{} }
|
func (m *Object) Reset() { *m = Object{} }
|
||||||
func (m *Object) String() string { return proto.CompactTextString(m) }
|
func (m *Object) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Object) ProtoMessage() {}
|
func (*Object) ProtoMessage() {}
|
||||||
func (*Object) Descriptor() ([]byte, []int) { return fileDescriptorSortable, []int{0} }
|
func (*Object) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_sortable_d1adc3e2593f24f3, []int{0}
|
||||||
|
}
|
||||||
|
func (m *Object) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Object.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Object) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Object.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *Object) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Object.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *Object) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Object.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Object) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Object.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Object proto.InternalMessageInfo
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*Object)(nil), "sortkeys.Object")
|
proto.RegisterType((*Object)(nil), "sortkeys.Object")
|
||||||
@@ -61,6 +76,9 @@ func (this *Object) Equal(that interface{}) bool {
|
|||||||
} else if this == nil {
|
} else if this == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
func (this *Object) GoString() string {
|
func (this *Object) GoString() string {
|
||||||
@@ -69,6 +87,9 @@ func (this *Object) GoString() string {
|
|||||||
}
|
}
|
||||||
s := make([]string, 0, 4)
|
s := make([]string, 0, 4)
|
||||||
s = append(s, "&sortkeys.Object{")
|
s = append(s, "&sortkeys.Object{")
|
||||||
|
if this.XXX_unrecognized != nil {
|
||||||
|
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
|
||||||
|
}
|
||||||
s = append(s, "}")
|
s = append(s, "}")
|
||||||
return strings.Join(s, "")
|
return strings.Join(s, "")
|
||||||
}
|
}
|
||||||
@@ -83,6 +104,7 @@ func valueToGoStringSortable(v interface{}, typ string) string {
|
|||||||
func NewPopulatedObject(r randySortable, easy bool) *Object {
|
func NewPopulatedObject(r randySortable, easy bool) *Object {
|
||||||
this := &Object{}
|
this := &Object{}
|
||||||
if !easy && r.Intn(10) != 0 {
|
if !easy && r.Intn(10) != 0 {
|
||||||
|
this.XXX_unrecognized = randUnrecognizedSortable(r, 1)
|
||||||
}
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@@ -160,9 +182,9 @@ func encodeVarintPopulateSortable(dAtA []byte, v uint64) []byte {
|
|||||||
return dAtA
|
return dAtA
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("sortkeys/sortable.proto", fileDescriptorSortable) }
|
func init() { proto.RegisterFile("sortkeys/sortable.proto", fileDescriptor_sortable_d1adc3e2593f24f3) }
|
||||||
|
|
||||||
var fileDescriptorSortable = []byte{
|
var fileDescriptor_sortable_d1adc3e2593f24f3 = []byte{
|
||||||
// 115 bytes of a gzipped FileDescriptorProto
|
// 115 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2f, 0xce, 0x2f, 0x2a,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2f, 0xce, 0x2f, 0x2a,
|
||||||
0xc9, 0x4e, 0xad, 0x2c, 0xd6, 0x07, 0x31, 0x12, 0x93, 0x72, 0x52, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b,
|
0xc9, 0x4e, 0xad, 0x2c, 0xd6, 0x07, 0x31, 0x12, 0x93, 0x72, 0x52, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b,
|
||||||
|
|||||||
+42
-18
@@ -1,15 +1,6 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: index.proto
|
// source: index.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package index is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
index.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
IndexQuery
|
|
||||||
*/
|
|
||||||
package index
|
package index
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
@@ -33,15 +24,45 @@ var _ = math.Inf
|
|||||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type IndexQuery struct {
|
type IndexQuery struct {
|
||||||
Key *string `protobuf:"bytes,1,opt,name=Key" json:"Key,omitempty"`
|
Key *string `protobuf:"bytes,1,opt,name=Key" json:"Key,omitempty"`
|
||||||
Value *string `protobuf:"bytes,2,opt,name=Value" json:"Value,omitempty"`
|
Value *string `protobuf:"bytes,2,opt,name=Value" json:"Value,omitempty"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *IndexQuery) Reset() { *m = IndexQuery{} }
|
func (m *IndexQuery) Reset() { *m = IndexQuery{} }
|
||||||
func (m *IndexQuery) String() string { return proto.CompactTextString(m) }
|
func (m *IndexQuery) String() string { return proto.CompactTextString(m) }
|
||||||
func (*IndexQuery) ProtoMessage() {}
|
func (*IndexQuery) ProtoMessage() {}
|
||||||
func (*IndexQuery) Descriptor() ([]byte, []int) { return fileDescriptorIndex, []int{0} }
|
func (*IndexQuery) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_index_5bc64712555c00b6, []int{0}
|
||||||
|
}
|
||||||
|
func (m *IndexQuery) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *IndexQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_IndexQuery.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalTo(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (dst *IndexQuery) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_IndexQuery.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *IndexQuery) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *IndexQuery) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_IndexQuery.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_IndexQuery proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *IndexQuery) GetKey() string {
|
func (m *IndexQuery) GetKey() string {
|
||||||
if m != nil && m.Key != nil {
|
if m != nil && m.Key != nil {
|
||||||
@@ -233,6 +254,9 @@ func encodeVarintPopulateIndex(dAtA []byte, v uint64) []byte {
|
|||||||
return dAtA
|
return dAtA
|
||||||
}
|
}
|
||||||
func (m *IndexQuery) Size() (n int) {
|
func (m *IndexQuery) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
if m.Key != nil {
|
if m.Key != nil {
|
||||||
@@ -478,9 +502,9 @@ var (
|
|||||||
ErrIntOverflowIndex = fmt.Errorf("proto: integer overflow")
|
ErrIntOverflowIndex = fmt.Errorf("proto: integer overflow")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { proto.RegisterFile("index.proto", fileDescriptorIndex) }
|
func init() { proto.RegisterFile("index.proto", fileDescriptor_index_5bc64712555c00b6) }
|
||||||
|
|
||||||
var fileDescriptorIndex = []byte{
|
var fileDescriptor_index_5bc64712555c00b6 = []byte{
|
||||||
// 141 bytes of a gzipped FileDescriptorProto
|
// 141 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xce, 0xcc, 0x4b, 0x49,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xce, 0xcc, 0x4b, 0x49,
|
||||||
0xad, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x73, 0xa4, 0x74, 0xd3, 0x33, 0x4b,
|
0xad, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x73, 0xa4, 0x74, 0xd3, 0x33, 0x4b,
|
||||||
|
|||||||
+5
-11
@@ -1,14 +1,6 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: issue312.proto
|
// source: issue312.proto
|
||||||
|
|
||||||
/*
|
|
||||||
Package issue312 is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
issue312.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
*/
|
|
||||||
package issue312
|
package issue312
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
@@ -62,15 +54,17 @@ func (x *TaskState) UnmarshalJSON(data []byte) error {
|
|||||||
*x = TaskState(value)
|
*x = TaskState(value)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (TaskState) EnumDescriptor() ([]byte, []int) { return fileDescriptorIssue312, []int{0} }
|
func (TaskState) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_issue312_ffe23d3d41bbbf36, []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterEnum("issue312.TaskState", TaskState_name, TaskState_value)
|
proto.RegisterEnum("issue312.TaskState", TaskState_name, TaskState_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("issue312.proto", fileDescriptorIssue312) }
|
func init() { proto.RegisterFile("issue312.proto", fileDescriptor_issue312_ffe23d3d41bbbf36) }
|
||||||
|
|
||||||
var fileDescriptorIssue312 = []byte{
|
var fileDescriptor_issue312_ffe23d3d41bbbf36 = []byte{
|
||||||
// 147 bytes of a gzipped FileDescriptorProto
|
// 147 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0x2c, 0x2e, 0x2e,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0x2c, 0x2e, 0x2e,
|
||||||
0x4d, 0x35, 0x36, 0x34, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x80, 0xf1, 0xa5, 0x74,
|
0x4d, 0x35, 0x36, 0x34, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x80, 0xf1, 0xa5, 0x74,
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
regenerate:
|
||||||
|
go install github.com/gogo/protobuf/protoc-gen-gogo
|
||||||
|
protoc-min-version --version="3.0.0" --gogo_out=Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types:. --proto_path=../../../../../:../../protobuf/:. issue411.proto
|
||||||
+222
@@ -0,0 +1,222 @@
|
|||||||
|
package issue411
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TraceID is a random 128bit identifier for a trace
|
||||||
|
type TraceID struct {
|
||||||
|
Low uint64 `json:"lo"`
|
||||||
|
High uint64 `json:"hi"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SpanID is a random 64bit identifier for a span
|
||||||
|
type SpanID uint64
|
||||||
|
|
||||||
|
// ------- TraceID -------
|
||||||
|
|
||||||
|
// NewTraceID creates a new TraceID from two 64bit unsigned ints.
|
||||||
|
func NewTraceID(high, low uint64) TraceID {
|
||||||
|
return TraceID{High: high, Low: low}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t TraceID) String() string {
|
||||||
|
if t.High == 0 {
|
||||||
|
return fmt.Sprintf("%x", t.Low)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%x%016x", t.High, t.Low)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TraceIDFromString creates a TraceID from a hexadecimal string
|
||||||
|
func TraceIDFromString(s string) (TraceID, error) {
|
||||||
|
var hi, lo uint64
|
||||||
|
var err error
|
||||||
|
if len(s) > 32 {
|
||||||
|
return TraceID{}, fmt.Errorf("TraceID cannot be longer than 32 hex characters: %s", s)
|
||||||
|
} else if len(s) > 16 {
|
||||||
|
hiLen := len(s) - 16
|
||||||
|
if hi, err = strconv.ParseUint(s[0:hiLen], 16, 64); err != nil {
|
||||||
|
return TraceID{}, err
|
||||||
|
}
|
||||||
|
if lo, err = strconv.ParseUint(s[hiLen:], 16, 64); err != nil {
|
||||||
|
return TraceID{}, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if lo, err = strconv.ParseUint(s, 16, 64); err != nil {
|
||||||
|
return TraceID{}, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TraceID{High: hi, Low: lo}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalText is called by encoding/json, which we do not want people to use.
|
||||||
|
func (t TraceID) MarshalText() ([]byte, error) {
|
||||||
|
return nil, fmt.Errorf("unsupported method TraceID.MarshalText; please use github.com/gogo/protobuf/jsonpb for marshalling")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalText is called by encoding/json, which we do not want people to use.
|
||||||
|
func (t *TraceID) UnmarshalText(text []byte) error {
|
||||||
|
return fmt.Errorf("unsupported method TraceID.UnmarshalText; please use github.com/gogo/protobuf/jsonpb for marshalling")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Size returns the size of this datum in protobuf. It is always 16 bytes.
|
||||||
|
func (t *TraceID) Size() int {
|
||||||
|
return 16
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marshal converts trace ID into a binary representation. Called by protobuf serialization.
|
||||||
|
func (t TraceID) Marshal() ([]byte, error) {
|
||||||
|
b := make([]byte, t.Size())
|
||||||
|
_, err := t.MarshalTo(b)
|
||||||
|
return b, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalTo converts trace ID into a binary representation. Called by protobuf serialization.
|
||||||
|
func (t *TraceID) MarshalTo(data []byte) (n int, err error) {
|
||||||
|
var b [16]byte
|
||||||
|
binary.BigEndian.PutUint64(b[:8], uint64(t.High))
|
||||||
|
binary.BigEndian.PutUint64(b[8:], uint64(t.Low))
|
||||||
|
return marshalBytes(data, b[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unmarshal inflates this trace ID from binary representation. Called by protobuf serialization.
|
||||||
|
func (t *TraceID) Unmarshal(data []byte) error {
|
||||||
|
if len(data) < 16 {
|
||||||
|
return fmt.Errorf("buffer is too short")
|
||||||
|
}
|
||||||
|
t.High = binary.BigEndian.Uint64(data[:8])
|
||||||
|
t.Low = binary.BigEndian.Uint64(data[8:])
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func marshalBytes(dst []byte, src []byte) (n int, err error) {
|
||||||
|
if len(dst) < len(src) {
|
||||||
|
return 0, fmt.Errorf("buffer is too short")
|
||||||
|
}
|
||||||
|
return copy(dst, src), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON converts trace id into a base64 string enclosed in quotes.
|
||||||
|
// Used by protobuf JSON serialization.
|
||||||
|
// Example: {high:2, low:1} => "AAAAAAAAAAIAAAAAAAAAAQ==".
|
||||||
|
func (t TraceID) MarshalJSON() ([]byte, error) {
|
||||||
|
var b [16]byte
|
||||||
|
_, err := t.MarshalTo(b[:]) // can only error on incorrect buffer size
|
||||||
|
if err != nil {
|
||||||
|
return []byte{}, err
|
||||||
|
}
|
||||||
|
s := make([]byte, 24+2)
|
||||||
|
base64.StdEncoding.Encode(s[1:25], b[:])
|
||||||
|
s[0], s[25] = '"', '"'
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON inflates trace id from base64 string, possibly enclosed in quotes.
|
||||||
|
// User by protobuf JSON serialization.
|
||||||
|
func (t *TraceID) UnmarshalJSON(data []byte) error {
|
||||||
|
s := string(data)
|
||||||
|
if l := len(s); l > 2 && s[0] == '"' && s[l-1] == '"' {
|
||||||
|
s = s[1 : l-1]
|
||||||
|
}
|
||||||
|
b, err := base64.StdEncoding.DecodeString(s)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot unmarshal TraceID from string '%s': %v", string(data), err)
|
||||||
|
}
|
||||||
|
return t.Unmarshal(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------- SpanID -------
|
||||||
|
|
||||||
|
// NewSpanID creates a new SpanID from a 64bit unsigned int.
|
||||||
|
func NewSpanID(v uint64) SpanID {
|
||||||
|
return SpanID(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SpanID) String() string {
|
||||||
|
return fmt.Sprintf("%x", uint64(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SpanIDFromString creates a SpanID from a hexadecimal string
|
||||||
|
func SpanIDFromString(s string) (SpanID, error) {
|
||||||
|
if len(s) > 16 {
|
||||||
|
return SpanID(0), fmt.Errorf("SpanID cannot be longer than 16 hex characters: %s", s)
|
||||||
|
}
|
||||||
|
id, err := strconv.ParseUint(s, 16, 64)
|
||||||
|
if err != nil {
|
||||||
|
return SpanID(0), err
|
||||||
|
}
|
||||||
|
return SpanID(id), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalText is called by encoding/json, which we do not want people to use.
|
||||||
|
func (s SpanID) MarshalText() ([]byte, error) {
|
||||||
|
return nil, fmt.Errorf("unsupported method SpanID.MarshalText; please use github.com/gogo/protobuf/jsonpb for marshalling")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalText is called by encoding/json, which we do not want people to use.
|
||||||
|
func (s *SpanID) UnmarshalText(text []byte) error {
|
||||||
|
return fmt.Errorf("unsupported method SpanID.UnmarshalText; please use github.com/gogo/protobuf/jsonpb for marshalling")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Size returns the size of this datum in protobuf. It is always 8 bytes.
|
||||||
|
func (s *SpanID) Size() int {
|
||||||
|
return 8
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marshal converts span ID into a binary representation. Called by protobuf serialization.
|
||||||
|
func (s SpanID) Marshal() ([]byte, error) {
|
||||||
|
b := make([]byte, s.Size())
|
||||||
|
_, err := s.MarshalTo(b)
|
||||||
|
return b, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalTo converts span ID into a binary representation. Called by protobuf serialization.
|
||||||
|
func (s *SpanID) MarshalTo(data []byte) (n int, err error) {
|
||||||
|
var b [8]byte
|
||||||
|
binary.BigEndian.PutUint64(b[:], uint64(*s))
|
||||||
|
return marshalBytes(data, b[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unmarshal inflates span ID from a binary representation. Called by protobuf serialization.
|
||||||
|
func (s *SpanID) Unmarshal(data []byte) error {
|
||||||
|
if len(data) < 8 {
|
||||||
|
return fmt.Errorf("buffer is too short")
|
||||||
|
}
|
||||||
|
*s = NewSpanID(binary.BigEndian.Uint64(data))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON converts span id into a base64 string enclosed in quotes.
|
||||||
|
// Used by protobuf JSON serialization.
|
||||||
|
// Example: {1} => "AAAAAAAAAAE=".
|
||||||
|
func (s SpanID) MarshalJSON() ([]byte, error) {
|
||||||
|
var b [8]byte
|
||||||
|
_, err := s.MarshalTo(b[:]) // can only error on incorrect buffer size
|
||||||
|
if err != nil {
|
||||||
|
return []byte{}, err
|
||||||
|
}
|
||||||
|
v := make([]byte, 12+2)
|
||||||
|
base64.StdEncoding.Encode(v[1:13], b[:])
|
||||||
|
v[0], v[13] = '"', '"'
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON inflates span id from base64 string, possibly enclosed in quotes.
|
||||||
|
// User by protobuf JSON serialization.
|
||||||
|
//
|
||||||
|
// There appears to be a bug in gogoproto, as this function is only called for numeric values.
|
||||||
|
// https://github.com/gogo/protobuf/issues/411#issuecomment-393856837
|
||||||
|
func (s *SpanID) UnmarshalJSON(data []byte) error {
|
||||||
|
str := string(data)
|
||||||
|
if l := len(str); l > 2 && str[0] == '"' && str[l-1] == '"' {
|
||||||
|
str = str[1 : l-1]
|
||||||
|
}
|
||||||
|
b, err := base64.StdEncoding.DecodeString(str)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot unmarshal SpanID from string '%s': %v", string(data), err)
|
||||||
|
}
|
||||||
|
return s.Unmarshal(b)
|
||||||
|
}
|
||||||
+72
@@ -0,0 +1,72 @@
|
|||||||
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
|
// source: issue411.proto
|
||||||
|
|
||||||
|
package issue411
|
||||||
|
|
||||||
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
|
import fmt "fmt"
|
||||||
|
import math "math"
|
||||||
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
|
type Span struct {
|
||||||
|
TraceID TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=TraceID" json:"trace_id"`
|
||||||
|
SpanID SpanID `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3,customtype=SpanID" json:"span_id"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Span) Reset() { *m = Span{} }
|
||||||
|
func (m *Span) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Span) ProtoMessage() {}
|
||||||
|
func (*Span) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_issue411_3de9ea40a93d370b, []int{0}
|
||||||
|
}
|
||||||
|
func (m *Span) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Span.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Span) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Span.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *Span) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Span.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *Span) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Span.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Span) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Span.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Span proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*Span)(nil), "issue411.Span")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("issue411.proto", fileDescriptor_issue411_3de9ea40a93d370b) }
|
||||||
|
|
||||||
|
var fileDescriptor_issue411_3de9ea40a93d370b = []byte{
|
||||||
|
// 158 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0x2c, 0x2e, 0x2e,
|
||||||
|
0x4d, 0x35, 0x31, 0x34, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x80, 0xf1, 0xa5, 0x74,
|
||||||
|
0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xd3, 0xf3, 0xd3, 0xf3, 0xf5,
|
||||||
|
0xc1, 0x0a, 0x92, 0x4a, 0xd3, 0xc0, 0x3c, 0x30, 0x07, 0xcc, 0x82, 0x68, 0x54, 0x2a, 0xe0, 0x62,
|
||||||
|
0x09, 0x2e, 0x48, 0xcc, 0x13, 0x32, 0xe5, 0xe2, 0x28, 0x29, 0x4a, 0x4c, 0x4e, 0x8d, 0xcf, 0x4c,
|
||||||
|
0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x71, 0x92, 0x3a, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79,
|
||||||
|
0xf6, 0x10, 0x90, 0xb8, 0xa7, 0xcb, 0x23, 0x04, 0x33, 0x88, 0x1d, 0xac, 0xd6, 0x33, 0x45, 0xc8,
|
||||||
|
0x90, 0x8b, 0xbd, 0xb8, 0x20, 0x31, 0x0f, 0xa4, 0x8b, 0x09, 0xac, 0x4b, 0x02, 0xaa, 0x8b, 0x0d,
|
||||||
|
0x64, 0x2a, 0x58, 0x13, 0x94, 0x15, 0xc4, 0x06, 0x52, 0xe8, 0x99, 0x92, 0xc4, 0x06, 0xb6, 0xd8,
|
||||||
|
0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xd9, 0x68, 0x60, 0x2b, 0xc3, 0x00, 0x00, 0x00,
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
// Go support for Protocol Buffers - Google's data interchange format
|
||||||
|
//
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// https://github.com/golang/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package issue411;
|
||||||
|
|
||||||
|
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
|
||||||
|
|
||||||
|
message Span {
|
||||||
|
bytes trace_id = 1 [
|
||||||
|
(gogoproto.nullable) = false,
|
||||||
|
(gogoproto.customtype) = "TraceID",
|
||||||
|
(gogoproto.customname) = "TraceID"
|
||||||
|
];
|
||||||
|
bytes span_id = 2 [
|
||||||
|
(gogoproto.nullable) = false,
|
||||||
|
(gogoproto.customtype) = "SpanID",
|
||||||
|
(gogoproto.customname) = "SpanID"
|
||||||
|
];
|
||||||
|
}
|
||||||
+2919
-1354
File diff suppressed because it is too large
Load Diff
+4
@@ -47,6 +47,10 @@ func PutLittleEndianUint64(b []byte, offset int, v uint64) {
|
|||||||
|
|
||||||
type Uuid []byte
|
type Uuid []byte
|
||||||
|
|
||||||
|
func (uuid Uuid) Bytes() []byte {
|
||||||
|
return uuid
|
||||||
|
}
|
||||||
|
|
||||||
func (uuid Uuid) Marshal() ([]byte, error) {
|
func (uuid Uuid) Marshal() ([]byte, error) {
|
||||||
if len(uuid) == 0 {
|
if len(uuid) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user