7
7
8
8
syntax = "proto2" ;
9
9
10
+ package objc.protobuf.tests ;
11
+
10
12
import "google/protobuf/any.proto" ;
11
13
import "objectivec/Tests/unittest.proto" ;
12
14
13
- package objc.protobuf.tests ;
14
-
15
15
// Explicit empty prefix, tests some validations code paths also.
16
16
option objc_class_prefix = "" ;
17
17
@@ -78,143 +78,142 @@ message self {
78
78
}
79
79
80
80
enum autorelease {
81
- retain = 1 ;
82
- release = 2 ;
81
+ retain = 1 ;
82
+ release = 2 ;
83
83
retainCount = 3 ;
84
84
}
85
85
86
86
// Singular
87
87
// Objective C Keywords
88
- optional bool id = 1 ;
89
- optional bool _cmd = 2 ;
88
+ optional bool id = 1 ;
89
+ optional bool _cmd = 2 ;
90
90
// super is used as submessage above
91
- optional bool in = 4 ;
92
- optional bool out = 5 ;
93
- optional bool inout = 6 ;
94
- optional bool bycopy = 7 ;
95
- optional bool byref = 8 ;
96
- optional bool oneway = 9 ;
97
- optional bool self = 10 ;
98
- optional bool instancetype = 11 ;
99
- optional bool nullable = 12 ;
100
- optional bool nonnull = 13 ;
101
- optional bool nil = 14 ;
91
+ optional bool in = 4 ;
92
+ optional bool out = 5 ;
93
+ optional bool inout = 6 ;
94
+ optional bool bycopy = 7 ;
95
+ optional bool byref = 8 ;
96
+ optional bool oneway = 9 ;
97
+ optional bool self = 10 ;
98
+ optional bool instancetype = 11 ;
99
+ optional bool nullable = 12 ;
100
+ optional bool nonnull = 13 ;
101
+ optional bool nil = 14 ;
102
102
// Nil and nil can't be in the same message
103
- optional bool YES = 16 ;
104
- optional bool NO = 17 ;
105
- optional bool weak = 18 ;
103
+ optional bool YES = 16 ;
104
+ optional bool NO = 17 ;
105
+ optional bool weak = 18 ;
106
106
107
107
// Some C/C++ Keywords
108
- optional bool case = 30 ;
109
- optional bool if = 31 ;
110
- optional bool and_eq = 32 ;
111
- optional bool public = 33 ;
112
- optional bool private = 34 ;
113
- optional bool typename = 35 ;
114
- optional bool static_cast = 36 ;
115
- optional bool typeof = 37 ;
116
- optional bool restrict = 38 ;
117
- optional bool NULL = 39 ;
108
+ optional bool case = 30 ;
109
+ optional bool if = 31 ;
110
+ optional bool and_eq = 32 ;
111
+ optional bool public = 33 ;
112
+ optional bool private = 34 ;
113
+ optional bool typename = 35 ;
114
+ optional bool static_cast = 36 ;
115
+ optional bool typeof = 37 ;
116
+ optional bool restrict = 38 ;
117
+ optional bool NULL = 39 ;
118
118
119
119
// Some NSObject Methods
120
- optional bool dealloc = 110 ;
121
- optional bool isProxy = 111 ;
122
- optional bool copy = 112 ;
123
- optional bool description = 113 ;
124
- optional bool zone = 114 ;
125
- optional bool className = 115 ;
126
- optional bool __retain_OA = 116 ;
127
- optional bool CAMLType = 117 ;
128
- optional bool isNSDictionary__ = 118 ;
120
+ optional bool dealloc = 110 ;
121
+ optional bool isProxy = 111 ;
122
+ optional bool copy = 112 ;
123
+ optional bool description = 113 ;
124
+ optional bool zone = 114 ;
125
+ optional bool className = 115 ;
126
+ optional bool __retain_OA = 116 ;
127
+ optional bool CAMLType = 117 ;
128
+ optional bool isNSDictionary__ = 118 ;
129
129
optional bool accessibilityLabel = 119 ;
130
130
131
131
// Some Objc "keywords" that we shouldn't
132
132
// have to worry about because they
133
133
// can only appear in specialized areas.
134
- optional bool assign = 200 ;
135
- optional bool getter = 201 ;
136
- optional bool setter = 202 ;
137
- optional bool atomic = 203 ;
138
- optional bool nonatomic = 204 ;
139
- optional bool strong = 205 ;
140
- optional bool null_resettable = 206 ;
141
- optional bool readonly = 207 ;
134
+ optional bool assign = 200 ;
135
+ optional bool getter = 201 ;
136
+ optional bool setter = 202 ;
137
+ optional bool atomic = 203 ;
138
+ optional bool nonatomic = 204 ;
139
+ optional bool strong = 205 ;
140
+ optional bool null_resettable = 206 ;
141
+ optional bool readonly = 207 ;
142
142
143
143
// Some GPBMessage methods
144
- optional bool clear = 300 ;
145
- optional bool data = 301 ;
146
- optional bool descriptor = 302 ;
147
- optional bool delimitedData = 303 ;
144
+ optional bool clear = 300 ;
145
+ optional bool data = 301 ;
146
+ optional bool descriptor = 302 ;
147
+ optional bool delimitedData = 303 ;
148
148
149
149
// Some MacTypes
150
- optional bool Fixed = 400 ;
151
- optional bool Point = 401 ;
152
- optional bool FixedPoint = 402 ;
153
- optional bool Style = 403 ;
150
+ optional bool Fixed = 400 ;
151
+ optional bool Point = 401 ;
152
+ optional bool FixedPoint = 402 ;
153
+ optional bool Style = 403 ;
154
154
155
155
// C/C++ reserved identifiers
156
- optional bool _Generic = 500 ;
157
- optional bool __block = 501 ;
156
+ optional bool _Generic = 500 ;
157
+ optional bool __block = 501 ;
158
158
159
159
// Try a keyword as a type
160
- optional autorelease SubEnum = 1000 ;
160
+ optional autorelease SubEnum = 1000 ;
161
161
162
162
optional group New = 2000 {
163
- optional string copy = 1;
163
+ optional string copy = 1;
164
164
}
165
165
optional group MutableCopy = 2001 {
166
166
optional int32 extensionRegistry = 1;
167
167
}
168
168
169
169
extensions 3000 to 3999;
170
-
171
170
}
172
171
173
172
enum retain {
174
- count = 4 ;
175
- initialized = 5 ;
173
+ count = 4 ;
174
+ initialized = 5 ;
176
175
serializedSize = 6 ;
177
176
}
178
177
179
178
message ObjCPropertyNaming {
180
179
// Test that the properties properly get things all caps.
181
- optional string url = 1 ;
180
+ optional string url = 1 ;
182
181
optional string thumbnail_url = 2 ;
183
- optional string url_foo = 3 ;
182
+ optional string url_foo = 3 ;
184
183
optional string some_url_blah = 4 ;
185
- optional string http = 5 ;
186
- optional string https = 6 ;
184
+ optional string http = 5 ;
185
+ optional string https = 6 ;
187
186
// This one doesn't.
188
- repeated string urls = 7 ;
187
+ repeated string urls = 7 ;
189
188
}
190
189
191
190
// EnumValueShortName: The short names shouldn't get suffixes/prefixes.
192
191
enum Foo {
193
192
SERIALIZED_SIZE = 1 ;
194
- SIZE = 2 ;
195
- OTHER = 3 ;
193
+ SIZE = 2 ;
194
+ OTHER = 3 ;
196
195
}
197
196
198
197
// EnumValueShortName: The enum name gets a prefix.
199
198
enum Category {
200
- RED = 1 ;
199
+ RED = 1 ;
201
200
BLUE = 2 ;
202
201
}
203
202
204
203
// EnumValueShortName: Twist case, full name gets PB, but the short names
205
204
// should still end up correct.
206
205
enum Time {
207
- BASE = 1 ;
208
- RECORD = 2 ;
209
- SOMETHING_ELSE = 3 ;
206
+ BASE = 1 ;
207
+ RECORD = 2 ;
208
+ SOMETHING_ELSE = 3 ;
210
209
}
211
210
212
211
extend self {
213
- repeated int32 debugDescription = 3000 [packed = true ];
214
- repeated int64 finalize = 3001 [packed = true ];
215
- repeated uint32 hash = 3002 [packed = true ];
216
- repeated uint64 classForCoder = 3003 [packed = true ];
217
- repeated sint32 byref = 3004 [packed = true ];
212
+ repeated int32 debugDescription = 3000 [packed = true ];
213
+ repeated int64 finalize = 3001 [packed = true ];
214
+ repeated uint32 hash = 3002 [packed = true ];
215
+ repeated uint64 classForCoder = 3003 [packed = true ];
216
+ repeated sint32 byref = 3004 [packed = true ];
218
217
}
219
218
220
219
// Test handing of fields that start with init*.
@@ -700,13 +699,17 @@ message JustToScopeExtensions {
700
699
701
700
repeated string mutableCopy_val_lower_complex_repeated = 2711 ;
702
701
repeated string mutableCopy_Val_upper_complex_repeated = 2712 ;
703
- repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 2713 ;
704
- repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 2714 ;
702
+ repeated string mutableCopyvalue_lower_no_underscore_complex_repeated =
703
+ 2713;
704
+ repeated string mutableCopyValue_upper_no_underscore_complex_repeated =
705
+ 2714;
705
706
706
707
repeated int32 mutableCopy_val_lower_primitive_repeated = 2715 ;
707
708
repeated int32 mutableCopy_Val_upper_primitive_repeated = 2716 ;
708
- repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 2717 ;
709
- repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 2718 ;
709
+ repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated =
710
+ 2717;
711
+ repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated =
712
+ 2718;
710
713
711
714
repeated self mutableCopy_val_lower_message_repeated = 2719 ;
712
715
repeated self mutableCopy_Val_upper_message_repeated = 2720 ;
@@ -781,9 +784,9 @@ message ObjcWeirdDefaults {
781
784
// Used to confirm negative enum values work as expected.
782
785
message EnumTestMsg {
783
786
enum MyEnum {
784
- ZERO = 0 ;
785
- ONE = 1 ;
786
- TWO = 2 ;
787
+ ZERO = 0 ;
788
+ ONE = 1 ;
789
+ TWO = 2 ;
787
790
NEG_ONE = -1;
788
791
NEG_TWO = -2;
789
792
}
@@ -794,6 +797,20 @@ message EnumTestMsg {
794
797
repeated MyEnum mumble = 4 ;
795
798
}
796
799
800
+ message EnumTestMsgPrime {
801
+ enum MyEnumPrime {
802
+ ZERO = 0 ;
803
+ ONE = 1 ;
804
+ NEG_ONE = -1;
805
+ // Lacks 2, -2.
806
+ }
807
+ optional MyEnumPrime foo = 1 ;
808
+ optional MyEnumPrime bar = 2 [default = ONE ];
809
+ optional MyEnumPrime baz = 3 [default = NEG_ONE ];
810
+
811
+ repeated MyEnumPrime mumble = 4 ;
812
+ }
813
+
797
814
// Test case for https://github.com/protocolbuffers/protobuf/issues/1453
798
815
// Message with no explicit defaults, but a non zero default for an enum.
799
816
message MessageWithOneBasedEnum {
0 commit comments