Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: third_party/protobuf/objectivec/GPBDescriptor_PackagePrivate.h

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // 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.
(...skipping 19 matching lines...) Expand all
30 30
31 // This header is private to the ProtobolBuffers library and must NOT be 31 // This header is private to the ProtobolBuffers library and must NOT be
32 // included by any sources outside this library. The contents of this file are 32 // included by any sources outside this library. The contents of this file are
33 // subject to change at any time without notice. 33 // subject to change at any time without notice.
34 34
35 #import "GPBDescriptor.h" 35 #import "GPBDescriptor.h"
36 #import "GPBWireFormat.h" 36 #import "GPBWireFormat.h"
37 37
38 // Describes attributes of the field. 38 // Describes attributes of the field.
39 typedef NS_OPTIONS(uint16_t, GPBFieldFlags) { 39 typedef NS_OPTIONS(uint16_t, GPBFieldFlags) {
40 GPBFieldNone = 0,
41 // These map to standard protobuf concepts. 40 // These map to standard protobuf concepts.
42 GPBFieldRequired = 1 << 0, 41 GPBFieldRequired = 1 << 0,
43 GPBFieldRepeated = 1 << 1, 42 GPBFieldRepeated = 1 << 1,
44 GPBFieldPacked = 1 << 2, 43 GPBFieldPacked = 1 << 2,
45 GPBFieldOptional = 1 << 3, 44 GPBFieldOptional = 1 << 3,
46 GPBFieldHasDefaultValue = 1 << 4, 45 GPBFieldHasDefaultValue = 1 << 4,
47 46
48 // Indicates the field needs custom handling for the TextFormat name, if not 47 // Indicates the field needs custom handling for the TextFormat name, if not
49 // set, the name can be derived from the ObjC name. 48 // set, the name can be derived from the ObjC name.
50 GPBFieldTextFormatNameCustom = 1 << 6, 49 GPBFieldTextFormatNameCustom = 1 << 6,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // value. This struct provides the default along with the field info. 104 // value. This struct provides the default along with the field info.
106 typedef struct GPBMessageFieldDescriptionWithDefault { 105 typedef struct GPBMessageFieldDescriptionWithDefault {
107 // Default value for the ivar. 106 // Default value for the ivar.
108 GPBGenericValue defaultValue; 107 GPBGenericValue defaultValue;
109 108
110 GPBMessageFieldDescription core; 109 GPBMessageFieldDescription core;
111 } GPBMessageFieldDescriptionWithDefault; 110 } GPBMessageFieldDescriptionWithDefault;
112 111
113 // Describes attributes of the extension. 112 // Describes attributes of the extension.
114 typedef NS_OPTIONS(uint8_t, GPBExtensionOptions) { 113 typedef NS_OPTIONS(uint8_t, GPBExtensionOptions) {
115 GPBExtensionNone = 0,
116 // These map to standard protobuf concepts. 114 // These map to standard protobuf concepts.
117 GPBExtensionRepeated = 1 << 0, 115 GPBExtensionRepeated = 1 << 0,
118 GPBExtensionPacked = 1 << 1, 116 GPBExtensionPacked = 1 << 1,
119 GPBExtensionSetWireFormat = 1 << 2, 117 GPBExtensionSetWireFormat = 1 << 2,
120 }; 118 };
121 119
122 // An extension 120 // An extension
123 typedef struct GPBExtensionDescription { 121 typedef struct GPBExtensionDescription {
124 GPBGenericValue defaultValue; 122 GPBGenericValue defaultValue;
125 const char *singletonName; 123 const char *singletonName;
126 const char *extendedClass; 124 const char *extendedClass;
127 const char *messageOrGroupClassName; 125 const char *messageOrGroupClassName;
128 GPBEnumDescriptorFunc enumDescriptorFunc; 126 GPBEnumDescriptorFunc enumDescriptorFunc;
129 int32_t fieldNumber; 127 int32_t fieldNumber;
130 GPBDataType dataType; 128 GPBDataType dataType;
131 GPBExtensionOptions options; 129 GPBExtensionOptions options;
132 } GPBExtensionDescription; 130 } GPBExtensionDescription;
133 131
134 typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) { 132 typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
135 GPBDescriptorInitializationFlag_None = 0,
136 GPBDescriptorInitializationFlag_FieldsWithDefault = 1 << 0, 133 GPBDescriptorInitializationFlag_FieldsWithDefault = 1 << 0,
137 GPBDescriptorInitializationFlag_WireFormat = 1 << 1, 134 GPBDescriptorInitializationFlag_WireFormat = 1 << 1,
138 }; 135 };
139 136
140 @interface GPBDescriptor () { 137 @interface GPBDescriptor () {
141 @package 138 @package
142 NSArray *fields_; 139 NSArray *fields_;
143 NSArray *oneofs_; 140 NSArray *oneofs_;
144 uint32_t storageSize_; 141 uint32_t storageSize_;
145 } 142 }
(...skipping 15 matching lines...) Expand all
161 wireFormat:(BOOL)wireFormat; 158 wireFormat:(BOOL)wireFormat;
162 159
163 // Called right after init to provide extra information to avoid init having 160 // Called right after init to provide extra information to avoid init having
164 // an explosion of args. These pointers are recorded, so they are expected 161 // an explosion of args. These pointers are recorded, so they are expected
165 // to live for the lifetime of the app. 162 // to live for the lifetime of the app.
166 - (void)setupOneofs:(const char **)oneofNames 163 - (void)setupOneofs:(const char **)oneofNames
167 count:(uint32_t)count 164 count:(uint32_t)count
168 firstHasIndex:(int32_t)firstHasIndex; 165 firstHasIndex:(int32_t)firstHasIndex;
169 - (void)setupExtraTextInfo:(const char *)extraTextFormatInfo; 166 - (void)setupExtraTextInfo:(const char *)extraTextFormatInfo;
170 - (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)co unt; 167 - (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)co unt;
171 - (void)setupContainingMessageClassName:(const char *)msgClassName;
172 - (void)setupMessageClassNameSuffix:(NSString *)suffix;
173 168
174 @end 169 @end
175 170
176 @interface GPBFileDescriptor () 171 @interface GPBFileDescriptor ()
177 - (instancetype)initWithPackage:(NSString *)package 172 - (instancetype)initWithPackage:(NSString *)package
178 objcPrefix:(NSString *)objcPrefix
179 syntax:(GPBFileSyntax)syntax;
180 - (instancetype)initWithPackage:(NSString *)package
181 syntax:(GPBFileSyntax)syntax; 173 syntax:(GPBFileSyntax)syntax;
182 @end 174 @end
183 175
184 @interface GPBOneofDescriptor () { 176 @interface GPBOneofDescriptor () {
185 @package 177 @package
186 const char *name_; 178 const char *name_;
187 NSArray *fields_; 179 NSArray *fields_;
188 SEL caseSel_; 180 SEL caseSel_;
189 } 181 }
190 // name must be long lived. 182 // name must be long lived.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 @property(nonatomic, readonly) GPBWireFormat alternateWireType; 238 @property(nonatomic, readonly) GPBWireFormat alternateWireType;
247 239
248 // description has to be long lived, it is held as a raw pointer. 240 // description has to be long lived, it is held as a raw pointer.
249 - (instancetype)initWithExtensionDescription: 241 - (instancetype)initWithExtensionDescription:
250 (GPBExtensionDescription *)description; 242 (GPBExtensionDescription *)description;
251 - (NSComparisonResult)compareByFieldNumber:(GPBExtensionDescriptor *)other; 243 - (NSComparisonResult)compareByFieldNumber:(GPBExtensionDescriptor *)other;
252 @end 244 @end
253 245
254 CF_EXTERN_C_BEGIN 246 CF_EXTERN_C_BEGIN
255 247
256 // Direct access is use for speed, to avoid even internally declaring things
257 // read/write, etc. The warning is enabled in the project to ensure code calling
258 // protos can turn on -Wdirect-ivar-access without issues.
259 #pragma clang diagnostic push
260 #pragma clang diagnostic ignored "-Wdirect-ivar-access"
261
262 GPB_INLINE BOOL GPBFieldIsMapOrArray(GPBFieldDescriptor *field) { 248 GPB_INLINE BOOL GPBFieldIsMapOrArray(GPBFieldDescriptor *field) {
263 return (field->description_->flags & 249 return (field->description_->flags &
264 (GPBFieldRepeated | GPBFieldMapKeyMask)) != 0; 250 (GPBFieldRepeated | GPBFieldMapKeyMask)) != 0;
265 } 251 }
266 252
267 GPB_INLINE GPBDataType GPBGetFieldDataType(GPBFieldDescriptor *field) { 253 GPB_INLINE GPBDataType GPBGetFieldDataType(GPBFieldDescriptor *field) {
268 return field->description_->dataType; 254 return field->description_->dataType;
269 } 255 }
270 256
271 GPB_INLINE int32_t GPBFieldHasIndex(GPBFieldDescriptor *field) { 257 GPB_INLINE int32_t GPBFieldHasIndex(GPBFieldDescriptor *field) {
272 return field->description_->hasIndex; 258 return field->description_->hasIndex;
273 } 259 }
274 260
275 GPB_INLINE uint32_t GPBFieldNumber(GPBFieldDescriptor *field) { 261 GPB_INLINE uint32_t GPBFieldNumber(GPBFieldDescriptor *field) {
276 return field->description_->number; 262 return field->description_->number;
277 } 263 }
278 264
279 #pragma clang diagnostic pop
280
281 uint32_t GPBFieldTag(GPBFieldDescriptor *self); 265 uint32_t GPBFieldTag(GPBFieldDescriptor *self);
282 266
283 // For repeated fields, alternateWireType is the wireType with the opposite 267 // For repeated fields, alternateWireType is the wireType with the opposite
284 // value for the packable property. i.e. - if the field was marked packed it 268 // value for the packable property. i.e. - if the field was marked packed it
285 // would be the wire type for unpacked; if the field was marked unpacked, it 269 // would be the wire type for unpacked; if the field was marked unpacked, it
286 // would be the wire type for packed. 270 // would be the wire type for packed.
287 uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self); 271 uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self);
288 272
289 GPB_INLINE BOOL GPBPreserveUnknownFields(GPBFileSyntax syntax) { 273 GPB_INLINE BOOL GPBPreserveUnknownFields(GPBFileSyntax syntax) {
290 return syntax != GPBFileSyntaxProto3; 274 return syntax != GPBFileSyntaxProto3;
291 } 275 }
292 276
293 GPB_INLINE BOOL GPBHasPreservingUnknownEnumSemantics(GPBFileSyntax syntax) { 277 GPB_INLINE BOOL GPBHasPreservingUnknownEnumSemantics(GPBFileSyntax syntax) {
294 return syntax == GPBFileSyntaxProto3; 278 return syntax == GPBFileSyntaxProto3;
295 } 279 }
296 280
297 GPB_INLINE BOOL GPBExtensionIsRepeated(GPBExtensionDescription *description) { 281 GPB_INLINE BOOL GPBExtensionIsRepeated(GPBExtensionDescription *description) {
298 return (description->options & GPBExtensionRepeated) != 0; 282 return (description->options & GPBExtensionRepeated) != 0;
299 } 283 }
300 284
301 GPB_INLINE BOOL GPBExtensionIsPacked(GPBExtensionDescription *description) { 285 GPB_INLINE BOOL GPBExtensionIsPacked(GPBExtensionDescription *description) {
302 return (description->options & GPBExtensionPacked) != 0; 286 return (description->options & GPBExtensionPacked) != 0;
303 } 287 }
304 288
305 GPB_INLINE BOOL GPBExtensionIsWireFormat(GPBExtensionDescription *description) { 289 GPB_INLINE BOOL GPBExtensionIsWireFormat(GPBExtensionDescription *description) {
306 return (description->options & GPBExtensionSetWireFormat) != 0; 290 return (description->options & GPBExtensionSetWireFormat) != 0;
307 } 291 }
308 292
309 // Helper for compile time assets. 293 // Helper for compile time assets.
310 #ifndef GPBInternalCompileAssert 294 #ifndef _GPBCompileAssert
311 #if __has_feature(c_static_assert) || __has_extension(c_static_assert) 295 #if __has_feature(c_static_assert) || __has_extension(c_static_assert)
312 #define GPBInternalCompileAssert(test, msg) _Static_assert((test), #msg) 296 #define _GPBCompileAssert(test, msg) _Static_assert((test), #msg)
313 #else 297 #else
314 // Pre-Xcode 7 support. 298 // Pre-Xcode 7 support.
315 #define GPBInternalCompileAssertSymbolInner(line, msg) GPBInternalCompileAss ert ## line ## __ ## msg 299 #define _GPBCompileAssertSymbolInner(line, msg) _GPBCompileAssert ## line ## __ ## msg
316 #define GPBInternalCompileAssertSymbol(line, msg) GPBInternalCompileAssertSy mbolInner(line, msg) 300 #define _GPBCompileAssertSymbol(line, msg) _GPBCompileAssertSymbolInner(line , msg)
317 #define GPBInternalCompileAssert(test, msg) \ 301 #define _GPBCompileAssert(test, msg) \
318 typedef char GPBInternalCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ] 302 typedef char _GPBCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
319 #endif // __has_feature(c_static_assert) || __has_extension(c_static_assert) 303 #endif // __has_feature(c_static_assert) || __has_extension(c_static_assert)
320 #endif // GPBInternalCompileAssert 304 #endif // _GPBCompileAssert
321 305
322 // Sanity check that there isn't padding between the field description 306 // Sanity check that there isn't padding between the field description
323 // structures with and without a default. 307 // structures with and without a default.
324 GPBInternalCompileAssert(sizeof(GPBMessageFieldDescriptionWithDefault) == 308 _GPBCompileAssert(sizeof(GPBMessageFieldDescriptionWithDefault) ==
325 (sizeof(GPBGenericValue) + 309 (sizeof(GPBGenericValue) +
326 sizeof(GPBMessageFieldDescription)), 310 sizeof(GPBMessageFieldDescription)),
327 DescriptionsWithDefault_different_size_than_expected); 311 DescriptionsWithDefault_different_size_than_expected);
328 312
329 CF_EXTERN_C_END 313 CF_EXTERN_C_END
OLDNEW
« no previous file with comments | « third_party/protobuf/objectivec/GPBDescriptor.m ('k') | third_party/protobuf/objectivec/GPBDictionary.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698