Skip to content

Commit

Permalink
Update upstream protos and regenerate (#792)
Browse files Browse the repository at this point in the history
* Update the protobuf from protocolbuffers/protobuf.  Using commit 37b5617d42d02d225faa1d64565696f5bfb8e61a
* Regenerate the sources from the update .proto files.
* Update the conformance test for the new enum category.

Yes, it changed the values when inserting the new one; an breaking proto
change...
  • Loading branch information
thomasvl authored Sep 6, 2018
1 parent 659025f commit 53cd963
Show file tree
Hide file tree
Showing 14 changed files with 409 additions and 139 deletions.
13 changes: 7 additions & 6 deletions Protos/conformance/conformance.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ enum WireFormat {
}

enum TestCategory {
BINARY_TEST = 0; // Test binary wire format.
JSON_TEST = 1; // Test json wire format.
UNSPECIFIED_TEST = 0;
BINARY_TEST = 1; // Test binary wire format.
JSON_TEST = 2; // Test json wire format.
// Similar to JSON_TEST. However, during parsing json, testee should ignore
// unknown fields. This feature is optional. Each implementation can descide
// whether to support it. See
// https://developers.google.com/protocol-buffers/docs/proto3#json_options
// for more detail.
JSON_IGNORE_UNKNOWN_PARSING_TEST = 2;
JSON_IGNORE_UNKNOWN_PARSING_TEST = 3;
}

// Represents a single test case's input. The testee should:
Expand Down Expand Up @@ -94,9 +95,9 @@ message ConformanceRequest {
// protobuf_test_messages.proto2.TestAllTypesProto2.
string message_type = 4;

// Each test is given a specific test category. Some category may need spedific
// support in testee programs. Refer to the defintion of TestCategory for
// more information.
// Each test is given a specific test category. Some category may need
// spedific support in testee programs. Refer to the defintion of TestCategory
// for more information.
TestCategory test_category = 5;
}

Expand Down
45 changes: 19 additions & 26 deletions Protos/google/protobuf/field_mask.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ option java_outer_classname = "FieldMaskProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask";
option cc_enable_arenas = true;

// `FieldMask` represents a set of symbolic field paths, for example:
//
Expand Down Expand Up @@ -107,57 +108,49 @@ option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask";
// describe the updated values, the API ignores the values of all
// fields not covered by the mask.
//
// If a repeated field is specified for an update operation, the existing
// repeated values in the target resource will be overwritten by the new values.
// Note that a repeated field is only allowed in the last position of a `paths`
// string.
// If a repeated field is specified for an update operation, new values will
// be appended to the existing repeated field in the target resource. Note that
// a repeated field is only allowed in the last position of a `paths` string.
//
// If a sub-message is specified in the last position of the field mask for an
// update operation, then the existing sub-message in the target resource is
// overwritten. Given the target message:
// update operation, then new value will be merged into the existing sub-message
// in the target resource.
//
// For example, given the target message:
//
// f {
// b {
// d : 1
// x : 2
// d: 1
// x: 2
// }
// c : 1
// c: [1]
// }
//
// And an update message:
//
// f {
// b {
// d : 10
// d: 10
// }
// c: [2]
// }
//
// then if the field mask is:
//
// paths: "f.b"
// paths: ["f.b", "f.c"]
//
// then the result will be:
//
// f {
// b {
// d : 10
// d: 10
// x: 2
// }
// c : 1
// c: [1, 2]
// }
//
// However, if the update mask was:
//
// paths: "f.b.d"
//
// then the result would be:
//
// f {
// b {
// d : 10
// x : 2
// }
// c : 1
// }
// An implementation may provide options to override this default behavior for
// repeated and message fields.
//
// In order to reset a field's value to the default, the field must
// be in the mask and set to the default value in the provided resource.
Expand Down
14 changes: 14 additions & 0 deletions Protos/google/protobuf/unittest_proto3.proto
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,17 @@ enum ForeignEnum {
message TestEmptyMessage {
}

// Same layout as TestOneof2 in unittest.proto to test unknown enum value
// parsing behavior in oneof.
message TestOneof2 {
oneof foo {
NestedEnum foo_enum = 6;
}

enum NestedEnum {
UNKNOWN = 0;
FOO = 1;
BAR = 2;
BAZ = 3;
}
}
5 changes: 5 additions & 0 deletions Protos/google/protobuf/wrappers.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
// for embedding primitives in the `google.protobuf.Any` type and for places
// where we need to distinguish between the absence of a primitive
// typed field and its default value.
//
// These wrappers have no meaningful use within repeated fields as they lack
// the ability to detect presence on individual elements.
// These wrappers have no meaningful use within a map or a oneof since individual
// entries of a map or fields of a oneof can already detect presence.

syntax = "proto3";

Expand Down
41 changes: 23 additions & 18 deletions Reference/conformance/conformance.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,39 +95,42 @@ extension Conformance_WireFormat: CaseIterable {

enum Conformance_TestCategory: SwiftProtobuf.Enum {
typealias RawValue = Int
case unspecifiedTest // = 0

/// Test binary wire format.
case binaryTest // = 0
case binaryTest // = 1

/// Test json wire format.
case jsonTest // = 1
case jsonTest // = 2

/// Similar to JSON_TEST. However, during parsing json, testee should ignore
/// unknown fields. This feature is optional. Each implementation can descide
/// whether to support it. See
/// https://developers.google.com/protocol-buffers/docs/proto3#json_options
/// for more detail.
case jsonIgnoreUnknownParsingTest // = 2
case jsonIgnoreUnknownParsingTest // = 3
case UNRECOGNIZED(Int)

init() {
self = .binaryTest
self = .unspecifiedTest
}

init?(rawValue: Int) {
switch rawValue {
case 0: self = .binaryTest
case 1: self = .jsonTest
case 2: self = .jsonIgnoreUnknownParsingTest
case 0: self = .unspecifiedTest
case 1: self = .binaryTest
case 2: self = .jsonTest
case 3: self = .jsonIgnoreUnknownParsingTest
default: self = .UNRECOGNIZED(rawValue)
}
}

var rawValue: Int {
switch self {
case .binaryTest: return 0
case .jsonTest: return 1
case .jsonIgnoreUnknownParsingTest: return 2
case .unspecifiedTest: return 0
case .binaryTest: return 1
case .jsonTest: return 2
case .jsonIgnoreUnknownParsingTest: return 3
case .UNRECOGNIZED(let i): return i
}
}
Expand All @@ -139,6 +142,7 @@ enum Conformance_TestCategory: SwiftProtobuf.Enum {
extension Conformance_TestCategory: CaseIterable {
// The compiler won't synthesize support with the UNRECOGNIZED case.
static var allCases: [Conformance_TestCategory] = [
.unspecifiedTest,
.binaryTest,
.jsonTest,
.jsonIgnoreUnknownParsingTest,
Expand Down Expand Up @@ -190,10 +194,10 @@ struct Conformance_ConformanceRequest {
/// protobuf_test_messages.proto2.TestAllTypesProto2.
var messageType: String = String()

/// Each test is given a specific test category. Some category may need spedific
/// support in testee programs. Refer to the defintion of TestCategory for
/// more information.
var testCategory: Conformance_TestCategory = .binaryTest
/// Each test is given a specific test category. Some category may need
/// spedific support in testee programs. Refer to the defintion of TestCategory
/// for more information.
var testCategory: Conformance_TestCategory = .unspecifiedTest

var unknownFields = SwiftProtobuf.UnknownStorage()

Expand Down Expand Up @@ -354,9 +358,10 @@ extension Conformance_WireFormat: SwiftProtobuf._ProtoNameProviding {

extension Conformance_TestCategory: SwiftProtobuf._ProtoNameProviding {
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
0: .same(proto: "BINARY_TEST"),
1: .same(proto: "JSON_TEST"),
2: .same(proto: "JSON_IGNORE_UNKNOWN_PARSING_TEST"),
0: .same(proto: "UNSPECIFIED_TEST"),
1: .same(proto: "BINARY_TEST"),
2: .same(proto: "JSON_TEST"),
3: .same(proto: "JSON_IGNORE_UNKNOWN_PARSING_TEST"),
]
}

Expand Down Expand Up @@ -405,7 +410,7 @@ extension Conformance_ConformanceRequest: SwiftProtobuf.Message, SwiftProtobuf._
if !self.messageType.isEmpty {
try visitor.visitSingularStringField(value: self.messageType, fieldNumber: 4)
}
if self.testCategory != .binaryTest {
if self.testCategory != .unspecifiedTest {
try visitor.visitSingularEnumField(value: self.testCategory, fieldNumber: 5)
}
try unknownFields.traverse(visitor: &visitor)
Expand Down
44 changes: 18 additions & 26 deletions Reference/google/protobuf/field_mask.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,57 +116,49 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP
/// describe the updated values, the API ignores the values of all
/// fields not covered by the mask.
///
/// If a repeated field is specified for an update operation, the existing
/// repeated values in the target resource will be overwritten by the new values.
/// Note that a repeated field is only allowed in the last position of a `paths`
/// string.
/// If a repeated field is specified for an update operation, new values will
/// be appended to the existing repeated field in the target resource. Note that
/// a repeated field is only allowed in the last position of a `paths` string.
///
/// If a sub-message is specified in the last position of the field mask for an
/// update operation, then the existing sub-message in the target resource is
/// overwritten. Given the target message:
/// update operation, then new value will be merged into the existing sub-message
/// in the target resource.
///
/// For example, given the target message:
///
/// f {
/// b {
/// d : 1
/// x : 2
/// d: 1
/// x: 2
/// }
/// c : 1
/// c: [1]
/// }
///
/// And an update message:
///
/// f {
/// b {
/// d : 10
/// d: 10
/// }
/// c: [2]
/// }
///
/// then if the field mask is:
///
/// paths: "f.b"
/// paths: ["f.b", "f.c"]
///
/// then the result will be:
///
/// f {
/// b {
/// d : 10
/// d: 10
/// x: 2
/// }
/// c : 1
/// c: [1, 2]
/// }
///
/// However, if the update mask was:
///
/// paths: "f.b.d"
///
/// then the result would be:
///
/// f {
/// b {
/// d : 10
/// x : 2
/// }
/// c : 1
/// }
/// An implementation may provide options to override this default behavior for
/// repeated and message fields.
///
/// In order to reset a field's value to the default, the field must
/// be in the mask and set to the default value in the provided resource.
Expand Down
Loading

0 comments on commit 53cd963

Please sign in to comment.