| 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 // https://developers.google.com/protocol-buffers/ |
| 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. |
| 11 // * Redistributions in binary form must reproduce the above | 11 // * Redistributions in binary form must reproduce the above |
| 12 // copyright notice, this list of conditions and the following disclaimer | 12 // copyright notice, this list of conditions and the following disclaimer |
| 13 // in the documentation and/or other materials provided with the | 13 // in the documentation and/or other materials provided with the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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 google.protobuf. |
| 36 | 36 |
| 37 syntax = "proto2"; |
| 37 | 38 |
| 38 // Some generic_services option(s) added automatically. | 39 // Some generic_services option(s) added automatically. |
| 39 // See: http://go/proto2-generic-services-default | 40 // See: http://go/proto2-generic-services-default |
| 40 option cc_generic_services = true; // auto-added | 41 option cc_generic_services = true; // auto-added |
| 41 option java_generic_services = true; // auto-added | 42 option java_generic_services = true; // auto-added |
| 42 option py_generic_services = true; | 43 option py_generic_services = true; |
| 43 | 44 |
| 44 // A custom file option (defined below). | 45 // A custom file option (defined below). |
| 45 option (file_opt1) = 9876543210; | 46 option (file_opt1) = 9876543210; |
| 46 | 47 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 option (double_opt) = -154; | 212 option (double_opt) = -154; |
| 212 } | 213 } |
| 213 | 214 |
| 214 // Options of complex message types, themselves combined and extended in | 215 // Options of complex message types, themselves combined and extended in |
| 215 // various ways. | 216 // various ways. |
| 216 | 217 |
| 217 message ComplexOptionType1 { | 218 message ComplexOptionType1 { |
| 218 optional int32 foo = 1; | 219 optional int32 foo = 1; |
| 219 optional int32 foo2 = 2; | 220 optional int32 foo2 = 2; |
| 220 optional int32 foo3 = 3; | 221 optional int32 foo3 = 3; |
| 222 repeated int32 foo4 = 4; |
| 221 | 223 |
| 222 extensions 100 to max; | 224 extensions 100 to max; |
| 223 } | 225 } |
| 224 | 226 |
| 225 message ComplexOptionType2 { | 227 message ComplexOptionType2 { |
| 226 optional ComplexOptionType1 bar = 1; | 228 optional ComplexOptionType1 bar = 1; |
| 227 optional int32 baz = 2; | 229 optional int32 baz = 2; |
| 228 | 230 |
| 229 message ComplexOptionType4 { | 231 message ComplexOptionType4 { |
| 230 optional int32 waldo = 1; | 232 optional int32 waldo = 1; |
| 231 | 233 |
| 232 extend google.protobuf.MessageOptions { | 234 extend google.protobuf.MessageOptions { |
| 233 optional ComplexOptionType4 complex_opt4 = 7633546; | 235 optional ComplexOptionType4 complex_opt4 = 7633546; |
| 234 } | 236 } |
| 235 } | 237 } |
| 236 | 238 |
| 237 optional ComplexOptionType4 fred = 3; | 239 optional ComplexOptionType4 fred = 3; |
| 240 repeated ComplexOptionType4 barney = 4; |
| 238 | 241 |
| 239 extensions 100 to max; | 242 extensions 100 to max; |
| 240 } | 243 } |
| 241 | 244 |
| 242 message ComplexOptionType3 { | 245 message ComplexOptionType3 { |
| 243 optional int32 qux = 1; | 246 optional int32 qux = 1; |
| 244 | 247 |
| 245 optional group ComplexOptionType5 = 2 { | 248 optional group ComplexOptionType5 = 2 { |
| 246 optional int32 plugh = 3; | 249 optional int32 plugh = 3; |
| 247 } | 250 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 264 optional group ComplexOpt6 = 7595468 { | 267 optional group ComplexOpt6 = 7595468 { |
| 265 optional int32 xyzzy = 7593951; | 268 optional int32 xyzzy = 7593951; |
| 266 } | 269 } |
| 267 } | 270 } |
| 268 | 271 |
| 269 // Note that we try various different ways of naming the same extension. | 272 // Note that we try various different ways of naming the same extension. |
| 270 message VariousComplexOptions { | 273 message VariousComplexOptions { |
| 271 option (.protobuf_unittest.complex_opt1).foo = 42; | 274 option (.protobuf_unittest.complex_opt1).foo = 42; |
| 272 option (protobuf_unittest.complex_opt1).(.protobuf_unittest.quux) = 324; | 275 option (protobuf_unittest.complex_opt1).(.protobuf_unittest.quux) = 324; |
| 273 option (.protobuf_unittest.complex_opt1).(protobuf_unittest.corge).qux = 876; | 276 option (.protobuf_unittest.complex_opt1).(protobuf_unittest.corge).qux = 876; |
| 277 option (protobuf_unittest.complex_opt1).foo4 = 99; |
| 278 option (protobuf_unittest.complex_opt1).foo4 = 88; |
| 274 option (complex_opt2).baz = 987; | 279 option (complex_opt2).baz = 987; |
| 275 option (complex_opt2).(grault) = 654; | 280 option (complex_opt2).(grault) = 654; |
| 276 option (complex_opt2).bar.foo = 743; | 281 option (complex_opt2).bar.foo = 743; |
| 277 option (complex_opt2).bar.(quux) = 1999; | 282 option (complex_opt2).bar.(quux) = 1999; |
| 278 option (complex_opt2).bar.(protobuf_unittest.corge).qux = 2008; | 283 option (complex_opt2).bar.(protobuf_unittest.corge).qux = 2008; |
| 279 option (complex_opt2).(garply).foo = 741; | 284 option (complex_opt2).(garply).foo = 741; |
| 280 option (complex_opt2).(garply).(.protobuf_unittest.quux) = 1998; | 285 option (complex_opt2).(garply).(.protobuf_unittest.quux) = 1998; |
| 281 option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121; | 286 option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121; |
| 282 option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971; | 287 option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971; |
| 283 option (complex_opt2).fred.waldo = 321; | 288 option (complex_opt2).fred.waldo = 321; |
| 289 option (complex_opt2).barney = { waldo: 101 }; |
| 290 option (complex_opt2).barney = { waldo: 212 }; |
| 284 option (protobuf_unittest.complex_opt3).qux = 9; | 291 option (protobuf_unittest.complex_opt3).qux = 9; |
| 285 option (complex_opt3).complexoptiontype5.plugh = 22; | 292 option (complex_opt3).complexoptiontype5.plugh = 22; |
| 286 option (complexopt6).xyzzy = 24; | 293 option (complexopt6).xyzzy = 24; |
| 287 } | 294 } |
| 288 | 295 |
| 289 // ------------------------------------------------------ | 296 // ------------------------------------------------------ |
| 290 // Definitions for testing aggregate option parsing. | 297 // Definitions for testing aggregate option parsing. |
| 291 // See descriptor_unittest.cc. | 298 // See descriptor_unittest.cc. |
| 292 | 299 |
| 293 message AggregateMessageSet { | 300 message AggregateMessageSet { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 optional int32 nested_field = 1 [(field_opt1) = 1002]; | 385 optional int32 nested_field = 1 [(field_opt1) = 1002]; |
| 379 } | 386 } |
| 380 enum NestedEnum { | 387 enum NestedEnum { |
| 381 option (enum_opt1) = 1003; | 388 option (enum_opt1) = 1003; |
| 382 NESTED_ENUM_VALUE = 1 [(enum_value_opt1) = 1004]; | 389 NESTED_ENUM_VALUE = 1 [(enum_value_opt1) = 1004]; |
| 383 } | 390 } |
| 384 extend google.protobuf.FileOptions { | 391 extend google.protobuf.FileOptions { |
| 385 optional int32 nested_extension = 7912573 [(field_opt2) = 1005]; | 392 optional int32 nested_extension = 7912573 [(field_opt2) = 1005]; |
| 386 } | 393 } |
| 387 } | 394 } |
| 395 |
| 396 // Custom message option that has a required enum field. |
| 397 // WARNING: this is strongly discouraged! |
| 398 message OldOptionType { |
| 399 enum TestEnum { |
| 400 OLD_VALUE = 0; |
| 401 } |
| 402 required TestEnum value = 1; |
| 403 } |
| 404 |
| 405 // Updated version of the custom option above. |
| 406 message NewOptionType { |
| 407 enum TestEnum { |
| 408 OLD_VALUE = 0; |
| 409 NEW_VALUE = 1; |
| 410 } |
| 411 required TestEnum value = 1; |
| 412 } |
| 413 |
| 414 extend google.protobuf.MessageOptions { |
| 415 optional OldOptionType required_enum_opt = 106161807; |
| 416 } |
| 417 |
| 418 // Test message using the "required_enum_opt" option defined above. |
| 419 message TestMessageWithRequiredEnumOption { |
| 420 option (required_enum_opt) = { value: OLD_VALUE }; |
| 421 } |
| OLD | NEW |