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 // https://developers.google.com/protocol-buffers/ | 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. |
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 12 matching lines...) Expand all Loading... |
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: jonp@google.com (Jon Perlow) | 31 // Author: jonp@google.com (Jon Perlow) |
32 | 32 |
33 // This file tests that various identifiers work as field and type names even | 33 // This file tests that various identifiers work as field and type names even |
34 // though the same identifiers are used internally by the java code generator. | 34 // though the same identifiers are used internally by the java code generator. |
35 | 35 |
36 syntax = "proto2"; | |
37 | 36 |
38 // Some generic_services option(s) added automatically. | 37 // Some generic_services option(s) added automatically. |
39 // See: http://go/proto2-generic-services-default | 38 // See: http://go/proto2-generic-services-default |
40 option java_generic_services = true; // auto-added | 39 option java_generic_services = true; // auto-added |
41 | 40 |
42 package io_protocol_tests; | 41 package io_protocol_tests; |
43 | 42 |
44 option java_package = "com.google.protobuf"; | 43 option java_package = "com.google.protobuf"; |
45 option java_outer_classname = "TestBadIdentifiersProto"; | 44 option java_outer_classname = "TestBadIdentifiersProto"; |
46 option java_generate_equals_and_hash = true; | |
47 | 45 |
48 message TestMessage { | 46 message TestMessage { |
49 optional string cached_size = 1; | |
50 optional string serialized_size = 2; | |
51 optional string class = 3; | |
52 } | 47 } |
53 | 48 |
54 message Descriptor { | 49 message Descriptor { |
55 option no_standard_descriptor_accessor = true; | 50 option no_standard_descriptor_accessor = true; |
56 optional string descriptor = 1; | 51 optional string descriptor = 1; |
57 message NestedDescriptor { | 52 message NestedDescriptor { |
58 option no_standard_descriptor_accessor = true; | 53 option no_standard_descriptor_accessor = true; |
59 optional string descriptor = 1; | 54 optional string descriptor = 1; |
60 } | 55 } |
61 optional NestedDescriptor nested_descriptor = 2; | 56 optional NestedDescriptor nested_descriptor = 2; |
62 enum NestedEnum { | |
63 UNKNOWN = 0; | |
64 FOO = 1; | |
65 } | |
66 } | 57 } |
67 | 58 |
68 message Parser { | 59 message Parser { |
69 enum ParserEnum { | 60 enum ParserEnum { |
70 UNKNOWN = 0; | |
71 PARSER = 1; | 61 PARSER = 1; |
72 } | 62 } |
73 optional ParserEnum parser = 1; | 63 optional ParserEnum parser = 1; |
74 } | 64 } |
75 | 65 |
76 message Deprecated { | 66 message Deprecated { |
77 enum TestEnum { | 67 enum TestEnum { |
78 UNKNOWN = 0; | |
79 FOO = 1; | 68 FOO = 1; |
80 | |
81 // Test if @Deprecated annotation conflicts with Deprecated message name. | |
82 BAR = 2 [ deprecated = true ]; | |
83 } | 69 } |
84 | 70 |
85 optional int32 field1 = 1 [deprecated=true]; | 71 optional int32 field1 = 1 [deprecated=true]; |
86 optional TestEnum field2 = 2 [deprecated=true]; | 72 optional TestEnum field2 = 2 [deprecated=true]; |
87 optional TestMessage field3 = 3 [deprecated=true]; | 73 optional TestMessage field3 = 3 [deprecated=true]; |
88 } | 74 } |
89 | 75 |
90 message Override { | 76 message Override { |
91 optional int32 override = 1; | 77 optional int32 override = 1; |
92 } | 78 } |
(...skipping 20 matching lines...) Expand all Loading... |
113 } | 99 } |
114 | 100 |
115 message Double { | 101 message Double { |
116 optional double double = 1; | 102 optional double double = 1; |
117 } | 103 } |
118 | 104 |
119 service TestConflictingMethodNames { | 105 service TestConflictingMethodNames { |
120 rpc Override(TestMessage) returns (TestMessage); | 106 rpc Override(TestMessage) returns (TestMessage); |
121 } | 107 } |
122 | 108 |
123 message TestConflictingFieldNames { | |
124 enum TestEnum { | |
125 UNKNOWN = 0; | |
126 FOO = 1; | |
127 } | |
128 message TestMessage { | |
129 } | |
130 repeated int32 int32_field = 1; | |
131 repeated TestEnum enum_field = 2; | |
132 repeated string string_field = 3; | |
133 repeated bytes bytes_field = 4; | |
134 repeated TestMessage message_field = 5; | |
135 | |
136 optional int32 int32_field_count = 11; | |
137 optional TestEnum enum_field_count = 12; | |
138 optional string string_field_count = 13; | |
139 optional bytes bytes_field_count = 14; | |
140 optional TestMessage message_field_count = 15; | |
141 | |
142 repeated int32 Int32Field = 21; // NO_PROTO3 | |
143 repeated TestEnum EnumField = 22; // NO_PROTO3 | |
144 repeated string StringField = 23; // NO_PROTO3 | |
145 repeated bytes BytesField = 24; // NO_PROTO3 | |
146 repeated TestMessage MessageField = 25; // NO_PROTO3 | |
147 | |
148 // This field conflicts with "int32_field" as they both generate | |
149 // the method getInt32FieldList(). | |
150 required int32 int32_field_list = 31; // NO_PROTO3 | |
151 | |
152 extensions 1000 to max; // NO_PROTO3 | |
153 | |
154 repeated int64 int64_field = 41; | |
155 extend TestConflictingFieldNames { // NO_PROTO3 | |
156 // We don't generate accessors for extensions so the following extension | |
157 // fields don't conflict with the repeated field "int64_field". | |
158 optional int64 int64_field_count = 1001; // NO_PROTO3 | |
159 optional int64 int64_field_list = 1002; // NO_PROTO3 | |
160 } // NO_PROTO3 | |
161 } | |
162 | |
163 message TestMapField { | |
164 message MapField {} | |
165 message Pair {} | |
166 message Message {} | |
167 | |
168 map<int32, int32> map_field = 1; | |
169 } | |
OLD | NEW |