Skip to content

Commit

Permalink
Integrate internal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TeBoring committed Oct 10, 2016
1 parent 0977514 commit a66697e
Show file tree
Hide file tree
Showing 19 changed files with 348 additions and 74 deletions.
1 change: 0 additions & 1 deletion google/protobuf/any.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ option go_package = "github.com/golang/protobuf/ptypes/any";
option java_package = "com.google.protobuf";
option java_outer_classname = "AnyProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB";

// `Any` contains an arbitrary serialized protocol buffer message along with a
Expand Down
1 change: 0 additions & 1 deletion google/protobuf/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option java_package = "com.google.protobuf";
option java_outer_classname = "ApiProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB";

// Api is a light-weight descriptor for a protocol buffer service.
Expand Down
25 changes: 9 additions & 16 deletions google/protobuf/descriptor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ option java_package = "com.google.protobuf";
option java_outer_classname = "DescriptorProtos";
option csharp_namespace = "Google.Protobuf.Reflection";
option objc_class_prefix = "GPB";
option java_generate_equals_and_hash = true;

// descriptor.proto must be optimized for speed because reflection-based
// algorithms don't work during bootstrapping.
Expand Down Expand Up @@ -306,19 +305,10 @@ message FileOptions {
// top-level extensions defined in the file.
optional bool java_multiple_files = 10 [default=false];

// If set true, then the Java code generator will generate equals() and
// hashCode() methods for all messages defined in the .proto file.
// This increases generated code size, potentially substantially for large
// protos, which may harm a memory-constrained application.
// - In the full runtime this is a speed optimization, as the
// AbstractMessage base class includes reflection-based implementations of
// these methods.
// - In the lite runtime, setting this option changes the semantics of
// equals() and hashCode() to more closely match those of the full runtime;
// the generated methods compute their results based on field values rather
// than object identity. (Implementations should not assume that hashcodes
// will be consistent across runtimes or versions of the protocol compiler.)
optional bool java_generate_equals_and_hash = 20 [default=false];
// BEGIN PROTOBUF-OPENSOURCE
// // This option does nothing.
// optional bool java_generate_equals_and_hash = 20 [deprecated=true];
// END PROTOBUF-OPENSOURCE

// If set true, then the Java2 code generator will generate code that
// throws an exception whenever an attempt is made to assign a non-UTF-8
Expand Down Expand Up @@ -448,6 +438,8 @@ message MessageOptions {

// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;

reserved 8; // javalite_serializable
}

message FieldOptions {
Expand All @@ -471,7 +463,6 @@ message FieldOptions {
// false will avoid using packed encoding.
optional bool packed = 2;


// The jstype option determines the JavaScript type used for values of the
// field. The option is permitted only for 64 bit integral and fixed types
// (int64, uint64, sint64, fixed64, sfixed64). By default these types are
Expand Down Expand Up @@ -512,7 +503,7 @@ message FieldOptions {
//
//
// Note that implementations may choose not to check required fields within
// a lazy sub-message. That is, calling IsInitialized() on the outher message
// a lazy sub-message. That is, calling IsInitialized() on the outer message
// may return true even if the inner message has missing required fields.
// This is necessary because otherwise the inner message would have to be
// parsed in order to perform the check, defeating the purpose of lazy
Expand All @@ -538,6 +529,8 @@ message FieldOptions {

// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;

reserved 4; // removed jtype
}

message OneofOptions {
Expand Down
8 changes: 7 additions & 1 deletion google/protobuf/duration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ syntax = "proto3";
package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "github.com/golang/protobuf/ptypes/duration";
option java_package = "com.google.protobuf";
option java_outer_classname = "DurationProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB";

// A Duration represents a signed, fixed-length span of time represented
Expand Down Expand Up @@ -81,6 +81,12 @@ option objc_class_prefix = "GPB";
// end.nanos -= 1000000000;
// }
//
// Example 3: Compute Duration from datetime.timedelta in Python.
//
// td = datetime.timedelta(days=3, minutes=10)
// duration = Duration()
// duration.FromTimedelta(td)
//
//
message Duration {

Expand Down
1 change: 0 additions & 1 deletion google/protobuf/empty.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ option go_package = "github.com/golang/protobuf/ptypes/empty";
option java_package = "com.google.protobuf";
option java_outer_classname = "EmptyProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB";
option cc_enable_arenas = true;

Expand Down
7 changes: 3 additions & 4 deletions google/protobuf/field_mask.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ option java_package = "com.google.protobuf";
option java_outer_classname = "FieldMaskProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option java_generate_equals_and_hash = true;

// `FieldMask` represents a set of symbolic field paths, for example:
//
Expand Down Expand Up @@ -82,7 +81,7 @@ option java_generate_equals_and_hash = true;
// }
//
// A repeated field is not allowed except at the last position of a
// field mask.
// paths string.
//
// If a FieldMask object is not present in a get operation, the
// operation applies to all fields (as if a FieldMask of all fields
Expand All @@ -109,8 +108,8 @@ option java_generate_equals_and_hash = true;
//
// 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.
// 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
Expand Down
1 change: 0 additions & 1 deletion google/protobuf/source_context.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option java_package = "com.google.protobuf";
option java_outer_classname = "SourceContextProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB";

// `SourceContext` represents information about the source of a
Expand Down
2 changes: 1 addition & 1 deletion google/protobuf/struct.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ syntax = "proto3";
package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "github.com/golang/protobuf/ptypes/struct;structpb";
option java_package = "com.google.protobuf";
option java_outer_classname = "StructProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB";


Expand Down
9 changes: 3 additions & 6 deletions google/protobuf/timestamp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ option go_package = "github.com/golang/protobuf/ptypes/timestamp";
option java_package = "com.google.protobuf";
option java_outer_classname = "TimestampProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB";

// A Timestamp represents a point in time independent of any time zone
Expand Down Expand Up @@ -90,16 +89,14 @@ option objc_class_prefix = "GPB";
//
// Example 5: Compute Timestamp from current time in Python.
//
// now = time.time()
// seconds = int(now)
// nanos = int((now - seconds) * 10**9)
// timestamp = Timestamp(seconds=seconds, nanos=nanos)
// timestamp = Timestamp()
// timestamp.GetCurrentTime()
//
//
message Timestamp {

// Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to
// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive.
int64 seconds = 1;

Expand Down
2 changes: 1 addition & 1 deletion google/protobuf/type.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ import "google/protobuf/any.proto";
import "google/protobuf/source_context.proto";

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf";
option java_outer_classname = "TypeProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB";

// A protocol buffer message type.
Expand Down
8 changes: 8 additions & 0 deletions google/protobuf/unittest.proto
Original file line number Diff line number Diff line change
Expand Up @@ -878,3 +878,11 @@ service TestService {
message BarRequest {}
message BarResponse {}

message TestJsonName {
optional int32 field_name1 = 1;
optional int32 fieldName2 = 2;
optional int32 FieldName3 = 3;
optional int32 _field_name4 = 4;
optional int32 FIELD_NAME5 = 5;
optional int32 field_name6 = 6 [json_name = "@type"];
}
69 changes: 62 additions & 7 deletions google/protobuf/util/internal/testdata/anys.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,75 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Proto to test Proto3 Any serialization.
syntax = "proto3";

package google.protobuf.testing.anys;
option java_package = "com.google.protobuf.testing.anys";
package google.protobuf.testing;

import "google/protobuf/any.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/wrappers.proto";

// Top-level test cases proto used by MarshallingTest. See description
// at the top of the class MarshallingTest for details on how to write
// test cases.
message AnyTestCases {
AnyWrapper empty_any = 1;
AnyWrapper type_only_any = 2;
AnyWrapper wrapper_any = 3;
AnyWrapper any_with_timestamp_value = 4;
AnyWrapper any_with_duration_value = 5;
AnyWrapper any_with_struct_value = 6;
AnyWrapper recursive_any = 7;
AnyWrapper any_with_message_value = 8;
AnyWrapper any_with_nested_message = 9;
AnyWrapper any_with_message_with_wrapper_type = 10;
AnyWrapper any_with_message_with_timestamp = 11;
AnyWrapper any_with_message_containing_map = 12;
AnyWrapper any_with_message_containing_struct = 13;
AnyWrapper any_with_message_containing_repeated_message = 14;
AnyWrapper recursive_any_with_type_field_at_end = 15;

google.protobuf.Any top_level_any = 50;
google.protobuf.Any top_level_any_with_type_field_at_end = 51;
}

message AnyWrapper {
google.protobuf.Any any = 1;
}

// Hack to make sure the types we put into the any are included in the types.
// Real solution is to add these types to the service config.
message Imports {
google.protobuf.DoubleValue dbl = 1;
google.protobuf.Struct struct = 2;
google.protobuf.Timestamp timestamp = 3;
google.protobuf.Duration duration = 4;
google.protobuf.Int32Value i32 = 5;
Data data = 100;
}

message Data {
int32 attr = 1;
string str = 2;
repeated string msgs = 3;
Data nested_data = 4;
google.protobuf.Int32Value int_wrapper = 5;
google.protobuf.Timestamp time = 6;
map<string, string> map_data = 7;
google.protobuf.Struct struct_data = 8;
repeated Data repeated_data = 9;
}

service AnyTestService {
rpc Call(AnyTestCases) returns (AnyTestCases);
rpc Call1(Imports) returns (Imports);
}

message AnyIn {
string something = 1;
google.protobuf.Any any = 2;
}

message AnyOut {
Expand All @@ -47,7 +106,3 @@ message AnyOut {
message AnyM {
string foo = 1;
}

service TestService {
rpc Call(AnyIn) returns (AnyOut);
}
5 changes: 5 additions & 0 deletions google/protobuf/util/internal/testdata/books.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
// Author: [email protected] (Sven Mawson)
//
// Sample protos for testing.

// Some of the older enums don't use CAPITALS_WITH_UNDERSCORES for testing.
// LINT: LEGACY_NAMES

syntax = "proto2";

package google.protobuf.testing;
Expand Down Expand Up @@ -60,6 +64,7 @@ message Book {
FICTION = 1;
KIDS = 2;
ACTION_AND_ADVENTURE = 3;
arts_and_photography = 4;
}
optional Type type = 11;

Expand Down
Loading

0 comments on commit a66697e

Please sign in to comment.