OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // http://code.google.com/p/protobuf/ | 3 // http://code.google.com/p/protobuf/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 17 matching lines...) Expand all Loading... |
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
31 // Author: benjy@google.com (Benjy Weinberger) | 31 // Author: benjy@google.com (Benjy Weinberger) |
32 // Based on original Protocol Buffers design by | 32 // Based on original Protocol Buffers design by |
33 // Sanjay Ghemawat, Jeff Dean, and others. | 33 // Sanjay Ghemawat, Jeff Dean, and others. |
34 // | 34 // |
35 // A proto file used to test the "custom options" feature of proto2. | 35 // A proto file used to test the "custom options" feature of proto2. |
36 | 36 |
37 | 37 |
| 38 // Some generic_services option(s) added automatically. |
| 39 // See: http://go/proto2-generic-services-default |
| 40 option cc_generic_services = true; // auto-added |
| 41 option java_generic_services = true; // auto-added |
| 42 option py_generic_services = true; |
| 43 |
38 // A custom file option (defined below). | 44 // A custom file option (defined below). |
39 option (file_opt1) = 9876543210; | 45 option (file_opt1) = 9876543210; |
40 | 46 |
41 import "google/protobuf/descriptor.proto"; | 47 import "google/protobuf/descriptor.proto"; |
42 | 48 |
43 // We don't put this in a package within proto2 because we need to make sure | 49 // We don't put this in a package within proto2 because we need to make sure |
44 // that the generated code doesn't depend on being in the proto2 namespace. | 50 // that the generated code doesn't depend on being in the proto2 namespace. |
45 package protobuf_unittest; | 51 package protobuf_unittest; |
46 | 52 |
47 | 53 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 option (complex_opt2).bar.(protobuf_unittest.corge).qux = 2008; | 272 option (complex_opt2).bar.(protobuf_unittest.corge).qux = 2008; |
267 option (complex_opt2).(garply).foo = 741; | 273 option (complex_opt2).(garply).foo = 741; |
268 option (complex_opt2).(garply).(.protobuf_unittest.quux) = 1998; | 274 option (complex_opt2).(garply).(.protobuf_unittest.quux) = 1998; |
269 option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121; | 275 option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121; |
270 option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971; | 276 option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971; |
271 option (complex_opt2).fred.waldo = 321; | 277 option (complex_opt2).fred.waldo = 321; |
272 option (protobuf_unittest.complex_opt3).qux = 9; | 278 option (protobuf_unittest.complex_opt3).qux = 9; |
273 option (complex_opt3).complexoptiontype5.plugh = 22; | 279 option (complex_opt3).complexoptiontype5.plugh = 22; |
274 option (complexopt6).xyzzy = 24; | 280 option (complexopt6).xyzzy = 24; |
275 } | 281 } |
| 282 |
| 283 // ------------------------------------------------------ |
| 284 // Definitions for testing aggregate option parsing. |
| 285 // See descriptor_unittest.cc. |
| 286 |
| 287 message AggregateMessageSet { |
| 288 option message_set_wire_format = true; |
| 289 extensions 4 to max; |
| 290 } |
| 291 |
| 292 message AggregateMessageSetElement { |
| 293 extend AggregateMessageSet { |
| 294 optional AggregateMessageSetElement message_set_extension = 15447542; |
| 295 } |
| 296 optional string s = 1; |
| 297 } |
| 298 |
| 299 // A helper type used to test aggregate option parsing |
| 300 message Aggregate { |
| 301 optional int32 i = 1; |
| 302 optional string s = 2; |
| 303 |
| 304 // A nested object |
| 305 optional Aggregate sub = 3; |
| 306 |
| 307 // To test the parsing of extensions inside aggregate values |
| 308 optional google.protobuf.FileOptions file = 4; |
| 309 extend google.protobuf.FileOptions { |
| 310 optional Aggregate nested = 15476903; |
| 311 } |
| 312 |
| 313 // An embedded message set |
| 314 optional AggregateMessageSet mset = 5; |
| 315 } |
| 316 |
| 317 // Allow Aggregate to be used as an option at all possible locations |
| 318 // in the .proto grammer. |
| 319 extend google.protobuf.FileOptions { optional Aggregate fileopt = 154784
79; } |
| 320 extend google.protobuf.MessageOptions { optional Aggregate msgopt = 154800
88; } |
| 321 extend google.protobuf.FieldOptions { optional Aggregate fieldopt = 154813
74; } |
| 322 extend google.protobuf.EnumOptions { optional Aggregate enumopt = 154832
18; } |
| 323 extend google.protobuf.EnumValueOptions { optional Aggregate enumvalopt = 154869
21; } |
| 324 extend google.protobuf.ServiceOptions { optional Aggregate serviceopt = 154971
45; } |
| 325 extend google.protobuf.MethodOptions { optional Aggregate methodopt = 155127
13; } |
| 326 |
| 327 // Try using AggregateOption at different points in the proto grammar |
| 328 option (fileopt) = { |
| 329 s: 'FileAnnotation' |
| 330 // Also test the handling of comments |
| 331 /* of both types */ i: 100 |
| 332 |
| 333 sub { s: 'NestedFileAnnotation' } |
| 334 |
| 335 // Include a google.protobuf.FileOptions and recursively extend it with |
| 336 // another fileopt. |
| 337 file { |
| 338 [protobuf_unittest.fileopt] { |
| 339 s:'FileExtensionAnnotation' |
| 340 } |
| 341 } |
| 342 |
| 343 // A message set inside an option value |
| 344 mset { |
| 345 [protobuf_unittest.AggregateMessageSetElement.message_set_extension] { |
| 346 s: 'EmbeddedMessageSetElement' |
| 347 } |
| 348 } |
| 349 }; |
| 350 |
| 351 message AggregateMessage { |
| 352 option (msgopt) = { i:101 s:'MessageAnnotation' }; |
| 353 optional int32 fieldname = 1 [(fieldopt) = { s:'FieldAnnotation' }]; |
| 354 } |
| 355 |
| 356 service AggregateService { |
| 357 option (serviceopt) = { s:'ServiceAnnotation' }; |
| 358 rpc Method (AggregateMessage) returns (AggregateMessage) { |
| 359 option (methodopt) = { s:'MethodAnnotation' }; |
| 360 } |
| 361 } |
| 362 |
| 363 enum AggregateEnum { |
| 364 option (enumopt) = { s:'EnumAnnotation' }; |
| 365 VALUE = 1 [(enumvalopt) = { s:'EnumValueAnnotation' }]; |
| 366 } |
OLD | NEW |