Format the headers.

pull/10650/head
Thomas Van Lenten 2 years ago
parent 9e069b2e51
commit 5d0b2175c3
  1. 9
      objectivec/GPBBootstrap.h
  2. 2
      objectivec/GPBCodedInputStream.h
  3. 16
      objectivec/GPBCodedInputStream_PackagePrivate.h
  4. 68
      objectivec/GPBCodedOutputStream_PackagePrivate.h
  5. 10
      objectivec/GPBDescriptor.h
  6. 130
      objectivec/GPBDescriptor_PackagePrivate.h
  7. 19
      objectivec/GPBDictionary_PackagePrivate.h
  8. 11
      objectivec/GPBExtensionInternals.h
  9. 2
      objectivec/GPBExtensionRegistry.h
  10. 9
      objectivec/GPBMessage.h
  11. 7
      objectivec/GPBMessage_PackagePrivate.h
  12. 6
      objectivec/GPBUnknownField.h
  13. 2
      objectivec/GPBUnknownFieldSet.h
  14. 7
      objectivec/GPBUtilities.h
  15. 49
      objectivec/GPBUtilities_PackagePrivate.h
  16. 12
      objectivec/GPBWellKnownTypes.h

@ -42,7 +42,7 @@
// Used in the generated code to give sizes to enums. int32_t was chosen based
// on the fact that Protocol Buffers enums are limited to this range.
#if !__has_feature(objc_fixed_enum)
#error All supported Xcode versions should support objc_fixed_enum.
#error All supported Xcode versions should support objc_fixed_enum.
#endif
// If the headers are imported into Objective-C++, we can run into an issue
@ -52,9 +52,11 @@
// providing a local definition. The default case has to use NS_ENUM for the
// magic that is Swift bridging of enums.
#if (defined(__cplusplus) && __cplusplus && __cplusplus < 201103L)
#define GPB_ENUM(X) enum X : int32_t X; enum X : int32_t
#define GPB_ENUM(X) \
enum X : int32_t X; \
enum X : int32_t
#else
#define GPB_ENUM(X) NS_ENUM(int32_t, X)
#define GPB_ENUM(X) NS_ENUM(int32_t, X)
#endif
/**
@ -138,7 +140,6 @@
// - Gets changed when support for the older generated code is dropped.
#define GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION 30001
// This is a legacy constant now frozen in time for old generated code. If
// GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION ever gets moved above 30001 then
// this should also change to break code compiled with an old runtime that

@ -185,7 +185,7 @@ CF_EXTERN_C_END
* extensions for message.
**/
- (void)readMessage:(GPBMessage *)message
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry;
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry;
/**
* Reads and discards a single field, given its tag value.

@ -65,8 +65,7 @@ typedef struct GPBCodedInputStreamState {
// Reads a group field value from the stream and merges it into the given
// UnknownFieldSet.
- (void)readUnknownGroup:(int32_t)fieldNumber
message:(GPBUnknownFieldSet *)message;
- (void)readUnknownGroup:(int32_t)fieldNumber message:(GPBUnknownFieldSet *)message;
// Reads a map entry.
- (void)readMapEntry:(id)mapDictionary
@ -97,16 +96,13 @@ NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state)
__attribute((ns_returns_retained));
NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state)
__attribute((ns_returns_retained));
NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(
GPBCodedInputStreamState *state) __attribute((ns_returns_retained));
NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(GPBCodedInputStreamState *state)
__attribute((ns_returns_retained));
size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state,
size_t byteLimit);
void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state,
size_t oldLimit);
size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state, size_t byteLimit);
void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state, size_t oldLimit);
size_t GPBCodedInputStreamBytesUntilLimit(GPBCodedInputStreamState *state);
BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state);
void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
int32_t value);
void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t value);
CF_EXTERN_C_END

@ -34,46 +34,27 @@ NS_ASSUME_NONNULL_BEGIN
CF_EXTERN_C_BEGIN
size_t GPBComputeDoubleSize(int32_t fieldNumber, double value)
__attribute__((const));
size_t GPBComputeFloatSize(int32_t fieldNumber, float value)
__attribute__((const));
size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value)
__attribute__((const));
size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value)
__attribute__((const));
size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value)
__attribute__((const));
size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value)
__attribute__((const));
size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value)
__attribute__((const));
size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value)
__attribute__((const));
size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value)
__attribute__((const));
size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value)
__attribute__((const));
size_t GPBComputeUnknownGroupSize(int32_t fieldNumber,
GPBUnknownFieldSet *value)
__attribute__((const));
size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value)
__attribute__((const));
size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value)
__attribute__((const));
size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value)
__attribute__((const));
size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value)
__attribute__((const));
size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value)
__attribute__((const));
size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value)
__attribute__((const));
size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value)
__attribute__((const));
size_t GPBComputeDoubleSize(int32_t fieldNumber, double value) __attribute__((const));
size_t GPBComputeFloatSize(int32_t fieldNumber, float value) __attribute__((const));
size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value) __attribute__((const));
size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value) __attribute__((const));
size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value) __attribute__((const));
size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value) __attribute__((const));
size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value) __attribute__((const));
size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value) __attribute__((const));
size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value) __attribute__((const));
size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value) __attribute__((const));
size_t GPBComputeUnknownGroupSize(int32_t fieldNumber, GPBUnknownFieldSet *value)
__attribute__((const));
size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value) __attribute__((const));
size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value) __attribute__((const));
size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value) __attribute__((const));
size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value) __attribute__((const));
size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value) __attribute__((const));
size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value) __attribute__((const));
size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value) __attribute__((const));
size_t GPBComputeTagSize(int32_t fieldNumber) __attribute__((const));
size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType)
__attribute__((const));
size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType) __attribute__((const));
size_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const));
size_t GPBComputeFloatSizeNoTag(float value) __attribute__((const));
@ -85,8 +66,7 @@ size_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const));
size_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const));
size_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const));
size_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const));
size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value)
__attribute__((const));
size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value) __attribute__((const));
size_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const));
size_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const));
size_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const));
@ -103,8 +83,7 @@ size_t GPBComputeRawVarint32Size(int32_t value) __attribute__((const));
size_t GPBComputeRawVarint64Size(int64_t value) __attribute__((const));
// Note that this will calculate the size of 64 bit values truncated to 32.
size_t GPBComputeRawVarint32SizeForInteger(NSInteger value)
__attribute__((const));
size_t GPBComputeRawVarint32SizeForInteger(NSInteger value) __attribute__((const));
// Compute the number of bytes that would be needed to encode a
// MessageSet extension to the stream. For historical reasons,
@ -118,8 +97,7 @@ size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value)
size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value)
__attribute__((const));
size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value)
__attribute__((const));
size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value) __attribute__((const));
CF_EXTERN_C_END

@ -62,14 +62,14 @@ typedef NS_ENUM(uint8_t, GPBFieldType) {
/**
* Describes a proto message.
**/
@interface GPBDescriptor : NSObject<NSCopying>
@interface GPBDescriptor : NSObject <NSCopying>
/** Name of the message. */
@property(nonatomic, readonly, copy) NSString *name;
/** Fields declared in the message. */
@property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor*> *fields;
@property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor *> *fields;
/** Oneofs declared in the message. */
@property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor*> *oneofs;
@property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor *> *oneofs;
/** Extension range declared for the message. */
@property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRanges;
/** Number of extension ranges declared for the message. */
@ -139,7 +139,7 @@ typedef NS_ENUM(uint8_t, GPBFieldType) {
/** Name of the oneof field. */
@property(nonatomic, readonly) NSString *name;
/** Fields declared in the oneof. */
@property(nonatomic, readonly) NSArray<GPBFieldDescriptor*> *fields;
@property(nonatomic, readonly) NSArray<GPBFieldDescriptor *> *fields;
/**
* Gets the field for the given number.
@ -293,7 +293,7 @@ typedef NS_ENUM(uint8_t, GPBFieldType) {
/**
* Describes a proto extension.
**/
@interface GPBExtensionDescriptor : NSObject<NSCopying>
@interface GPBExtensionDescriptor : NSObject <NSCopying>
/** Field number under which the extension is stored. */
@property(nonatomic, readonly) uint32_t fieldNumber;
/** The containing message class, i.e. the class extended by this extension. */

@ -37,12 +37,12 @@
// Describes attributes of the field.
typedef NS_OPTIONS(uint16_t, GPBFieldFlags) {
GPBFieldNone = 0,
GPBFieldNone = 0,
// These map to standard protobuf concepts.
GPBFieldRequired = 1 << 0,
GPBFieldRepeated = 1 << 1,
GPBFieldPacked = 1 << 2,
GPBFieldOptional = 1 << 3,
GPBFieldRequired = 1 << 0,
GPBFieldRepeated = 1 << 1,
GPBFieldPacked = 1 << 2,
GPBFieldOptional = 1 << 3,
GPBFieldHasDefaultValue = 1 << 4,
// Indicate that the field should "clear" when set to zero value. This is the
@ -60,19 +60,19 @@ typedef NS_OPTIONS(uint16_t, GPBFieldFlags) {
// These bits are used to mark the field as a map and what the key
// type is.
GPBFieldMapKeyMask = 0xF << 8,
GPBFieldMapKeyInt32 = 1 << 8,
GPBFieldMapKeyInt64 = 2 << 8,
GPBFieldMapKeyUInt32 = 3 << 8,
GPBFieldMapKeyUInt64 = 4 << 8,
GPBFieldMapKeySInt32 = 5 << 8,
GPBFieldMapKeySInt64 = 6 << 8,
GPBFieldMapKeyFixed32 = 7 << 8,
GPBFieldMapKeyFixed64 = 8 << 8,
GPBFieldMapKeySFixed32 = 9 << 8,
GPBFieldMapKeyMask = 0xF << 8,
GPBFieldMapKeyInt32 = 1 << 8,
GPBFieldMapKeyInt64 = 2 << 8,
GPBFieldMapKeyUInt32 = 3 << 8,
GPBFieldMapKeyUInt64 = 4 << 8,
GPBFieldMapKeySInt32 = 5 << 8,
GPBFieldMapKeySInt64 = 6 << 8,
GPBFieldMapKeyFixed32 = 7 << 8,
GPBFieldMapKeyFixed64 = 8 << 8,
GPBFieldMapKeySFixed32 = 9 << 8,
GPBFieldMapKeySFixed64 = 10 << 8,
GPBFieldMapKeyBool = 11 << 8,
GPBFieldMapKeyString = 12 << 8,
GPBFieldMapKeyBool = 11 << 8,
GPBFieldMapKeyString = 12 << 8,
};
// NOTE: The structures defined here have their members ordered to minimize
@ -88,7 +88,7 @@ typedef struct GPBMessageFieldDescription {
// kept around right now for backwards compatibility.
// clazz is used iff GPBDescriptorInitializationFlag_UsesClassRefs is set.
char *className; // Name of the class of the message.
Class clazz; // Class of the message.
Class clazz; // Class of the message.
// For enums only: If EnumDescriptors are compiled in, it will be that,
// otherwise it will be the verifier.
GPBEnumDescriptorFunc enumDescFunc;
@ -120,10 +120,10 @@ typedef struct GPBMessageFieldDescriptionWithDefault {
// Describes attributes of the extension.
typedef NS_OPTIONS(uint8_t, GPBExtensionOptions) {
GPBExtensionNone = 0,
GPBExtensionNone = 0,
// These map to standard protobuf concepts.
GPBExtensionRepeated = 1 << 0,
GPBExtensionPacked = 1 << 1,
GPBExtensionRepeated = 1 << 0,
GPBExtensionPacked = 1 << 1,
GPBExtensionSetWireFormat = 1 << 2,
};
@ -132,10 +132,10 @@ typedef struct GPBExtensionDescription {
GPBGenericValue defaultValue;
const char *singletonName;
// Before 3.12, `extendedClass` was just a `const char *`. Thanks to nested
// initialization (https://en.cppreference.com/w/c/language/struct_initialization#Nested_initialization)
// old generated code with `.extendedClass = GPBStringifySymbol(Something)`
// still works; and the current generator can use `extendedClass.clazz`, to
// pass a Class reference.
// initialization
// (https://en.cppreference.com/w/c/language/struct_initialization#Nested_initialization) old
// generated code with `.extendedClass = GPBStringifySymbol(Something)` still works; and the
// current generator can use `extendedClass.clazz`, to pass a Class reference.
union {
const char *name;
Class clazz;
@ -150,9 +150,9 @@ typedef struct GPBExtensionDescription {
union {
const char *messageOrGroupClassName;
union {
const char *name;
Class clazz;
} messageOrGroupClass;
const char *name;
Class clazz;
} messageOrGroupClass;
};
GPBEnumDescriptorFunc enumDescriptorFunc;
int32_t fieldNumber;
@ -161,14 +161,14 @@ typedef struct GPBExtensionDescription {
} GPBExtensionDescription;
typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
GPBDescriptorInitializationFlag_None = 0,
GPBDescriptorInitializationFlag_None = 0,
GPBDescriptorInitializationFlag_FieldsWithDefault = 1 << 0,
GPBDescriptorInitializationFlag_WireFormat = 1 << 1,
GPBDescriptorInitializationFlag_WireFormat = 1 << 1,
// This is used as a stopgap as we move from using class names to class
// references. The runtime needs to support both until we allow a
// breaking change in the runtime.
GPBDescriptorInitializationFlag_UsesClassRefs = 1 << 2,
GPBDescriptorInitializationFlag_UsesClassRefs = 1 << 2,
// This flag is used to indicate that the generated sources already contain
// the `GPBFieldClearHasIvarOnZero` flag and it doesn't have to be computed
@ -185,14 +185,13 @@ typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
}
// fieldDescriptions have to be long lived, they are held as raw pointers.
+ (instancetype)
allocDescriptorForClass:(Class)messageClass
rootClass:(Class)rootClass
file:(GPBFileDescriptor *)file
fields:(void *)fieldDescriptions
fieldCount:(uint32_t)fieldCount
storageSize:(uint32_t)storageSize
flags:(GPBDescriptorInitializationFlags)flags;
+ (instancetype)allocDescriptorForClass:(Class)messageClass
rootClass:(Class)rootClass
file:(GPBFileDescriptor *)file
fields:(void *)fieldDescriptions
fieldCount:(uint32_t)fieldCount
storageSize:(uint32_t)storageSize
flags:(GPBDescriptorInitializationFlags)flags;
- (instancetype)initWithClass:(Class)messageClass
file:(GPBFileDescriptor *)file
@ -220,8 +219,7 @@ typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
- (instancetype)initWithPackage:(NSString *)package
objcPrefix:(NSString *)objcPrefix
syntax:(GPBFileSyntax)syntax;
- (instancetype)initWithPackage:(NSString *)package
syntax:(GPBFileSyntax)syntax;
- (instancetype)initWithPackage:(NSString *)package syntax:(GPBFileSyntax)syntax;
@end
@interface GPBOneofDescriptor () {
@ -258,19 +256,17 @@ typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
@interface GPBEnumDescriptor ()
// valueNames, values and extraTextFormatInfo have to be long lived, they are
// held as raw pointers.
+ (instancetype)
allocDescriptorForName:(NSString *)name
valueNames:(const char *)valueNames
values:(const int32_t *)values
count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier;
+ (instancetype)
allocDescriptorForName:(NSString *)name
valueNames:(const char *)valueNames
values:(const int32_t *)values
count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier
extraTextFormatInfo:(const char *)extraTextFormatInfo;
+ (instancetype)allocDescriptorForName:(NSString *)name
valueNames:(const char *)valueNames
values:(const int32_t *)values
count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier;
+ (instancetype)allocDescriptorForName:(NSString *)name
valueNames:(const char *)valueNames
values:(const int32_t *)values
count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier
extraTextFormatInfo:(const char *)extraTextFormatInfo;
- (instancetype)initWithName:(NSString *)name
valueNames:(const char *)valueNames
@ -309,8 +305,7 @@ CF_EXTERN_C_BEGIN
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
GPB_INLINE BOOL GPBFieldIsMapOrArray(GPBFieldDescriptor *field) {
return (field->description_->flags &
(GPBFieldRepeated | GPBFieldMapKeyMask)) != 0;
return (field->description_->flags & (GPBFieldRepeated | GPBFieldMapKeyMask)) != 0;
}
GPB_INLINE GPBDataType GPBGetFieldDataType(GPBFieldDescriptor *field) {
@ -353,22 +348,21 @@ GPB_INLINE BOOL GPBExtensionIsWireFormat(GPBExtensionDescription *description) {
// Helper for compile time assets.
#ifndef GPBInternalCompileAssert
#if __has_feature(c_static_assert) || __has_extension(c_static_assert)
#define GPBInternalCompileAssert(test, msg) _Static_assert((test), #msg)
#else
// Pre-Xcode 7 support.
#define GPBInternalCompileAssertSymbolInner(line, msg) GPBInternalCompileAssert ## line ## __ ## msg
#define GPBInternalCompileAssertSymbol(line, msg) GPBInternalCompileAssertSymbolInner(line, msg)
#define GPBInternalCompileAssert(test, msg) \
typedef char GPBInternalCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
#endif // __has_feature(c_static_assert) || __has_extension(c_static_assert)
#endif // GPBInternalCompileAssert
#if __has_feature(c_static_assert) || __has_extension(c_static_assert)
#define GPBInternalCompileAssert(test, msg) _Static_assert((test), #msg)
#else
// Pre-Xcode 7 support.
#define GPBInternalCompileAssertSymbolInner(line, msg) GPBInternalCompileAssert##line##__##msg
#define GPBInternalCompileAssertSymbol(line, msg) GPBInternalCompileAssertSymbolInner(line, msg)
#define GPBInternalCompileAssert(test, msg) \
typedef char GPBInternalCompileAssertSymbol(__LINE__, msg)[((test) ? 1 : -1)]
#endif // __has_feature(c_static_assert) || __has_extension(c_static_assert)
#endif // GPBInternalCompileAssert
// Sanity check that there isn't padding between the field description
// structures with and without a default.
GPBInternalCompileAssert(sizeof(GPBMessageFieldDescriptionWithDefault) ==
(sizeof(GPBGenericValue) +
sizeof(GPBMessageFieldDescription)),
(sizeof(GPBGenericValue) + sizeof(GPBMessageFieldDescription)),
DescriptionsWithDefault_different_size_than_expected);
CF_EXTERN_C_END

@ -41,8 +41,7 @@
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field;
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream
asField:(GPBFieldDescriptor *)field;
- (void)setGPBGenericValue:(GPBGenericValue *)value
forGPBGenericValueKey:(GPBGenericValue *)key;
- (void)setGPBGenericValue:(GPBGenericValue *)value forGPBGenericValueKey:(GPBGenericValue *)key;
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block;
@end
@ -459,7 +458,7 @@
#pragma mark - NSDictionary Subclass
@interface GPBAutocreatedDictionary : NSMutableDictionary {
@package
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@ -470,24 +469,20 @@ CF_EXTERN_C_BEGIN
// Helper to compute size when an NSDictionary is used for the map instead
// of a custom type.
size_t GPBDictionaryComputeSizeInternalHelper(NSDictionary *dict,
GPBFieldDescriptor *field);
size_t GPBDictionaryComputeSizeInternalHelper(NSDictionary *dict, GPBFieldDescriptor *field);
// Helper to write out when an NSDictionary is used for the map instead
// of a custom type.
void GPBDictionaryWriteToStreamInternalHelper(
GPBCodedOutputStream *outputStream, NSDictionary *dict,
GPBFieldDescriptor *field);
void GPBDictionaryWriteToStreamInternalHelper(GPBCodedOutputStream *outputStream,
NSDictionary *dict, GPBFieldDescriptor *field);
// Helper to check message initialization when an NSDictionary is used for
// the map instead of a custom type.
BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict,
GPBFieldDescriptor *field);
BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict, GPBFieldDescriptor *field);
// Helper to read a map instead.
void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream,
id<GPBExtensionRegistry>registry,
GPBFieldDescriptor *field,
id<GPBExtensionRegistry> registry, GPBFieldDescriptor *field,
GPBMessage *parentMessage);
CF_EXTERN_C_END

@ -36,15 +36,12 @@
@class GPBCodedOutputStream;
@protocol GPBExtensionRegistry;
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension,
BOOL isPackedOnStream,
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, BOOL isPackedOnStream,
GPBCodedInputStream *input,
id<GPBExtensionRegistry>extensionRegistry,
id<GPBExtensionRegistry> extensionRegistry,
GPBMessage *message);
size_t GPBComputeExtensionSerializedSizeIncludingTag(
GPBExtensionDescriptor *extension, id value);
size_t GPBComputeExtensionSerializedSizeIncludingTag(GPBExtensionDescriptor *extension, id value);
void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension,
id value,
void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension, id value,
GPBCodedOutputStream *output);

@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
* MyMessage *msg = [MyMessage parseData:data extensionRegistry:registry error:&parseError];
* ```
**/
@interface GPBExtensionRegistry : NSObject<NSCopying, GPBExtensionRegistry>
@interface GPBExtensionRegistry : NSObject <NSCopying, GPBExtensionRegistry>
/**
* Adds the given GPBExtensionDescriptor to this registry.

@ -80,7 +80,7 @@ CF_EXTERN_C_END
* @c +parseFromData:extensionRegistry:error: to provide an extension
* registry.
**/
@interface GPBMessage : NSObject<NSSecureCoding, NSCopying>
@interface GPBMessage : NSObject <NSSecureCoding, NSCopying>
// If you add an instance method/property to this class that may conflict with
// fields declared in protos, you need to update objective_helpers.cc. The main
@ -427,8 +427,7 @@ CF_EXTERN_C_END
* @param extension The extension descriptor under which to set the value.
* @param value The value to be set as the extension.
**/
- (void)setExtension:(GPBExtensionDescriptor *)extension
value:(nullable id)value;
- (void)setExtension:(GPBExtensionDescriptor *)extension value:(nullable id)value;
/**
* Adds the given value to the extension for this message. This only applies
@ -449,9 +448,7 @@ CF_EXTERN_C_END
* @param index The index of the extension to be replaced.
* @param value The value to be replaced in the repeated extension.
**/
- (void)setExtension:(GPBExtensionDescriptor *)extension
index:(NSUInteger)index
value:(id)value;
- (void)setExtension:(GPBExtensionDescriptor *)extension index:(NSUInteger)index value:(id)value;
/**
* Clears the given extension for this message.

@ -83,8 +83,7 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
// Parses the next delimited message of this type from the input and merges it
// with this message.
- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(id<GPBExtensionRegistry>)extensionRegistry;
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
@ -92,14 +91,12 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
CF_EXTERN_C_BEGIN
// Call this before using the readOnlySemaphore_. This ensures it is created only once.
void GPBPrepareReadOnlySemaphore(GPBMessage *self);
// Returns a new instance that was automatically created by |autocreator| for
// its field |field|.
GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass,
GPBMessage *autocreator,
GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass, GPBMessage *autocreator,
GPBFieldDescriptor *field)
__attribute__((ns_returns_retained));

@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
* Store an unknown field. These are used in conjunction with
* GPBUnknownFieldSet.
**/
@interface GPBUnknownField : NSObject<NSCopying>
@interface GPBUnknownField : NSObject <NSCopying>
/** Initialize a field with the given number. */
- (instancetype)initWithNumber:(int32_t)number;
@ -58,10 +58,10 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List;
/** An array of data values for this field. */
@property(nonatomic, readonly, strong) NSArray<NSData*> *lengthDelimitedList;
@property(nonatomic, readonly, strong) NSArray<NSData *> *lengthDelimitedList;
/** An array of groups of values for this field. */
@property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet*> *groupList;
@property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet *> *groupList;
/**
* Add a value to the varintList.

@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
* applies for files declared with the "proto2" syntax. Files declared with the
* "proto3" syntax discard the unknown values.
**/
@interface GPBUnknownFieldSet : NSObject<NSCopying>
@interface GPBUnknownFieldSet : NSObject <NSCopying>
/**
* Tests to see if the given field number has a value.

@ -50,8 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An NSString with the TextFormat of the message.
**/
NSString *GPBTextFormatForMessage(GPBMessage *message,
NSString * __nullable lineIndent);
NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *__nullable lineIndent);
/**
* Generates a string that should be a valid "TextFormat" for the C++ version
@ -63,8 +62,8 @@ NSString *GPBTextFormatForMessage(GPBMessage *message,
*
* @return An NSString with the TextFormat of the unknown field set.
**/
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet,
NSString * __nullable lineIndent);
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *__nullable unknownSet,
NSString *__nullable lineIndent);
/**
* Checks if the given field number is set on a message.

@ -40,17 +40,15 @@
#define GPBStringify(S) #S
#define GPBStringifySymbol(S) GPBStringify(S)
#define GPBNSStringify(S) @#S
#define GPBNSStringify(S) @ #S
#define GPBNSStringifySymbol(S) GPBNSStringify(S)
// Macros for generating a Class from a class name. These are used in
// the generated GPB descriptor classes wherever an Objective C class
// reference is needed for a generated class.
#define GPBObjCClassSymbol(name) OBJC_CLASS_$_##name
#define GPBObjCClass(name) \
((__bridge Class)&(GPBObjCClassSymbol(name)))
#define GPBObjCClassDeclaration(name) \
extern const GPBObjcClass_t GPBObjCClassSymbol(name)
#define GPBObjCClass(name) ((__bridge Class) & (GPBObjCClassSymbol(name)))
#define GPBObjCClassDeclaration(name) extern const GPBObjcClass_t GPBObjCClassSymbol(name)
// Constant to internally mark when there is no has bit.
#define GPBNoHasBit INT32_MAX
@ -120,7 +118,7 @@ GPB_INLINE int64_t GPBLogicalRightShift64(int64_t value, int32_t spaces) {
// negative values must be sign-extended to 64 bits to be varint encoded,
// thus always taking 10 bytes on the wire.)
GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) {
return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n) & 1));
return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n)&1));
}
// Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers
@ -128,7 +126,7 @@ GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) {
// negative values must be sign-extended to 64 bits to be varint encoded,
// thus always taking 10 bytes on the wire.)
GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) {
return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n) & 1));
return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n)&1));
}
// Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers
@ -197,12 +195,10 @@ GPB_INLINE BOOL GPBFieldStoresObject(GPBFieldDescriptor *field) {
}
BOOL GPBGetHasIvar(GPBMessage *self, int32_t index, uint32_t fieldNumber);
void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber,
BOOL value);
void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber, BOOL value);
uint32_t GPBGetHasOneof(GPBMessage *self, int32_t index);
GPB_INLINE BOOL
GPBGetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field) {
GPB_INLINE BOOL GPBGetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field) {
GPBMessageFieldDescription *fieldDesc = field->description_;
return GPBGetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number);
}
@ -262,28 +258,21 @@ void GPBSetDoubleIvarWithFieldPrivate(GPBMessage *self,
// clang-format on
void GPBSetEnumIvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value);
void GPBSetEnumIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field);
void GPBSetObjectIvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field, id value);
void GPBSetRetainedObjectIvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
id __attribute__((ns_consumed))
value);
void GPBSetObjectIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field, id value);
void GPBSetRetainedObjectIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field,
id __attribute__((ns_consumed)) value);
// GPBGetObjectIvarWithField will automatically create the field (message) if
// it doesn't exist. GPBGetObjectIvarWithFieldNoAutocreate will return nil.
id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self,
GPBFieldDescriptor *field);
id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self, GPBFieldDescriptor *field);
// Clears and releases the autocreated message ivar, if it's autocreated. If
// it's not set as autocreated, this method does nothing.
void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self,
GPBFieldDescriptor *field);
void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self, GPBFieldDescriptor *field);
// Returns an Objective C encoding for |selector|. |instanceSel| should be
// YES if it's an instance selector (as opposed to a class selector).
@ -293,17 +282,13 @@ const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel);
// Helper for text format name encoding.
// decodeData is the data describing the special decodes.
// key and inputString are the input that needs decoding.
NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key,
NSString *inputString);
NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, NSString *inputString);
// Shims from the older generated code into the runtime.
void GPBSetInt32IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value,
void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, GPBFieldDescriptor *field, int32_t value,
GPBFileSyntax syntax);
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
int32_t oneofHasIndex, uint32_t fieldNumberNotToClear);
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, int32_t oneofHasIndex,
uint32_t fieldNumberNotToClear);
// A series of selectors that are used solely to get @encoding values
// for them by the dynamic protobuf runtime code. See

@ -141,8 +141,7 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
*
* @return A newly configured GPBAny with the given message, or nil on failure.
*/
+ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message
error:(NSError **)errorPtr;
+ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message error:(NSError **)errorPtr;
/**
* Convenience method to create a GPBAny containing the serialized message.
@ -168,8 +167,7 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
*
* @return A newly configured GPBAny with the given message, or nil on failure.
*/
- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message
error:(NSError **)errorPtr;
- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message error:(NSError **)errorPtr;
/**
* Initializes a GPBAny to contain the serialized message.
@ -195,8 +193,7 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
*
* @return Whether the packing was successful or not.
*/
- (BOOL)packWithMessage:(nonnull GPBMessage *)message
error:(NSError **)errorPtr;
- (BOOL)packWithMessage:(nonnull GPBMessage *)message error:(NSError **)errorPtr;
/**
* Packs the serialized message into this GPBAny.
@ -225,8 +222,7 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
* @return An instance of the given class populated with the contained data, or
* nil on failure.
*/
- (nullable GPBMessage *)unpackMessageClass:(Class)messageClass
error:(NSError **)errorPtr;
- (nullable GPBMessage *)unpackMessageClass:(Class)messageClass error:(NSError **)errorPtr;
@end

Loading…
Cancel
Save