From 83b07385e53dad2f6a2ea30902499c2921773ac5 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Wed, 29 Jun 2016 15:23:27 -0700 Subject: [PATCH] Integrated internal changes from Google This includes all internal changes from around May 20 to now. --- google/protobuf/any.proto | 16 ++++-- google/protobuf/descriptor.proto | 9 ++++ google/protobuf/field_mask.proto | 52 +++++++++++++++++++ google/protobuf/source_context.proto | 2 +- google/protobuf/unittest.proto | 1 + google/protobuf/unittest_custom_options.proto | 9 ++++ google/protobuf/util/json_format_proto3.proto | 5 ++ 7 files changed, 90 insertions(+), 4 deletions(-) diff --git a/google/protobuf/any.proto b/google/protobuf/any.proto index 45db6ede352bb..81dcf46ccfd22 100644 --- a/google/protobuf/any.proto +++ b/google/protobuf/any.proto @@ -65,6 +65,16 @@ option objc_class_prefix = "GPB"; // foo = any.unpack(Foo.class); // } // +// Example 3: Pack and unpack a message in Python. +// +// foo = Foo(...) +// any = Any() +// any.Pack(foo) +// ... +// if any.Is(Foo.DESCRIPTOR): +// any.Unpack(foo) +// ... +// // The pack methods provided by protobuf library will by default use // 'type.googleapis.com/full.type.name' as the type URL and the unpack // methods only use the fully qualified type name after the last '/' @@ -104,10 +114,10 @@ message Any { // A URL/resource name whose content describes the type of the // serialized protocol buffer message. // - // For URLs which use the schema `http`, `https`, or no schema, the + // For URLs which use the scheme `http`, `https`, or no scheme, the // following restrictions and interpretations apply: // - // * If no schema is provided, `https` is assumed. + // * If no scheme is provided, `https` is assumed. // * The last segment of the URL's path must represent the fully // qualified name of the type (as in `path/google.protobuf.Duration`). // The name should be in a canonical form (e.g., leading "." is @@ -120,7 +130,7 @@ message Any { // on changes to types. (Use versioned type names to manage // breaking changes.) // - // Schemas other than `http`, `https` (or the empty schema) might be + // Schemes other than `http`, `https` (or the empty scheme) might be // used with implementation specific semantics. // string type_url = 1; diff --git a/google/protobuf/descriptor.proto b/google/protobuf/descriptor.proto index 08b155548beb9..da853dbc0ea84 100644 --- a/google/protobuf/descriptor.proto +++ b/google/protobuf/descriptor.proto @@ -202,6 +202,7 @@ message FieldDescriptorProto { // Describes a oneof. message OneofDescriptorProto { optional string name = 1; + optional OneofOptions options = 2; } // Describes an enum type. @@ -538,6 +539,14 @@ message FieldOptions { extensions 1000 to max; } +message OneofOptions { + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + message EnumOptions { // Set this option to true to allow mapping different tag names to the same diff --git a/google/protobuf/field_mask.proto b/google/protobuf/field_mask.proto index 6af6dbe898059..c51de09a832c2 100644 --- a/google/protobuf/field_mask.proto +++ b/google/protobuf/field_mask.proto @@ -107,6 +107,58 @@ option java_generate_equals_and_hash = true; // 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 field +// mask. +// +// 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: +// +// f { +// b { +// d : 1 +// x : 2 +// } +// c : 1 +// } +// +// And an update message: +// +// f { +// b { +// d : 10 +// } +// } +// +// then if the field mask is: +// +// paths: "f.b" +// +// then the result will be: +// +// f { +// b { +// d : 10 +// } +// c : 1 +// } +// +// However, if the update mask was: +// +// paths: "f.b.d" +// +// then the result would be: +// +// f { +// b { +// d : 10 +// x : 2 +// } +// c : 1 +// } +// // 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. // Hence, in order to reset all fields of a resource, provide a default diff --git a/google/protobuf/source_context.proto b/google/protobuf/source_context.proto index d76252ca841ed..a2c08e2b57d36 100644 --- a/google/protobuf/source_context.proto +++ b/google/protobuf/source_context.proto @@ -43,6 +43,6 @@ option objc_class_prefix = "GPB"; // protobuf element, like the file in which it is defined. message SourceContext { // The path-qualified name of the .proto file that contained the associated - // protobuf element. For example: `"google/protobuf/source.proto"`. + // protobuf element. For example: `"google/protobuf/source_context.proto"`. string file_name = 1; } diff --git a/google/protobuf/unittest.proto b/google/protobuf/unittest.proto index da56ae0a2449c..d5206d2463b8c 100644 --- a/google/protobuf/unittest.proto +++ b/google/protobuf/unittest.proto @@ -195,6 +195,7 @@ message TestDeprecatedFields { // that. message ForeignMessage { optional int32 c = 1; + optional int32 d = 2; } enum ForeignEnum { diff --git a/google/protobuf/unittest_custom_options.proto b/google/protobuf/unittest_custom_options.proto index 4cc0e362c56c7..218447e9aa5d7 100644 --- a/google/protobuf/unittest_custom_options.proto +++ b/google/protobuf/unittest_custom_options.proto @@ -69,6 +69,10 @@ extend google.protobuf.FieldOptions { optional int32 field_opt2 = 7753913 [default=42]; } +extend google.protobuf.OneofOptions { + optional int32 oneof_opt1 = 7740111; +} + extend google.protobuf.EnumOptions { optional sfixed32 enum_opt1 = 7753576; } @@ -100,6 +104,11 @@ message TestMessageWithCustomOptions { optional string field1 = 1 [ctype=CORD, (field_opt1)=8765432109]; + oneof AnOneof { + option (oneof_opt1) = -99; + int32 oneof_field = 2; + } + enum AnEnum { option (enum_opt1) = -789; diff --git a/google/protobuf/util/json_format_proto3.proto b/google/protobuf/util/json_format_proto3.proto index a1e24c1831823..3835b30eb951f 100644 --- a/google/protobuf/util/json_format_proto3.proto +++ b/google/protobuf/util/json_format_proto3.proto @@ -39,6 +39,7 @@ import "google/protobuf/wrappers.proto"; import "google/protobuf/struct.proto"; import "google/protobuf/any.proto"; import "google/protobuf/field_mask.proto"; +import "google/protobuf/unittest.proto"; enum EnumType { FOO = 0; @@ -174,3 +175,7 @@ message TestBoolValue { message TestCustomJsonName { int32 value = 1 [json_name = "@value"]; } + +message TestExtensions { + .protobuf_unittest.TestAllExtensions extensions = 1; +}