Skip to content

Commit

Permalink
Upstream internal Google protobuf changes
Browse files Browse the repository at this point in the history
Major changes:
 * New table-driven optimization for marshal, unmarshal, and merge
 * Unknown field preservation for Proto3
 * Generated source-file annotation for Kythe
 * Various bug fixes
  • Loading branch information
dsnet committed Nov 8, 2017
1 parent 1643683 commit 8cc9e46
Show file tree
Hide file tree
Showing 56 changed files with 15,457 additions and 4,069 deletions.
24 changes: 14 additions & 10 deletions _conformance/conformance.go
Expand Up @@ -95,19 +95,18 @@ var jsonMarshaler = jsonpb.Marshaler{

func handle(req *pb.ConformanceRequest) *pb.ConformanceResponse {
var err error
var msg pb.TestAllTypes
var msg pb.TestAllTypesProto3
var msg1 pb.TestAllTypesProto2
var isProto3 bool = bool(req.MessageType == "protobuf_test_messages.proto3.TestAllTypesProto3")
switch p := req.Payload.(type) {
case *pb.ConformanceRequest_ProtobufPayload:
err = proto.Unmarshal(p.ProtobufPayload, &msg)
if isProto3 {
err = proto.Unmarshal(p.ProtobufPayload, &msg)
} else {
err = proto.Unmarshal(p.ProtobufPayload, &msg1)
}
case *pb.ConformanceRequest_JsonPayload:
err = jsonpb.UnmarshalString(p.JsonPayload, &msg)
if err != nil && err.Error() == "unmarshaling Any not supported yet" {
return &pb.ConformanceResponse{
Result: &pb.ConformanceResponse_Skipped{
Skipped: err.Error(),
},
}
}
default:
return &pb.ConformanceResponse{
Result: &pb.ConformanceResponse_RuntimeError{
Expand All @@ -124,7 +123,12 @@ func handle(req *pb.ConformanceRequest) *pb.ConformanceResponse {
}
switch req.RequestedOutputFormat {
case pb.WireFormat_PROTOBUF:
p, err := proto.Marshal(&msg)
var p []byte
if isProto3 {
p, err = proto.Marshal(&msg)
} else {
p, err = proto.Marshal(&msg1)
}
if err != nil {
return &pb.ConformanceResponse{
Result: &pb.ConformanceResponse_SerializeError{
Expand Down
496 changes: 307 additions & 189 deletions _conformance/conformance_proto/conformance.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion descriptor/descriptor_test.go
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/golang/protobuf/descriptor"
tpb "github.com/golang/protobuf/proto/testdata"
tpb "github.com/golang/protobuf/proto/test_proto"
protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor"
)

Expand Down
139 changes: 125 additions & 14 deletions jsonpb/jsonpb_test_proto/more_test_objects.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8cc9e46

Please sign in to comment.