protobuf-cucumber 3.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rubocop.yml +70 -0
- data/.rubocop_todo.yml +145 -0
- data/.travis.yml +40 -0
- data/.yardopts +5 -0
- data/CHANGES.md +344 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +64 -0
- data/bin/protoc-gen-ruby +22 -0
- data/bin/rpc_server +5 -0
- data/install-protobuf.sh +28 -0
- data/lib/protobuf.rb +129 -0
- data/lib/protobuf/cli.rb +257 -0
- data/lib/protobuf/code_generator.rb +120 -0
- data/lib/protobuf/decoder.rb +28 -0
- data/lib/protobuf/deprecation.rb +117 -0
- data/lib/protobuf/descriptors.rb +3 -0
- data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +62 -0
- data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +301 -0
- data/lib/protobuf/encoder.rb +11 -0
- data/lib/protobuf/enum.rb +365 -0
- data/lib/protobuf/exceptions.rb +9 -0
- data/lib/protobuf/field.rb +74 -0
- data/lib/protobuf/field/base_field.rb +380 -0
- data/lib/protobuf/field/base_field_object_definitions.rb +504 -0
- data/lib/protobuf/field/bool_field.rb +64 -0
- data/lib/protobuf/field/bytes_field.rb +78 -0
- data/lib/protobuf/field/double_field.rb +25 -0
- data/lib/protobuf/field/enum_field.rb +61 -0
- data/lib/protobuf/field/field_array.rb +104 -0
- data/lib/protobuf/field/field_hash.rb +122 -0
- data/lib/protobuf/field/fixed32_field.rb +25 -0
- data/lib/protobuf/field/fixed64_field.rb +28 -0
- data/lib/protobuf/field/float_field.rb +43 -0
- data/lib/protobuf/field/int32_field.rb +21 -0
- data/lib/protobuf/field/int64_field.rb +34 -0
- data/lib/protobuf/field/integer_field.rb +23 -0
- data/lib/protobuf/field/message_field.rb +51 -0
- data/lib/protobuf/field/sfixed32_field.rb +27 -0
- data/lib/protobuf/field/sfixed64_field.rb +28 -0
- data/lib/protobuf/field/signed_integer_field.rb +29 -0
- data/lib/protobuf/field/sint32_field.rb +21 -0
- data/lib/protobuf/field/sint64_field.rb +21 -0
- data/lib/protobuf/field/string_field.rb +51 -0
- data/lib/protobuf/field/uint32_field.rb +21 -0
- data/lib/protobuf/field/uint64_field.rb +21 -0
- data/lib/protobuf/field/varint_field.rb +77 -0
- data/lib/protobuf/generators/base.rb +85 -0
- data/lib/protobuf/generators/enum_generator.rb +39 -0
- data/lib/protobuf/generators/extension_generator.rb +27 -0
- data/lib/protobuf/generators/field_generator.rb +193 -0
- data/lib/protobuf/generators/file_generator.rb +262 -0
- data/lib/protobuf/generators/group_generator.rb +122 -0
- data/lib/protobuf/generators/message_generator.rb +104 -0
- data/lib/protobuf/generators/option_generator.rb +17 -0
- data/lib/protobuf/generators/printable.rb +160 -0
- data/lib/protobuf/generators/service_generator.rb +50 -0
- data/lib/protobuf/lifecycle.rb +33 -0
- data/lib/protobuf/logging.rb +39 -0
- data/lib/protobuf/message.rb +260 -0
- data/lib/protobuf/message/fields.rb +233 -0
- data/lib/protobuf/message/serialization.rb +85 -0
- data/lib/protobuf/optionable.rb +70 -0
- data/lib/protobuf/rpc/buffer.rb +78 -0
- data/lib/protobuf/rpc/client.rb +140 -0
- data/lib/protobuf/rpc/connectors/base.rb +221 -0
- data/lib/protobuf/rpc/connectors/ping.rb +89 -0
- data/lib/protobuf/rpc/connectors/socket.rb +78 -0
- data/lib/protobuf/rpc/connectors/zmq.rb +319 -0
- data/lib/protobuf/rpc/dynamic_discovery.pb.rb +50 -0
- data/lib/protobuf/rpc/env.rb +60 -0
- data/lib/protobuf/rpc/error.rb +28 -0
- data/lib/protobuf/rpc/error/client_error.rb +31 -0
- data/lib/protobuf/rpc/error/server_error.rb +43 -0
- data/lib/protobuf/rpc/middleware.rb +25 -0
- data/lib/protobuf/rpc/middleware/exception_handler.rb +40 -0
- data/lib/protobuf/rpc/middleware/logger.rb +95 -0
- data/lib/protobuf/rpc/middleware/request_decoder.rb +79 -0
- data/lib/protobuf/rpc/middleware/response_encoder.rb +83 -0
- data/lib/protobuf/rpc/middleware/runner.rb +18 -0
- data/lib/protobuf/rpc/rpc.pb.rb +64 -0
- data/lib/protobuf/rpc/rpc_method.rb +16 -0
- data/lib/protobuf/rpc/server.rb +39 -0
- data/lib/protobuf/rpc/servers/socket/server.rb +121 -0
- data/lib/protobuf/rpc/servers/socket/worker.rb +56 -0
- data/lib/protobuf/rpc/servers/socket_runner.rb +46 -0
- data/lib/protobuf/rpc/servers/zmq/broker.rb +194 -0
- data/lib/protobuf/rpc/servers/zmq/server.rb +321 -0
- data/lib/protobuf/rpc/servers/zmq/util.rb +48 -0
- data/lib/protobuf/rpc/servers/zmq/worker.rb +105 -0
- data/lib/protobuf/rpc/servers/zmq_runner.rb +70 -0
- data/lib/protobuf/rpc/service.rb +172 -0
- data/lib/protobuf/rpc/service_directory.rb +261 -0
- data/lib/protobuf/rpc/service_dispatcher.rb +45 -0
- data/lib/protobuf/rpc/service_filters.rb +250 -0
- data/lib/protobuf/rpc/stat.rb +119 -0
- data/lib/protobuf/socket.rb +21 -0
- data/lib/protobuf/tasks.rb +1 -0
- data/lib/protobuf/tasks/compile.rake +80 -0
- data/lib/protobuf/varint.rb +20 -0
- data/lib/protobuf/varint_pure.rb +31 -0
- data/lib/protobuf/version.rb +3 -0
- data/lib/protobuf/wire_type.rb +10 -0
- data/lib/protobuf/zmq.rb +21 -0
- data/profile.html +5103 -0
- data/proto/dynamic_discovery.proto +44 -0
- data/proto/google/protobuf/compiler/plugin.proto +147 -0
- data/proto/google/protobuf/descriptor.proto +779 -0
- data/proto/rpc.proto +69 -0
- data/protobuf-cucumber.gemspec +57 -0
- data/spec/benchmark/tasks.rb +143 -0
- data/spec/bin/protoc-gen-ruby_spec.rb +23 -0
- data/spec/encoding/all_types_spec.rb +103 -0
- data/spec/encoding/extreme_values_spec.rb +0 -0
- data/spec/functional/class_inheritance_spec.rb +52 -0
- data/spec/functional/code_generator_spec.rb +58 -0
- data/spec/functional/socket_server_spec.rb +59 -0
- data/spec/functional/zmq_server_spec.rb +105 -0
- data/spec/lib/protobuf/cli_spec.rb +317 -0
- data/spec/lib/protobuf/code_generator_spec.rb +87 -0
- data/spec/lib/protobuf/enum_spec.rb +307 -0
- data/spec/lib/protobuf/field/bool_field_spec.rb +91 -0
- data/spec/lib/protobuf/field/double_field_spec.rb +9 -0
- data/spec/lib/protobuf/field/enum_field_spec.rb +44 -0
- data/spec/lib/protobuf/field/field_array_spec.rb +105 -0
- data/spec/lib/protobuf/field/field_hash_spec.rb +168 -0
- data/spec/lib/protobuf/field/fixed32_field_spec.rb +7 -0
- data/spec/lib/protobuf/field/fixed64_field_spec.rb +7 -0
- data/spec/lib/protobuf/field/float_field_spec.rb +90 -0
- data/spec/lib/protobuf/field/int32_field_spec.rb +120 -0
- data/spec/lib/protobuf/field/int64_field_spec.rb +7 -0
- data/spec/lib/protobuf/field/message_field_spec.rb +132 -0
- data/spec/lib/protobuf/field/sfixed32_field_spec.rb +9 -0
- data/spec/lib/protobuf/field/sfixed64_field_spec.rb +9 -0
- data/spec/lib/protobuf/field/sint32_field_spec.rb +9 -0
- data/spec/lib/protobuf/field/sint64_field_spec.rb +9 -0
- data/spec/lib/protobuf/field/string_field_spec.rb +79 -0
- data/spec/lib/protobuf/field/uint32_field_spec.rb +7 -0
- data/spec/lib/protobuf/field/uint64_field_spec.rb +7 -0
- data/spec/lib/protobuf/field_spec.rb +192 -0
- data/spec/lib/protobuf/generators/base_spec.rb +154 -0
- data/spec/lib/protobuf/generators/enum_generator_spec.rb +82 -0
- data/spec/lib/protobuf/generators/extension_generator_spec.rb +42 -0
- data/spec/lib/protobuf/generators/field_generator_spec.rb +197 -0
- data/spec/lib/protobuf/generators/file_generator_spec.rb +119 -0
- data/spec/lib/protobuf/generators/message_generator_spec.rb +0 -0
- data/spec/lib/protobuf/generators/service_generator_spec.rb +99 -0
- data/spec/lib/protobuf/lifecycle_spec.rb +94 -0
- data/spec/lib/protobuf/message_spec.rb +944 -0
- data/spec/lib/protobuf/optionable_spec.rb +265 -0
- data/spec/lib/protobuf/rpc/client_spec.rb +66 -0
- data/spec/lib/protobuf/rpc/connectors/base_spec.rb +226 -0
- data/spec/lib/protobuf/rpc/connectors/ping_spec.rb +69 -0
- data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +34 -0
- data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +110 -0
- data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +62 -0
- data/spec/lib/protobuf/rpc/middleware/logger_spec.rb +49 -0
- data/spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb +115 -0
- data/spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb +91 -0
- data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +38 -0
- data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +43 -0
- data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +55 -0
- data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +35 -0
- data/spec/lib/protobuf/rpc/service_directory_spec.rb +293 -0
- data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +35 -0
- data/spec/lib/protobuf/rpc/service_filters_spec.rb +517 -0
- data/spec/lib/protobuf/rpc/service_spec.rb +162 -0
- data/spec/lib/protobuf/rpc/stat_spec.rb +101 -0
- data/spec/lib/protobuf/varint_spec.rb +29 -0
- data/spec/lib/protobuf_spec.rb +105 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/support/all.rb +6 -0
- data/spec/support/packed_field.rb +23 -0
- data/spec/support/protos/all_types.data.bin +0 -0
- data/spec/support/protos/all_types.data.txt +119 -0
- data/spec/support/protos/enum.pb.rb +63 -0
- data/spec/support/protos/enum.proto +37 -0
- data/spec/support/protos/extreme_values.data.bin +0 -0
- data/spec/support/protos/google_unittest.bin +0 -0
- data/spec/support/protos/google_unittest.pb.rb +798 -0
- data/spec/support/protos/google_unittest.proto +884 -0
- data/spec/support/protos/google_unittest_custom_options.bin +0 -0
- data/spec/support/protos/google_unittest_custom_options.pb.rb +361 -0
- data/spec/support/protos/google_unittest_custom_options.proto +424 -0
- data/spec/support/protos/google_unittest_import.pb.rb +55 -0
- data/spec/support/protos/google_unittest_import.proto +73 -0
- data/spec/support/protos/google_unittest_import_public.pb.rb +31 -0
- data/spec/support/protos/google_unittest_import_public.proto +41 -0
- data/spec/support/protos/map-test.bin +157 -0
- data/spec/support/protos/map-test.pb.rb +85 -0
- data/spec/support/protos/map-test.proto +68 -0
- data/spec/support/protos/multi_field_extensions.pb.rb +59 -0
- data/spec/support/protos/multi_field_extensions.proto +35 -0
- data/spec/support/protos/resource.pb.rb +172 -0
- data/spec/support/protos/resource.proto +137 -0
- data/spec/support/resource_service.rb +23 -0
- data/spec/support/server.rb +65 -0
- data/spec/support/test_app_file.rb +2 -0
- data/varint_prof.rb +82 -0
- metadata +579 -0
@@ -0,0 +1,884 @@
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
2
|
+
// Copyright 2008 Google Inc. All rights reserved.
|
3
|
+
// https://developers.google.com/protocol-buffers/
|
4
|
+
//
|
5
|
+
// Redistribution and use in source and binary forms, with or without
|
6
|
+
// modification, are permitted provided that the following conditions are
|
7
|
+
// met:
|
8
|
+
//
|
9
|
+
// * Redistributions of source code must retain the above copyright
|
10
|
+
// notice, this list of conditions and the following disclaimer.
|
11
|
+
// * Redistributions in binary form must reproduce the above
|
12
|
+
// copyright notice, this list of conditions and the following disclaimer
|
13
|
+
// in the documentation and/or other materials provided with the
|
14
|
+
// distribution.
|
15
|
+
// * Neither the name of Google Inc. nor the names of its
|
16
|
+
// contributors may be used to endorse or promote products derived from
|
17
|
+
// this software without specific prior written permission.
|
18
|
+
//
|
19
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
// Author: kenton@google.com (Kenton Varda)
|
32
|
+
// Based on original Protocol Buffers design by
|
33
|
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
34
|
+
//
|
35
|
+
// A proto file we will use for unit testing.
|
36
|
+
|
37
|
+
syntax = "proto2";
|
38
|
+
|
39
|
+
// Some generic_services option(s) added automatically.
|
40
|
+
// See: http://go/proto2-generic-services-default
|
41
|
+
option cc_generic_services = true; // auto-added
|
42
|
+
option java_generic_services = true; // auto-added
|
43
|
+
option py_generic_services = true; // auto-added
|
44
|
+
option cc_enable_arenas = true;
|
45
|
+
|
46
|
+
import "protos/google_unittest_import.proto";
|
47
|
+
|
48
|
+
// We don't put this in a package within proto2 because we need to make sure
|
49
|
+
// that the generated code doesn't depend on being in the proto2 namespace.
|
50
|
+
// In test_util.h we do "using namespace unittest = protobuf_unittest".
|
51
|
+
package protobuf_unittest;
|
52
|
+
|
53
|
+
// Protos optimized for SPEED use a strict superset of the generated code
|
54
|
+
// of equivalent ones optimized for CODE_SIZE, so we should optimize all our
|
55
|
+
// tests for speed unless explicitly testing code size optimization.
|
56
|
+
option optimize_for = SPEED;
|
57
|
+
|
58
|
+
option java_outer_classname = "UnittestProto";
|
59
|
+
|
60
|
+
// This proto includes every type of field in both singular and repeated
|
61
|
+
// forms.
|
62
|
+
message TestAllTypes {
|
63
|
+
message NestedMessage {
|
64
|
+
// The field name "b" fails to compile in proto1 because it conflicts with
|
65
|
+
// a local variable named "b" in one of the generated methods. Doh.
|
66
|
+
// This file needs to compile in proto1 to test backwards-compatibility.
|
67
|
+
optional int32 bb = 1;
|
68
|
+
}
|
69
|
+
|
70
|
+
enum NestedEnum {
|
71
|
+
FOO = 1;
|
72
|
+
BAR = 2;
|
73
|
+
BAZ = 3;
|
74
|
+
NEG = -1; // Intentionally negative.
|
75
|
+
}
|
76
|
+
|
77
|
+
// Singular
|
78
|
+
optional int32 optional_int32 = 1;
|
79
|
+
optional int64 optional_int64 = 2;
|
80
|
+
optional uint32 optional_uint32 = 3;
|
81
|
+
optional uint64 optional_uint64 = 4;
|
82
|
+
optional sint32 optional_sint32 = 5;
|
83
|
+
optional sint64 optional_sint64 = 6;
|
84
|
+
optional fixed32 optional_fixed32 = 7;
|
85
|
+
optional fixed64 optional_fixed64 = 8;
|
86
|
+
optional sfixed32 optional_sfixed32 = 9;
|
87
|
+
optional sfixed64 optional_sfixed64 = 10;
|
88
|
+
optional float optional_float = 11;
|
89
|
+
optional double optional_double = 12;
|
90
|
+
optional bool optional_bool = 13;
|
91
|
+
optional string optional_string = 14;
|
92
|
+
optional bytes optional_bytes = 15;
|
93
|
+
|
94
|
+
optional group OptionalGroup = 16 {
|
95
|
+
optional int32 a = 17;
|
96
|
+
}
|
97
|
+
|
98
|
+
optional NestedMessage optional_nested_message = 18;
|
99
|
+
optional ForeignMessage optional_foreign_message = 19;
|
100
|
+
optional protobuf_unittest_import.ImportMessage optional_import_message = 20;
|
101
|
+
|
102
|
+
optional NestedEnum optional_nested_enum = 21;
|
103
|
+
optional ForeignEnum optional_foreign_enum = 22;
|
104
|
+
optional protobuf_unittest_import.ImportEnum optional_import_enum = 23;
|
105
|
+
|
106
|
+
optional string optional_string_piece = 24 [ctype=STRING_PIECE];
|
107
|
+
optional string optional_cord = 25 [ctype=CORD];
|
108
|
+
|
109
|
+
// Defined in unittest_import_public.proto
|
110
|
+
optional protobuf_unittest_import.PublicImportMessage
|
111
|
+
optional_public_import_message = 26;
|
112
|
+
|
113
|
+
optional NestedMessage optional_lazy_message = 27 [lazy=true];
|
114
|
+
|
115
|
+
// Repeated
|
116
|
+
repeated int32 repeated_int32 = 31;
|
117
|
+
repeated int64 repeated_int64 = 32;
|
118
|
+
repeated uint32 repeated_uint32 = 33;
|
119
|
+
repeated uint64 repeated_uint64 = 34;
|
120
|
+
repeated sint32 repeated_sint32 = 35;
|
121
|
+
repeated sint64 repeated_sint64 = 36;
|
122
|
+
repeated fixed32 repeated_fixed32 = 37;
|
123
|
+
repeated fixed64 repeated_fixed64 = 38;
|
124
|
+
repeated sfixed32 repeated_sfixed32 = 39;
|
125
|
+
repeated sfixed64 repeated_sfixed64 = 40;
|
126
|
+
repeated float repeated_float = 41;
|
127
|
+
repeated double repeated_double = 42;
|
128
|
+
repeated bool repeated_bool = 43;
|
129
|
+
repeated string repeated_string = 44;
|
130
|
+
repeated bytes repeated_bytes = 45;
|
131
|
+
|
132
|
+
repeated group RepeatedGroup = 46 {
|
133
|
+
optional int32 a = 47;
|
134
|
+
}
|
135
|
+
|
136
|
+
repeated NestedMessage repeated_nested_message = 48;
|
137
|
+
repeated ForeignMessage repeated_foreign_message = 49;
|
138
|
+
repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
|
139
|
+
|
140
|
+
repeated NestedEnum repeated_nested_enum = 51;
|
141
|
+
repeated ForeignEnum repeated_foreign_enum = 52;
|
142
|
+
repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
|
143
|
+
|
144
|
+
repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
|
145
|
+
repeated string repeated_cord = 55 [ctype=CORD];
|
146
|
+
|
147
|
+
repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
|
148
|
+
|
149
|
+
// Singular with defaults
|
150
|
+
optional int32 default_int32 = 61 [default = 41 ];
|
151
|
+
optional int64 default_int64 = 62 [default = 42 ];
|
152
|
+
optional uint32 default_uint32 = 63 [default = 43 ];
|
153
|
+
optional uint64 default_uint64 = 64 [default = 44 ];
|
154
|
+
optional sint32 default_sint32 = 65 [default = -45 ];
|
155
|
+
optional sint64 default_sint64 = 66 [default = 46 ];
|
156
|
+
optional fixed32 default_fixed32 = 67 [default = 47 ];
|
157
|
+
optional fixed64 default_fixed64 = 68 [default = 48 ];
|
158
|
+
optional sfixed32 default_sfixed32 = 69 [default = 49 ];
|
159
|
+
optional sfixed64 default_sfixed64 = 70 [default = -50 ];
|
160
|
+
optional float default_float = 71 [default = 51.5 ];
|
161
|
+
optional double default_double = 72 [default = 52e3 ];
|
162
|
+
optional bool default_bool = 73 [default = true ];
|
163
|
+
optional string default_string = 74 [default = "hello"];
|
164
|
+
optional bytes default_bytes = 75 [default = "world"];
|
165
|
+
|
166
|
+
optional NestedEnum default_nested_enum = 81 [default = BAR ];
|
167
|
+
optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR];
|
168
|
+
optional protobuf_unittest_import.ImportEnum
|
169
|
+
default_import_enum = 83 [default = IMPORT_BAR];
|
170
|
+
|
171
|
+
optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
|
172
|
+
optional string default_cord = 85 [ctype=CORD,default="123"];
|
173
|
+
|
174
|
+
// For oneof test
|
175
|
+
oneof oneof_field {
|
176
|
+
uint32 oneof_uint32 = 111;
|
177
|
+
NestedMessage oneof_nested_message = 112;
|
178
|
+
string oneof_string = 113;
|
179
|
+
bytes oneof_bytes = 114;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
// This proto includes a recusively nested message.
|
184
|
+
message NestedTestAllTypes {
|
185
|
+
optional NestedTestAllTypes child = 1;
|
186
|
+
optional TestAllTypes payload = 2;
|
187
|
+
repeated NestedTestAllTypes repeated_child = 3;
|
188
|
+
}
|
189
|
+
|
190
|
+
message TestDeprecatedFields {
|
191
|
+
optional int32 deprecated_int32 = 1 [deprecated=true];
|
192
|
+
}
|
193
|
+
|
194
|
+
// Define these after TestAllTypes to make sure the compiler can handle
|
195
|
+
// that.
|
196
|
+
message ForeignMessage {
|
197
|
+
optional int32 c = 1;
|
198
|
+
}
|
199
|
+
|
200
|
+
enum ForeignEnum {
|
201
|
+
FOREIGN_FOO = 4;
|
202
|
+
FOREIGN_BAR = 5;
|
203
|
+
FOREIGN_BAZ = 6;
|
204
|
+
}
|
205
|
+
|
206
|
+
message TestReservedFields {
|
207
|
+
reserved 2, 15, 9 to 11;
|
208
|
+
reserved "bar", "baz";
|
209
|
+
}
|
210
|
+
|
211
|
+
message TestAllExtensions {
|
212
|
+
extensions 1 to max;
|
213
|
+
}
|
214
|
+
|
215
|
+
extend TestAllExtensions {
|
216
|
+
// Singular
|
217
|
+
optional int32 optional_int32_extension = 1;
|
218
|
+
optional int64 optional_int64_extension = 2;
|
219
|
+
optional uint32 optional_uint32_extension = 3;
|
220
|
+
optional uint64 optional_uint64_extension = 4;
|
221
|
+
optional sint32 optional_sint32_extension = 5;
|
222
|
+
optional sint64 optional_sint64_extension = 6;
|
223
|
+
optional fixed32 optional_fixed32_extension = 7;
|
224
|
+
optional fixed64 optional_fixed64_extension = 8;
|
225
|
+
optional sfixed32 optional_sfixed32_extension = 9;
|
226
|
+
optional sfixed64 optional_sfixed64_extension = 10;
|
227
|
+
optional float optional_float_extension = 11;
|
228
|
+
optional double optional_double_extension = 12;
|
229
|
+
optional bool optional_bool_extension = 13;
|
230
|
+
optional string optional_string_extension = 14;
|
231
|
+
optional bytes optional_bytes_extension = 15;
|
232
|
+
|
233
|
+
optional group OptionalGroup_extension = 16 {
|
234
|
+
optional int32 a = 17;
|
235
|
+
}
|
236
|
+
|
237
|
+
optional TestAllTypes.NestedMessage optional_nested_message_extension = 18;
|
238
|
+
optional ForeignMessage optional_foreign_message_extension = 19;
|
239
|
+
optional protobuf_unittest_import.ImportMessage
|
240
|
+
optional_import_message_extension = 20;
|
241
|
+
|
242
|
+
optional TestAllTypes.NestedEnum optional_nested_enum_extension = 21;
|
243
|
+
optional ForeignEnum optional_foreign_enum_extension = 22;
|
244
|
+
optional protobuf_unittest_import.ImportEnum
|
245
|
+
optional_import_enum_extension = 23;
|
246
|
+
|
247
|
+
optional string optional_string_piece_extension = 24 [ctype=STRING_PIECE];
|
248
|
+
optional string optional_cord_extension = 25 [ctype=CORD];
|
249
|
+
|
250
|
+
optional protobuf_unittest_import.PublicImportMessage
|
251
|
+
optional_public_import_message_extension = 26;
|
252
|
+
|
253
|
+
optional TestAllTypes.NestedMessage
|
254
|
+
optional_lazy_message_extension = 27 [lazy=true];
|
255
|
+
|
256
|
+
// Repeated
|
257
|
+
repeated int32 repeated_int32_extension = 31;
|
258
|
+
repeated int64 repeated_int64_extension = 32;
|
259
|
+
repeated uint32 repeated_uint32_extension = 33;
|
260
|
+
repeated uint64 repeated_uint64_extension = 34;
|
261
|
+
repeated sint32 repeated_sint32_extension = 35;
|
262
|
+
repeated sint64 repeated_sint64_extension = 36;
|
263
|
+
repeated fixed32 repeated_fixed32_extension = 37;
|
264
|
+
repeated fixed64 repeated_fixed64_extension = 38;
|
265
|
+
repeated sfixed32 repeated_sfixed32_extension = 39;
|
266
|
+
repeated sfixed64 repeated_sfixed64_extension = 40;
|
267
|
+
repeated float repeated_float_extension = 41;
|
268
|
+
repeated double repeated_double_extension = 42;
|
269
|
+
repeated bool repeated_bool_extension = 43;
|
270
|
+
repeated string repeated_string_extension = 44;
|
271
|
+
repeated bytes repeated_bytes_extension = 45;
|
272
|
+
|
273
|
+
repeated group RepeatedGroup_extension = 46 {
|
274
|
+
optional int32 a = 47;
|
275
|
+
}
|
276
|
+
|
277
|
+
repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48;
|
278
|
+
repeated ForeignMessage repeated_foreign_message_extension = 49;
|
279
|
+
repeated protobuf_unittest_import.ImportMessage
|
280
|
+
repeated_import_message_extension = 50;
|
281
|
+
|
282
|
+
repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51;
|
283
|
+
repeated ForeignEnum repeated_foreign_enum_extension = 52;
|
284
|
+
repeated protobuf_unittest_import.ImportEnum
|
285
|
+
repeated_import_enum_extension = 53;
|
286
|
+
|
287
|
+
repeated string repeated_string_piece_extension = 54 [ctype=STRING_PIECE];
|
288
|
+
repeated string repeated_cord_extension = 55 [ctype=CORD];
|
289
|
+
|
290
|
+
repeated TestAllTypes.NestedMessage
|
291
|
+
repeated_lazy_message_extension = 57 [lazy=true];
|
292
|
+
|
293
|
+
// Singular with defaults
|
294
|
+
optional int32 default_int32_extension = 61 [default = 41 ];
|
295
|
+
optional int64 default_int64_extension = 62 [default = 42 ];
|
296
|
+
optional uint32 default_uint32_extension = 63 [default = 43 ];
|
297
|
+
optional uint64 default_uint64_extension = 64 [default = 44 ];
|
298
|
+
optional sint32 default_sint32_extension = 65 [default = -45 ];
|
299
|
+
optional sint64 default_sint64_extension = 66 [default = 46 ];
|
300
|
+
optional fixed32 default_fixed32_extension = 67 [default = 47 ];
|
301
|
+
optional fixed64 default_fixed64_extension = 68 [default = 48 ];
|
302
|
+
optional sfixed32 default_sfixed32_extension = 69 [default = 49 ];
|
303
|
+
optional sfixed64 default_sfixed64_extension = 70 [default = -50 ];
|
304
|
+
optional float default_float_extension = 71 [default = 51.5 ];
|
305
|
+
optional double default_double_extension = 72 [default = 52e3 ];
|
306
|
+
optional bool default_bool_extension = 73 [default = true ];
|
307
|
+
optional string default_string_extension = 74 [default = "hello"];
|
308
|
+
optional bytes default_bytes_extension = 75 [default = "world"];
|
309
|
+
|
310
|
+
optional TestAllTypes.NestedEnum
|
311
|
+
default_nested_enum_extension = 81 [default = BAR];
|
312
|
+
optional ForeignEnum
|
313
|
+
default_foreign_enum_extension = 82 [default = FOREIGN_BAR];
|
314
|
+
optional protobuf_unittest_import.ImportEnum
|
315
|
+
default_import_enum_extension = 83 [default = IMPORT_BAR];
|
316
|
+
|
317
|
+
optional string default_string_piece_extension = 84 [ctype=STRING_PIECE,
|
318
|
+
default="abc"];
|
319
|
+
optional string default_cord_extension = 85 [ctype=CORD, default="123"];
|
320
|
+
|
321
|
+
// For oneof test
|
322
|
+
optional uint32 oneof_uint32_extension = 111;
|
323
|
+
optional TestAllTypes.NestedMessage oneof_nested_message_extension = 112;
|
324
|
+
optional string oneof_string_extension = 113;
|
325
|
+
optional bytes oneof_bytes_extension = 114;
|
326
|
+
}
|
327
|
+
|
328
|
+
message TestNestedExtension {
|
329
|
+
extend TestAllExtensions {
|
330
|
+
// Check for bug where string extensions declared in tested scope did not
|
331
|
+
// compile.
|
332
|
+
optional string test = 1002 [default="test"];
|
333
|
+
// Used to test if generated extension name is correct when there are
|
334
|
+
// underscores.
|
335
|
+
optional string nested_string_extension = 1003;
|
336
|
+
}
|
337
|
+
}
|
338
|
+
|
339
|
+
message TestMoreNestedExtension {
|
340
|
+
extend TestAllExtensions {
|
341
|
+
// Check that duplicate field names in different namespaces work
|
342
|
+
optional string test = 1004 [default="a different test"];
|
343
|
+
}
|
344
|
+
}
|
345
|
+
|
346
|
+
// We have separate messages for testing required fields because it's
|
347
|
+
// annoying to have to fill in required fields in TestProto in order to
|
348
|
+
// do anything with it. Note that we don't need to test every type of
|
349
|
+
// required filed because the code output is basically identical to
|
350
|
+
// optional fields for all types.
|
351
|
+
message TestRequired {
|
352
|
+
required int32 a = 1;
|
353
|
+
optional int32 dummy2 = 2;
|
354
|
+
required int32 b = 3;
|
355
|
+
|
356
|
+
extend TestAllExtensions {
|
357
|
+
optional TestRequired single = 1000;
|
358
|
+
repeated TestRequired multi = 1001;
|
359
|
+
}
|
360
|
+
|
361
|
+
// Pad the field count to 32 so that we can test that IsInitialized()
|
362
|
+
// properly checks multiple elements of has_bits_.
|
363
|
+
optional int32 dummy4 = 4;
|
364
|
+
optional int32 dummy5 = 5;
|
365
|
+
optional int32 dummy6 = 6;
|
366
|
+
optional int32 dummy7 = 7;
|
367
|
+
optional int32 dummy8 = 8;
|
368
|
+
optional int32 dummy9 = 9;
|
369
|
+
optional int32 dummy10 = 10;
|
370
|
+
optional int32 dummy11 = 11;
|
371
|
+
optional int32 dummy12 = 12;
|
372
|
+
optional int32 dummy13 = 13;
|
373
|
+
optional int32 dummy14 = 14;
|
374
|
+
optional int32 dummy15 = 15;
|
375
|
+
optional int32 dummy16 = 16;
|
376
|
+
optional int32 dummy17 = 17;
|
377
|
+
optional int32 dummy18 = 18;
|
378
|
+
optional int32 dummy19 = 19;
|
379
|
+
optional int32 dummy20 = 20;
|
380
|
+
optional int32 dummy21 = 21;
|
381
|
+
optional int32 dummy22 = 22;
|
382
|
+
optional int32 dummy23 = 23;
|
383
|
+
optional int32 dummy24 = 24;
|
384
|
+
optional int32 dummy25 = 25;
|
385
|
+
optional int32 dummy26 = 26;
|
386
|
+
optional int32 dummy27 = 27;
|
387
|
+
optional int32 dummy28 = 28;
|
388
|
+
optional int32 dummy29 = 29;
|
389
|
+
optional int32 dummy30 = 30;
|
390
|
+
optional int32 dummy31 = 31;
|
391
|
+
optional int32 dummy32 = 32;
|
392
|
+
|
393
|
+
required int32 c = 33;
|
394
|
+
}
|
395
|
+
|
396
|
+
message TestRequiredForeign {
|
397
|
+
optional TestRequired optional_message = 1;
|
398
|
+
repeated TestRequired repeated_message = 2;
|
399
|
+
optional int32 dummy = 3;
|
400
|
+
}
|
401
|
+
|
402
|
+
// Test that we can use NestedMessage from outside TestAllTypes.
|
403
|
+
message TestForeignNested {
|
404
|
+
optional TestAllTypes.NestedMessage foreign_nested = 1;
|
405
|
+
}
|
406
|
+
|
407
|
+
// TestEmptyMessage is used to test unknown field support.
|
408
|
+
message TestEmptyMessage {
|
409
|
+
}
|
410
|
+
|
411
|
+
// Like above, but declare all field numbers as potential extensions. No
|
412
|
+
// actual extensions should ever be defined for this type.
|
413
|
+
message TestEmptyMessageWithExtensions {
|
414
|
+
extensions 1 to max;
|
415
|
+
}
|
416
|
+
|
417
|
+
message TestMultipleExtensionRanges {
|
418
|
+
extensions 42;
|
419
|
+
extensions 4143 to 4243;
|
420
|
+
extensions 65536 to max;
|
421
|
+
}
|
422
|
+
|
423
|
+
// Test that really large tag numbers don't break anything.
|
424
|
+
message TestReallyLargeTagNumber {
|
425
|
+
// The largest possible tag number is 2^28 - 1, since the wire format uses
|
426
|
+
// three bits to communicate wire type.
|
427
|
+
optional int32 a = 1;
|
428
|
+
optional int32 bb = 268435455;
|
429
|
+
}
|
430
|
+
|
431
|
+
message TestRecursiveMessage {
|
432
|
+
optional TestRecursiveMessage a = 1;
|
433
|
+
optional int32 i = 2;
|
434
|
+
}
|
435
|
+
|
436
|
+
// Test that mutual recursion works.
|
437
|
+
message TestMutualRecursionA {
|
438
|
+
optional TestMutualRecursionB bb = 1;
|
439
|
+
}
|
440
|
+
|
441
|
+
message TestMutualRecursionB {
|
442
|
+
optional TestMutualRecursionA a = 1;
|
443
|
+
optional int32 optional_int32 = 2;
|
444
|
+
}
|
445
|
+
|
446
|
+
// Test that groups have disjoint field numbers from their siblings and
|
447
|
+
// parents. This is NOT possible in proto1; only google.protobuf. When attempting
|
448
|
+
// to compile with proto1, this will emit an error; so we only include it
|
449
|
+
// in protobuf_unittest_proto.
|
450
|
+
message TestDupFieldNumber { // NO_PROTO1
|
451
|
+
optional int32 a = 1; // NO_PROTO1
|
452
|
+
optional group Foo = 2 { optional int32 a = 1; } // NO_PROTO1
|
453
|
+
optional group Bar = 3 { optional int32 a = 1; } // NO_PROTO1
|
454
|
+
} // NO_PROTO1
|
455
|
+
|
456
|
+
// Additional messages for testing lazy fields.
|
457
|
+
message TestEagerMessage {
|
458
|
+
optional TestAllTypes sub_message = 1 [lazy=false];
|
459
|
+
}
|
460
|
+
message TestLazyMessage {
|
461
|
+
optional TestAllTypes sub_message = 1 [lazy=true];
|
462
|
+
}
|
463
|
+
|
464
|
+
// Needed for a Python test.
|
465
|
+
message TestNestedMessageHasBits {
|
466
|
+
message NestedMessage {
|
467
|
+
repeated int32 nestedmessage_repeated_int32 = 1;
|
468
|
+
repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2;
|
469
|
+
}
|
470
|
+
optional NestedMessage optional_nested_message = 1;
|
471
|
+
}
|
472
|
+
|
473
|
+
|
474
|
+
// Test an enum that has multiple values with the same number.
|
475
|
+
enum TestEnumWithDupValue {
|
476
|
+
option allow_alias = true;
|
477
|
+
|
478
|
+
FOO1 = 1;
|
479
|
+
BAR1 = 2;
|
480
|
+
BAZ = 3;
|
481
|
+
FOO2 = 1;
|
482
|
+
BAR2 = 2;
|
483
|
+
}
|
484
|
+
|
485
|
+
// Test an enum with large, unordered values.
|
486
|
+
enum TestSparseEnum {
|
487
|
+
SPARSE_A = 123;
|
488
|
+
SPARSE_B = 62374;
|
489
|
+
SPARSE_C = 12589234;
|
490
|
+
SPARSE_D = -15;
|
491
|
+
SPARSE_E = -53452;
|
492
|
+
SPARSE_F = 0;
|
493
|
+
SPARSE_G = 2;
|
494
|
+
}
|
495
|
+
|
496
|
+
// Test message with CamelCase field names. This violates Protocol Buffer
|
497
|
+
// standard style.
|
498
|
+
message TestCamelCaseFieldNames {
|
499
|
+
optional int32 PrimitiveField = 1;
|
500
|
+
optional string StringField = 2;
|
501
|
+
optional ForeignEnum EnumField = 3;
|
502
|
+
optional ForeignMessage MessageField = 4;
|
503
|
+
optional string StringPieceField = 5 [ctype=STRING_PIECE];
|
504
|
+
optional string CordField = 6 [ctype=CORD];
|
505
|
+
|
506
|
+
repeated int32 RepeatedPrimitiveField = 7;
|
507
|
+
repeated string RepeatedStringField = 8;
|
508
|
+
repeated ForeignEnum RepeatedEnumField = 9;
|
509
|
+
repeated ForeignMessage RepeatedMessageField = 10;
|
510
|
+
repeated string RepeatedStringPieceField = 11 [ctype=STRING_PIECE];
|
511
|
+
repeated string RepeatedCordField = 12 [ctype=CORD];
|
512
|
+
}
|
513
|
+
|
514
|
+
|
515
|
+
// We list fields out of order, to ensure that we're using field number and not
|
516
|
+
// field index to determine serialization order.
|
517
|
+
message TestFieldOrderings {
|
518
|
+
optional string my_string = 11;
|
519
|
+
extensions 2 to 10;
|
520
|
+
optional int64 my_int = 1;
|
521
|
+
extensions 12 to 100;
|
522
|
+
optional float my_float = 101;
|
523
|
+
message NestedMessage {
|
524
|
+
optional int64 oo = 2;
|
525
|
+
// The field name "b" fails to compile in proto1 because it conflicts with
|
526
|
+
// a local variable named "b" in one of the generated methods. Doh.
|
527
|
+
// This file needs to compile in proto1 to test backwards-compatibility.
|
528
|
+
optional int32 bb = 1;
|
529
|
+
}
|
530
|
+
|
531
|
+
optional NestedMessage optional_nested_message = 200;
|
532
|
+
}
|
533
|
+
|
534
|
+
|
535
|
+
extend TestFieldOrderings {
|
536
|
+
optional string my_extension_string = 50;
|
537
|
+
optional int32 my_extension_int = 5;
|
538
|
+
}
|
539
|
+
|
540
|
+
|
541
|
+
message TestExtremeDefaultValues {
|
542
|
+
optional bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"];
|
543
|
+
optional uint32 large_uint32 = 2 [default = 0xFFFFFFFF];
|
544
|
+
optional uint64 large_uint64 = 3 [default = 0xFFFFFFFFFFFFFFFF];
|
545
|
+
optional int32 small_int32 = 4 [default = -0x7FFFFFFF];
|
546
|
+
optional int64 small_int64 = 5 [default = -0x7FFFFFFFFFFFFFFF];
|
547
|
+
optional int32 really_small_int32 = 21 [default = -0x80000000];
|
548
|
+
optional int64 really_small_int64 = 22 [default = -0x8000000000000000];
|
549
|
+
|
550
|
+
// The default value here is UTF-8 for "\u1234". (We could also just type
|
551
|
+
// the UTF-8 text directly into this text file rather than escape it, but
|
552
|
+
// lots of people use editors that would be confused by this.)
|
553
|
+
optional string utf8_string = 6 [default = "\341\210\264"];
|
554
|
+
|
555
|
+
// Tests for single-precision floating-point values.
|
556
|
+
optional float zero_float = 7 [default = 0];
|
557
|
+
optional float one_float = 8 [default = 1];
|
558
|
+
optional float small_float = 9 [default = 1.5];
|
559
|
+
optional float negative_one_float = 10 [default = -1];
|
560
|
+
optional float negative_float = 11 [default = -1.5];
|
561
|
+
// Using exponents
|
562
|
+
optional float large_float = 12 [default = 2E8];
|
563
|
+
optional float small_negative_float = 13 [default = -8e-28];
|
564
|
+
|
565
|
+
// Text for nonfinite floating-point values.
|
566
|
+
optional double inf_double = 14 [default = inf];
|
567
|
+
optional double neg_inf_double = 15 [default = -inf];
|
568
|
+
optional double nan_double = 16 [default = nan];
|
569
|
+
optional float inf_float = 17 [default = inf];
|
570
|
+
optional float neg_inf_float = 18 [default = -inf];
|
571
|
+
optional float nan_float = 19 [default = nan];
|
572
|
+
|
573
|
+
// Tests for C++ trigraphs.
|
574
|
+
// Trigraphs should be escaped in C++ generated files, but they should not be
|
575
|
+
// escaped for other languages.
|
576
|
+
// Note that in .proto file, "\?" is a valid way to escape ? in string
|
577
|
+
// literals.
|
578
|
+
optional string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"];
|
579
|
+
|
580
|
+
// String defaults containing the character '\000'
|
581
|
+
optional string string_with_zero = 23 [default = "hel\000lo"];
|
582
|
+
optional bytes bytes_with_zero = 24 [default = "wor\000ld"];
|
583
|
+
optional string string_piece_with_zero = 25 [ctype=STRING_PIECE,
|
584
|
+
default="ab\000c"];
|
585
|
+
optional string cord_with_zero = 26 [ctype=CORD,
|
586
|
+
default="12\0003"];
|
587
|
+
optional string replacement_string = 27 [default="${unknown}"];
|
588
|
+
}
|
589
|
+
|
590
|
+
message SparseEnumMessage {
|
591
|
+
optional TestSparseEnum sparse_enum = 1;
|
592
|
+
}
|
593
|
+
|
594
|
+
// Test String and Bytes: string is for valid UTF-8 strings
|
595
|
+
message OneString {
|
596
|
+
optional string data = 1;
|
597
|
+
}
|
598
|
+
|
599
|
+
message MoreString {
|
600
|
+
repeated string data = 1;
|
601
|
+
}
|
602
|
+
|
603
|
+
message OneBytes {
|
604
|
+
optional bytes data = 1;
|
605
|
+
}
|
606
|
+
|
607
|
+
message MoreBytes {
|
608
|
+
repeated bytes data = 1;
|
609
|
+
}
|
610
|
+
|
611
|
+
// Test int32, uint32, int64, uint64, and bool are all compatible
|
612
|
+
message Int32Message {
|
613
|
+
optional int32 data = 1;
|
614
|
+
}
|
615
|
+
|
616
|
+
message Uint32Message {
|
617
|
+
optional uint32 data = 1;
|
618
|
+
}
|
619
|
+
|
620
|
+
message Int64Message {
|
621
|
+
optional int64 data = 1;
|
622
|
+
}
|
623
|
+
|
624
|
+
message Uint64Message {
|
625
|
+
optional uint64 data = 1;
|
626
|
+
}
|
627
|
+
|
628
|
+
message BoolMessage {
|
629
|
+
optional bool data = 1;
|
630
|
+
}
|
631
|
+
|
632
|
+
// Test oneofs.
|
633
|
+
message TestOneof {
|
634
|
+
oneof foo {
|
635
|
+
int32 foo_int = 1;
|
636
|
+
string foo_string = 2;
|
637
|
+
TestAllTypes foo_message = 3;
|
638
|
+
group FooGroup = 4 {
|
639
|
+
optional int32 a = 5;
|
640
|
+
optional string b = 6;
|
641
|
+
}
|
642
|
+
}
|
643
|
+
}
|
644
|
+
|
645
|
+
message TestOneofBackwardsCompatible {
|
646
|
+
optional int32 foo_int = 1;
|
647
|
+
optional string foo_string = 2;
|
648
|
+
optional TestAllTypes foo_message = 3;
|
649
|
+
optional group FooGroup = 4 {
|
650
|
+
optional int32 a = 5;
|
651
|
+
optional string b = 6;
|
652
|
+
}
|
653
|
+
}
|
654
|
+
|
655
|
+
message TestOneof2 {
|
656
|
+
oneof foo {
|
657
|
+
int32 foo_int = 1;
|
658
|
+
string foo_string = 2;
|
659
|
+
string foo_cord = 3 [ctype=CORD];
|
660
|
+
string foo_string_piece = 4 [ctype=STRING_PIECE];
|
661
|
+
bytes foo_bytes = 5;
|
662
|
+
NestedEnum foo_enum = 6;
|
663
|
+
NestedMessage foo_message = 7;
|
664
|
+
group FooGroup = 8 {
|
665
|
+
optional int32 a = 9;
|
666
|
+
optional string b = 10;
|
667
|
+
}
|
668
|
+
NestedMessage foo_lazy_message = 11 [lazy=true];
|
669
|
+
}
|
670
|
+
|
671
|
+
oneof bar {
|
672
|
+
int32 bar_int = 12 [default = 5];
|
673
|
+
string bar_string = 13 [default = "STRING"];
|
674
|
+
string bar_cord = 14 [ctype=CORD, default = "CORD"];
|
675
|
+
string bar_string_piece = 15 [ctype=STRING_PIECE, default = "SPIECE"];
|
676
|
+
bytes bar_bytes = 16 [default = "BYTES"];
|
677
|
+
NestedEnum bar_enum = 17 [default = BAR];
|
678
|
+
}
|
679
|
+
|
680
|
+
optional int32 baz_int = 18;
|
681
|
+
optional string baz_string = 19 [default = "BAZ"];
|
682
|
+
|
683
|
+
message NestedMessage {
|
684
|
+
optional int64 qux_int = 1;
|
685
|
+
repeated int32 corge_int = 2;
|
686
|
+
}
|
687
|
+
|
688
|
+
enum NestedEnum {
|
689
|
+
FOO = 1;
|
690
|
+
BAR = 2;
|
691
|
+
BAZ = 3;
|
692
|
+
}
|
693
|
+
}
|
694
|
+
|
695
|
+
message TestRequiredOneof {
|
696
|
+
oneof foo {
|
697
|
+
int32 foo_int = 1;
|
698
|
+
string foo_string = 2;
|
699
|
+
NestedMessage foo_message = 3;
|
700
|
+
}
|
701
|
+
message NestedMessage {
|
702
|
+
required double required_double = 1;
|
703
|
+
}
|
704
|
+
}
|
705
|
+
|
706
|
+
// Test messages for packed fields
|
707
|
+
|
708
|
+
message TestPackedTypes {
|
709
|
+
repeated int32 packed_int32 = 90 [packed = true];
|
710
|
+
repeated int64 packed_int64 = 91 [packed = true];
|
711
|
+
repeated uint32 packed_uint32 = 92 [packed = true];
|
712
|
+
repeated uint64 packed_uint64 = 93 [packed = true];
|
713
|
+
repeated sint32 packed_sint32 = 94 [packed = true];
|
714
|
+
repeated sint64 packed_sint64 = 95 [packed = true];
|
715
|
+
repeated fixed32 packed_fixed32 = 96 [packed = true];
|
716
|
+
repeated fixed64 packed_fixed64 = 97 [packed = true];
|
717
|
+
repeated sfixed32 packed_sfixed32 = 98 [packed = true];
|
718
|
+
repeated sfixed64 packed_sfixed64 = 99 [packed = true];
|
719
|
+
repeated float packed_float = 100 [packed = true];
|
720
|
+
repeated double packed_double = 101 [packed = true];
|
721
|
+
repeated bool packed_bool = 102 [packed = true];
|
722
|
+
repeated ForeignEnum packed_enum = 103 [packed = true];
|
723
|
+
}
|
724
|
+
|
725
|
+
// A message with the same fields as TestPackedTypes, but without packing. Used
|
726
|
+
// to test packed <-> unpacked wire compatibility.
|
727
|
+
message TestUnpackedTypes {
|
728
|
+
repeated int32 unpacked_int32 = 90 [packed = false];
|
729
|
+
repeated int64 unpacked_int64 = 91 [packed = false];
|
730
|
+
repeated uint32 unpacked_uint32 = 92 [packed = false];
|
731
|
+
repeated uint64 unpacked_uint64 = 93 [packed = false];
|
732
|
+
repeated sint32 unpacked_sint32 = 94 [packed = false];
|
733
|
+
repeated sint64 unpacked_sint64 = 95 [packed = false];
|
734
|
+
repeated fixed32 unpacked_fixed32 = 96 [packed = false];
|
735
|
+
repeated fixed64 unpacked_fixed64 = 97 [packed = false];
|
736
|
+
repeated sfixed32 unpacked_sfixed32 = 98 [packed = false];
|
737
|
+
repeated sfixed64 unpacked_sfixed64 = 99 [packed = false];
|
738
|
+
repeated float unpacked_float = 100 [packed = false];
|
739
|
+
repeated double unpacked_double = 101 [packed = false];
|
740
|
+
repeated bool unpacked_bool = 102 [packed = false];
|
741
|
+
repeated ForeignEnum unpacked_enum = 103 [packed = false];
|
742
|
+
}
|
743
|
+
|
744
|
+
message TestPackedExtensions {
|
745
|
+
extensions 1 to max;
|
746
|
+
}
|
747
|
+
|
748
|
+
extend TestPackedExtensions {
|
749
|
+
repeated int32 packed_int32_extension = 90 [packed = true];
|
750
|
+
repeated int64 packed_int64_extension = 91 [packed = true];
|
751
|
+
repeated uint32 packed_uint32_extension = 92 [packed = true];
|
752
|
+
repeated uint64 packed_uint64_extension = 93 [packed = true];
|
753
|
+
repeated sint32 packed_sint32_extension = 94 [packed = true];
|
754
|
+
repeated sint64 packed_sint64_extension = 95 [packed = true];
|
755
|
+
repeated fixed32 packed_fixed32_extension = 96 [packed = true];
|
756
|
+
repeated fixed64 packed_fixed64_extension = 97 [packed = true];
|
757
|
+
repeated sfixed32 packed_sfixed32_extension = 98 [packed = true];
|
758
|
+
repeated sfixed64 packed_sfixed64_extension = 99 [packed = true];
|
759
|
+
repeated float packed_float_extension = 100 [packed = true];
|
760
|
+
repeated double packed_double_extension = 101 [packed = true];
|
761
|
+
repeated bool packed_bool_extension = 102 [packed = true];
|
762
|
+
repeated ForeignEnum packed_enum_extension = 103 [packed = true];
|
763
|
+
}
|
764
|
+
|
765
|
+
message TestUnpackedExtensions {
|
766
|
+
extensions 1 to max;
|
767
|
+
}
|
768
|
+
|
769
|
+
extend TestUnpackedExtensions {
|
770
|
+
repeated int32 unpacked_int32_extension = 90 [packed = false];
|
771
|
+
repeated int64 unpacked_int64_extension = 91 [packed = false];
|
772
|
+
repeated uint32 unpacked_uint32_extension = 92 [packed = false];
|
773
|
+
repeated uint64 unpacked_uint64_extension = 93 [packed = false];
|
774
|
+
repeated sint32 unpacked_sint32_extension = 94 [packed = false];
|
775
|
+
repeated sint64 unpacked_sint64_extension = 95 [packed = false];
|
776
|
+
repeated fixed32 unpacked_fixed32_extension = 96 [packed = false];
|
777
|
+
repeated fixed64 unpacked_fixed64_extension = 97 [packed = false];
|
778
|
+
repeated sfixed32 unpacked_sfixed32_extension = 98 [packed = false];
|
779
|
+
repeated sfixed64 unpacked_sfixed64_extension = 99 [packed = false];
|
780
|
+
repeated float unpacked_float_extension = 100 [packed = false];
|
781
|
+
repeated double unpacked_double_extension = 101 [packed = false];
|
782
|
+
repeated bool unpacked_bool_extension = 102 [packed = false];
|
783
|
+
repeated ForeignEnum unpacked_enum_extension = 103 [packed = false];
|
784
|
+
}
|
785
|
+
|
786
|
+
// Used by ExtensionSetTest/DynamicExtensions. The test actually builds
|
787
|
+
// a set of extensions to TestAllExtensions dynamically, based on the fields
|
788
|
+
// of this message type.
|
789
|
+
message TestDynamicExtensions {
|
790
|
+
enum DynamicEnumType {
|
791
|
+
DYNAMIC_FOO = 2200;
|
792
|
+
DYNAMIC_BAR = 2201;
|
793
|
+
DYNAMIC_BAZ = 2202;
|
794
|
+
}
|
795
|
+
message DynamicMessageType {
|
796
|
+
optional int32 dynamic_field = 2100;
|
797
|
+
}
|
798
|
+
|
799
|
+
optional fixed32 scalar_extension = 2000;
|
800
|
+
optional ForeignEnum enum_extension = 2001;
|
801
|
+
optional DynamicEnumType dynamic_enum_extension = 2002;
|
802
|
+
|
803
|
+
optional ForeignMessage message_extension = 2003;
|
804
|
+
optional DynamicMessageType dynamic_message_extension = 2004;
|
805
|
+
|
806
|
+
repeated string repeated_extension = 2005;
|
807
|
+
repeated sint32 packed_extension = 2006 [packed = true];
|
808
|
+
}
|
809
|
+
|
810
|
+
message TestRepeatedScalarDifferentTagSizes {
|
811
|
+
// Parsing repeated fixed size values used to fail. This message needs to be
|
812
|
+
// used in order to get a tag of the right size; all of the repeated fields
|
813
|
+
// in TestAllTypes didn't trigger the check.
|
814
|
+
repeated fixed32 repeated_fixed32 = 12;
|
815
|
+
// Check for a varint type, just for good measure.
|
816
|
+
repeated int32 repeated_int32 = 13;
|
817
|
+
|
818
|
+
// These have two-byte tags.
|
819
|
+
repeated fixed64 repeated_fixed64 = 2046;
|
820
|
+
repeated int64 repeated_int64 = 2047;
|
821
|
+
|
822
|
+
// Three byte tags.
|
823
|
+
repeated float repeated_float = 262142;
|
824
|
+
repeated uint64 repeated_uint64 = 262143;
|
825
|
+
}
|
826
|
+
|
827
|
+
// Test that if an optional or required message/group field appears multiple
|
828
|
+
// times in the input, they need to be merged.
|
829
|
+
message TestParsingMerge {
|
830
|
+
// RepeatedFieldsGenerator defines matching field types as TestParsingMerge,
|
831
|
+
// except that all fields are repeated. In the tests, we will serialize the
|
832
|
+
// RepeatedFieldsGenerator to bytes, and parse the bytes to TestParsingMerge.
|
833
|
+
// Repeated fields in RepeatedFieldsGenerator are expected to be merged into
|
834
|
+
// the corresponding required/optional fields in TestParsingMerge.
|
835
|
+
message RepeatedFieldsGenerator {
|
836
|
+
repeated TestAllTypes field1 = 1;
|
837
|
+
repeated TestAllTypes field2 = 2;
|
838
|
+
repeated TestAllTypes field3 = 3;
|
839
|
+
repeated group Group1 = 10 {
|
840
|
+
optional TestAllTypes field1 = 11;
|
841
|
+
}
|
842
|
+
repeated group Group2 = 20 {
|
843
|
+
optional TestAllTypes field1 = 21;
|
844
|
+
}
|
845
|
+
repeated TestAllTypes ext1 = 1000;
|
846
|
+
repeated TestAllTypes ext2 = 1001;
|
847
|
+
}
|
848
|
+
required TestAllTypes required_all_types = 1;
|
849
|
+
optional TestAllTypes optional_all_types = 2;
|
850
|
+
repeated TestAllTypes repeated_all_types = 3;
|
851
|
+
optional group OptionalGroup = 10 {
|
852
|
+
optional TestAllTypes optional_group_all_types = 11;
|
853
|
+
}
|
854
|
+
repeated group RepeatedGroup = 20 {
|
855
|
+
optional TestAllTypes repeated_group_all_types = 21;
|
856
|
+
}
|
857
|
+
extensions 1000 to max;
|
858
|
+
extend TestParsingMerge {
|
859
|
+
optional TestAllTypes optional_ext = 1000;
|
860
|
+
repeated TestAllTypes repeated_ext = 1001;
|
861
|
+
}
|
862
|
+
}
|
863
|
+
|
864
|
+
message TestCommentInjectionMessage {
|
865
|
+
// */ <- This should not close the generated doc comment
|
866
|
+
optional string a = 1 [default="*/ <- Neither should this."];
|
867
|
+
}
|
868
|
+
|
869
|
+
|
870
|
+
// Test that RPC services work.
|
871
|
+
message FooRequest {}
|
872
|
+
message FooResponse {}
|
873
|
+
|
874
|
+
message FooClientMessage {}
|
875
|
+
message FooServerMessage{}
|
876
|
+
|
877
|
+
service TestService {
|
878
|
+
rpc Foo(FooRequest) returns (FooResponse);
|
879
|
+
rpc Bar(BarRequest) returns (BarResponse);
|
880
|
+
}
|
881
|
+
|
882
|
+
|
883
|
+
message BarRequest {}
|
884
|
+
message BarResponse {}
|