Commit d3d66d79 authored by Paul Yang's avatar Paul Yang

Merge pull request #503 from thomasvl/add_nonnill_markup

Add nonnull/nullable/null_resettable markup to ObjC library.
parents 5b3a8e76 8c88957e
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
// Note: These are not meant to be subclassed. // Note: These are not meant to be subclassed.
NS_ASSUME_NONNULL_BEGIN
//%PDDM-EXPAND DECLARE_ARRAYS() //%PDDM-EXPAND DECLARE_ARRAYS()
// This block of code is generated, do not edit it directly. // This block of code is generated, do not edit it directly.
...@@ -321,21 +323,21 @@ ...@@ -321,21 +323,21 @@
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
+ (instancetype)array; + (instancetype)array;
+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func; + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
rawValue:(int32_t)value; rawValue:(int32_t)value;
+ (instancetype)arrayWithValueArray:(GPBEnumArray *)array; + (instancetype)arrayWithValueArray:(GPBEnumArray *)array;
+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
capacity:(NSUInteger)count; capacity:(NSUInteger)count;
- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func; - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
// Initializes the array, copying the values. // Initializes the array, copying the values.
- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
rawValues:(const int32_t [])values rawValues:(const int32_t [])values
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithValueArray:(GPBEnumArray *)array; - (instancetype)initWithValueArray:(GPBEnumArray *)array;
- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
capacity:(NSUInteger)count; capacity:(NSUInteger)count;
// These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a // These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a
...@@ -392,6 +394,8 @@ ...@@ -392,6 +394,8 @@
//%PDDM-EXPAND-END DECLARE_ARRAYS() //%PDDM-EXPAND-END DECLARE_ARRAYS()
NS_ASSUME_NONNULL_END
//%PDDM-DEFINE DECLARE_ARRAYS() //%PDDM-DEFINE DECLARE_ARRAYS()
//%ARRAY_INTERFACE_SIMPLE(Int32, int32_t) //%ARRAY_INTERFACE_SIMPLE(Int32, int32_t)
//%ARRAY_INTERFACE_SIMPLE(UInt32, uint32_t) //%ARRAY_INTERFACE_SIMPLE(UInt32, uint32_t)
...@@ -444,21 +448,21 @@ ...@@ -444,21 +448,21 @@
//%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; //%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
//% //%
//%+ (instancetype)array; //%+ (instancetype)array;
//%+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func; //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func;
//%+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
//% rawValue:(TYPE)value; //% rawValue:(TYPE)value;
//%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array; //%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array;
//%+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
//% capacity:(NSUInteger)count; //% capacity:(NSUInteger)count;
//% //%
//%- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func; //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
//% //%
//%// Initializes the array, copying the values. //%// Initializes the array, copying the values.
//%- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
//% rawValues:(const TYPE [])values //% rawValues:(const TYPE [])values
//% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; //% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
//%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array; //%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array;
//%- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
//% capacity:(NSUInteger)count; //% capacity:(NSUInteger)count;
//% //%
//%// These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a //%// These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
@class GPBMessage; @class GPBMessage;
@class GPBExtensionRegistry; @class GPBExtensionRegistry;
NS_ASSUME_NONNULL_BEGIN
// Reads and decodes protocol message fields. // Reads and decodes protocol message fields.
// Subclassing of GPBCodedInputStream is NOT supported. // Subclassing of GPBCodedInputStream is NOT supported.
@interface GPBCodedInputStream : NSObject @interface GPBCodedInputStream : NSObject
...@@ -64,7 +66,7 @@ ...@@ -64,7 +66,7 @@
// Read an embedded message field value from the stream. // Read an embedded message field value from the stream.
- (void)readMessage:(GPBMessage *)message - (void)readMessage:(GPBMessage *)message
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry; extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
// Reads and discards a single field, given its tag value. Returns NO if the // Reads and discards a single field, given its tag value. Returns NO if the
// tag is an endgroup tag, in which case nothing is skipped. Otherwise, // tag is an endgroup tag, in which case nothing is skipped. Otherwise,
...@@ -81,3 +83,5 @@ ...@@ -81,3 +83,5 @@
- (void)checkLastTagWas:(int32_t)value; - (void)checkLastTagWas:(int32_t)value;
@end @end
NS_ASSUME_NONNULL_END
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
@class GPBUInt64Array; @class GPBUInt64Array;
@class GPBUnknownFieldSet; @class GPBUnknownFieldSet;
NS_ASSUME_NONNULL_BEGIN
@interface GPBCodedOutputStream : NSObject @interface GPBCodedOutputStream : NSObject
// Creates a new stream to write into data. Data must be sized to fit or it // Creates a new stream to write into data. Data must be sized to fit or it
...@@ -53,12 +55,10 @@ ...@@ -53,12 +55,10 @@
+ (instancetype)streamWithOutputStream:(NSOutputStream *)output + (instancetype)streamWithOutputStream:(NSOutputStream *)output
bufferSize:(size_t)bufferSize; bufferSize:(size_t)bufferSize;
- (instancetype)initWithOutputStream:(NSOutputStream *)output;
- (instancetype)initWithData:(NSMutableData *)data; - (instancetype)initWithData:(NSMutableData *)data;
- (instancetype)initWithOutputStream:(NSOutputStream *)output;
- (instancetype)initWithOutputStream:(NSOutputStream *)output - (instancetype)initWithOutputStream:(NSOutputStream *)output
bufferSize:(size_t)bufferSize; bufferSize:(size_t)bufferSize;
- (instancetype)initWithOutputStream:(NSOutputStream *)output
data:(NSMutableData *)data;
- (void)flush; - (void)flush;
...@@ -294,6 +294,8 @@ size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value) ...@@ -294,6 +294,8 @@ size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value)
CF_EXTERN_C_END CF_EXTERN_C_END
NS_ASSUME_NONNULL_END
// Write methods for types that can be in packed arrays. // Write methods for types that can be in packed arrays.
//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE) //%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value; //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
......
...@@ -184,6 +184,9 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, ...@@ -184,6 +184,9 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
return [self initWithOutputStream:output data:data]; return [self initWithOutputStream:output data:data];
} }
// This initializer isn't exposed, but it is the designated initializer.
// Setting OutputStream and NSData is to control the buffering behavior/size
// of the work, but that is more obvious via the bufferSize: version.
- (instancetype)initWithOutputStream:(NSOutputStream *)output - (instancetype)initWithOutputStream:(NSOutputStream *)output
data:(NSMutableData *)data { data:(NSMutableData *)data {
if ((self = [super init])) { if ((self = [super init])) {
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
@class GPBFileDescriptor; @class GPBFileDescriptor;
@class GPBOneofDescriptor; @class GPBOneofDescriptor;
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, GPBFileSyntax) { typedef NS_ENUM(NSInteger, GPBFileSyntax) {
GPBFileSyntaxUnknown = 0, GPBFileSyntaxUnknown = 0,
GPBFileSyntaxProto2 = 2, GPBFileSyntaxProto2 = 2,
...@@ -53,20 +55,20 @@ typedef NS_ENUM(NSInteger, GPBFieldType) { ...@@ -53,20 +55,20 @@ typedef NS_ENUM(NSInteger, GPBFieldType) {
@interface GPBDescriptor : NSObject<NSCopying> @interface GPBDescriptor : NSObject<NSCopying>
@property(nonatomic, readonly, copy) NSString *name; @property(nonatomic, readonly, copy) NSString *name;
@property(nonatomic, readonly, strong) NSArray *fields; @property(nonatomic, readonly, strong, nullable) NSArray *fields;
@property(nonatomic, readonly, strong) NSArray *oneofs; @property(nonatomic, readonly, strong, nullable) NSArray *oneofs;
@property(nonatomic, readonly, strong) NSArray *enums; @property(nonatomic, readonly, strong, nullable) NSArray *enums;
@property(nonatomic, readonly) const GPBExtensionRange *extensionRanges; @property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRanges;
@property(nonatomic, readonly) NSUInteger extensionRangesCount; @property(nonatomic, readonly) NSUInteger extensionRangesCount;
@property(nonatomic, readonly, assign) GPBFileDescriptor *file; @property(nonatomic, readonly, assign) GPBFileDescriptor *file;
@property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat; @property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat;
@property(nonatomic, readonly) Class messageClass; @property(nonatomic, readonly) Class messageClass;
- (GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber; - (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
- (GPBFieldDescriptor *)fieldWithName:(NSString *)name; - (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
- (GPBOneofDescriptor *)oneofWithName:(NSString *)name; - (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name;
- (GPBEnumDescriptor *)enumWithName:(NSString *)name; - (nullable GPBEnumDescriptor *)enumWithName:(NSString *)name;
@end @end
...@@ -81,8 +83,8 @@ typedef NS_ENUM(NSInteger, GPBFieldType) { ...@@ -81,8 +83,8 @@ typedef NS_ENUM(NSInteger, GPBFieldType) {
@property(nonatomic, readonly) NSString *name; @property(nonatomic, readonly) NSString *name;
@property(nonatomic, readonly) NSArray *fields; @property(nonatomic, readonly) NSArray *fields;
- (GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber; - (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
- (GPBFieldDescriptor *)fieldWithName:(NSString *)name; - (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
@end @end
@interface GPBFieldDescriptor : NSObject @interface GPBFieldDescriptor : NSObject
...@@ -99,21 +101,21 @@ typedef NS_ENUM(NSInteger, GPBFieldType) { ...@@ -99,21 +101,21 @@ typedef NS_ENUM(NSInteger, GPBFieldType) {
@property(nonatomic, readonly) GPBDataType mapKeyDataType; @property(nonatomic, readonly) GPBDataType mapKeyDataType;
@property(nonatomic, readonly, getter=isPackable) BOOL packable; @property(nonatomic, readonly, getter=isPackable) BOOL packable;
@property(nonatomic, readonly, assign) GPBOneofDescriptor *containingOneof; @property(nonatomic, readonly, assign, nullable) GPBOneofDescriptor *containingOneof;
@property(nonatomic, readonly) GPBFieldOptions *fieldOptions; @property(nonatomic, readonly, nullable) GPBFieldOptions *fieldOptions;
// Message properties // Message properties
@property(nonatomic, readonly, assign) Class msgClass; @property(nonatomic, readonly, assign, nullable) Class msgClass;
// Enum properties // Enum properties
@property(nonatomic, readonly, strong) GPBEnumDescriptor *enumDescriptor; @property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
- (BOOL)isValidEnumValue:(int32_t)value; - (BOOL)isValidEnumValue:(int32_t)value;
// For now, this will return nil if it doesn't know the name to use for // For now, this will return nil if it doesn't know the name to use for
// TextFormat. // TextFormat.
- (NSString *)textFormatName; - (nullable NSString *)textFormatName;
@end @end
...@@ -122,10 +124,10 @@ typedef NS_ENUM(NSInteger, GPBFieldType) { ...@@ -122,10 +124,10 @@ typedef NS_ENUM(NSInteger, GPBFieldType) {
@property(nonatomic, readonly, copy) NSString *name; @property(nonatomic, readonly, copy) NSString *name;
@property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier; @property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier;
- (NSString *)enumNameForValue:(int32_t)number; - (nullable NSString *)enumNameForValue:(int32_t)number;
- (BOOL)getValue:(int32_t *)outValue forEnumName:(NSString *)name; - (BOOL)getValue:(nullable int32_t *)outValue forEnumName:(NSString *)name;
- (NSString *)textFormatNameForValue:(int32_t)number; - (nullable NSString *)textFormatNameForValue:(int32_t)number;
@end @end
...@@ -137,6 +139,8 @@ typedef NS_ENUM(NSInteger, GPBFieldType) { ...@@ -137,6 +139,8 @@ typedef NS_ENUM(NSInteger, GPBFieldType) {
@property(nonatomic, readonly, getter=isPackable) BOOL packable; @property(nonatomic, readonly, getter=isPackable) BOOL packable;
@property(nonatomic, readonly, assign) Class msgClass; @property(nonatomic, readonly, assign) Class msgClass;
@property(nonatomic, readonly) NSString *singletonName; @property(nonatomic, readonly) NSString *singletonName;
@property(nonatomic, readonly, strong) GPBEnumDescriptor *enumDescriptor; @property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
@property(nonatomic, readonly) id defaultValue; @property(nonatomic, readonly) id defaultValue;
@end @end
NS_ASSUME_NONNULL_END
This diff is collapsed.
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
@class GPBDescriptor; @class GPBDescriptor;
@class GPBExtensionDescriptor; @class GPBExtensionDescriptor;
NS_ASSUME_NONNULL_BEGIN
// A table of known extensions, searchable by name or field number. When // A table of known extensions, searchable by name or field number. When
// parsing a protocol message that might have extensions, you must provide an // parsing a protocol message that might have extensions, you must provide an
// ExtensionRegistry in which you have registered any extensions that you want // ExtensionRegistry in which you have registered any extensions that you want
...@@ -57,7 +59,9 @@ ...@@ -57,7 +59,9 @@
- (void)addExtension:(GPBExtensionDescriptor *)extension; - (void)addExtension:(GPBExtensionDescriptor *)extension;
- (void)addExtensions:(GPBExtensionRegistry *)registry; - (void)addExtensions:(GPBExtensionRegistry *)registry;
- (GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor - (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
fieldNumber:(NSInteger)fieldNumber; fieldNumber:(NSInteger)fieldNumber;
@end @end
NS_ASSUME_NONNULL_END
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
@class GPBFieldDescriptor; @class GPBFieldDescriptor;
@class GPBUnknownFieldSet; @class GPBUnknownFieldSet;
NS_ASSUME_NONNULL_BEGIN
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
// NSError domain used for errors. // NSError domain used for errors.
...@@ -66,7 +68,7 @@ CF_EXTERN_C_END ...@@ -66,7 +68,7 @@ CF_EXTERN_C_END
// The main cases are methods that take no arguments, or setFoo:/hasFoo: type // The main cases are methods that take no arguments, or setFoo:/hasFoo: type
// methods. // methods.
@property(nonatomic, readonly) GPBUnknownFieldSet *unknownFields; @property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields;
// Are all required fields in the message and all embedded messages set. // Are all required fields in the message and all embedded messages set.
@property(nonatomic, readonly, getter=isInitialized) BOOL initialized; @property(nonatomic, readonly, getter=isInitialized) BOOL initialized;
...@@ -80,18 +82,18 @@ CF_EXTERN_C_END ...@@ -80,18 +82,18 @@ CF_EXTERN_C_END
// if one is missing, the parse will fail (returning nil, filling in errorPtr). // if one is missing, the parse will fail (returning nil, filling in errorPtr).
+ (instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr; + (instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr;
+ (instancetype)parseFromData:(NSData *)data + (instancetype)parseFromData:(NSData *)data
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr; error:(NSError **)errorPtr;
+ (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input + (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry: extensionRegistry:
(GPBExtensionRegistry *)extensionRegistry (nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr; error:(NSError **)errorPtr;
// Create a message based on delimited input. If there is a data parse // Create a message based on delimited input. If there is a data parse
// error, nil is returned and if not NULL, errorPtr is filled in. // error, nil is returned and if not NULL, errorPtr is filled in.
+ (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input + (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry: extensionRegistry:
(GPBExtensionRegistry *)extensionRegistry (nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr; error:(NSError **)errorPtr;
// If there is a data parse error, nil is returned and if not NULL, errorPtr is // If there is a data parse error, nil is returned and if not NULL, errorPtr is
...@@ -100,11 +102,11 @@ CF_EXTERN_C_END ...@@ -100,11 +102,11 @@ CF_EXTERN_C_END
// if one is missing, the parse will fail (returning nil, filling in errorPtr). // if one is missing, the parse will fail (returning nil, filling in errorPtr).
- (instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr; - (instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr;
- (instancetype)initWithData:(NSData *)data - (instancetype)initWithData:(NSData *)data
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr; error:(NSError **)errorPtr;
- (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input - (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry: extensionRegistry:
(GPBExtensionRegistry *)extensionRegistry (nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr; error:(NSError **)errorPtr;
// Serializes the message and writes it to output. // Serializes the message and writes it to output.
...@@ -121,11 +123,11 @@ CF_EXTERN_C_END ...@@ -121,11 +123,11 @@ CF_EXTERN_C_END
// while generating the data, nil is returned. // while generating the data, nil is returned.
// NOTE: In DEBUG ONLY, the message is also checked for all required field, // NOTE: In DEBUG ONLY, the message is also checked for all required field,
// if one is missing, nil will be returned. // if one is missing, nil will be returned.
- (NSData *)data; - (nullable NSData *)data;
// Same as -[data], except a delimiter is added to the start of the data // Same as -[data], except a delimiter is added to the start of the data
// indicating the size of the message data that follows. // indicating the size of the message data that follows.
- (NSData *)delimitedData; - (nullable NSData *)delimitedData;
// Returns the size of the object if it were serialized. // Returns the size of the object if it were serialized.
// This is not a cached value. If you are following a pattern like this: // This is not a cached value. If you are following a pattern like this:
...@@ -149,16 +151,14 @@ CF_EXTERN_C_END ...@@ -149,16 +151,14 @@ CF_EXTERN_C_END
// repeated. If the extension is a Message one will be auto created for you // repeated. If the extension is a Message one will be auto created for you
// and returned similar to fields. // and returned similar to fields.
- (BOOL)hasExtension:(GPBExtensionDescriptor *)extension; - (BOOL)hasExtension:(GPBExtensionDescriptor *)extension;
- (id)getExtension:(GPBExtensionDescriptor *)extension; - (nullable id)getExtension:(GPBExtensionDescriptor *)extension;
- (void)setExtension:(GPBExtensionDescriptor *)extension value:(id)value; - (void)setExtension:(GPBExtensionDescriptor *)extension value:(nullable id)value;
- (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value; - (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value;
- (void)setExtension:(GPBExtensionDescriptor *)extension - (void)setExtension:(GPBExtensionDescriptor *)extension
index:(NSUInteger)index index:(NSUInteger)index
value:(id)value; value:(id)value;
- (void)clearExtension:(GPBExtensionDescriptor *)extension; - (void)clearExtension:(GPBExtensionDescriptor *)extension;
- (void)setUnknownFields:(GPBUnknownFieldSet *)unknownFields;
// Resets all fields to their default values. // Resets all fields to their default values.
- (void)clear; - (void)clear;
...@@ -166,10 +166,12 @@ CF_EXTERN_C_END ...@@ -166,10 +166,12 @@ CF_EXTERN_C_END
// message. // message.
// NOTE: This will throw if there is an error parsing the data. // NOTE: This will throw if there is an error parsing the data.
- (void)mergeFromData:(NSData *)data - (void)mergeFromData:(NSData *)data
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry; extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
// Merges the fields from another message (of the same type) into this // Merges the fields from another message (of the same type) into this
// message. // message.
- (void)mergeFrom:(GPBMessage *)other; - (void)mergeFrom:(GPBMessage *)other;
@end @end
NS_ASSUME_NONNULL_END
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
@class GPBExtensionRegistry; @class GPBExtensionRegistry;
NS_ASSUME_NONNULL_BEGIN
// All Root Objects derive from GPBRootObject. It supplies a registry // All Root Objects derive from GPBRootObject. It supplies a registry
// for derived classes to register their extensions to. // for derived classes to register their extensions to.
@interface GPBRootObject : NSObject @interface GPBRootObject : NSObject
...@@ -40,3 +42,5 @@ ...@@ -40,3 +42,5 @@
+ (GPBExtensionRegistry *)extensionRegistry; + (GPBExtensionRegistry *)extensionRegistry;
@end @end
NS_ASSUME_NONNULL_END
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#import <CoreFoundation/CoreFoundation.h> #import <CoreFoundation/CoreFoundation.h>
#import "GPBDescriptor.h" #import "GPBDescriptor.h"
#import "GPBExtensionRegistry.h"
#import "GPBUtilities_PackagePrivate.h" #import "GPBUtilities_PackagePrivate.h"
@interface GPBExtensionDescriptor (GPBRootObject) @interface GPBExtensionDescriptor (GPBRootObject)
...@@ -97,6 +98,7 @@ static CFHashCode GPBRootExtensionKeyHash(const void *value) { ...@@ -97,6 +98,7 @@ static CFHashCode GPBRootExtensionKeyHash(const void *value) {
static OSSpinLock gExtensionSingletonDictionaryLock_ = OS_SPINLOCK_INIT; static OSSpinLock gExtensionSingletonDictionaryLock_ = OS_SPINLOCK_INIT;
static CFMutableDictionaryRef gExtensionSingletonDictionary = NULL; static CFMutableDictionaryRef gExtensionSingletonDictionary = NULL;
static GPBExtensionRegistry *gDefaultExtensionRegistry = NULL;
+ (void)initialize { + (void)initialize {
// Ensure the global is started up. // Ensure the global is started up.
...@@ -113,6 +115,7 @@ static CFMutableDictionaryRef gExtensionSingletonDictionary = NULL; ...@@ -113,6 +115,7 @@ static CFMutableDictionaryRef gExtensionSingletonDictionary = NULL;
gExtensionSingletonDictionary = gExtensionSingletonDictionary =
CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallBacks, CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallBacks,
&kCFTypeDictionaryValueCallBacks); &kCFTypeDictionaryValueCallBacks);
gDefaultExtensionRegistry = [[GPBExtensionRegistry alloc] init];
} }
if ([self superclass] == [GPBRootObject class]) { if ([self superclass] == [GPBRootObject class]) {
...@@ -126,7 +129,7 @@ static CFMutableDictionaryRef gExtensionSingletonDictionary = NULL; ...@@ -126,7 +129,7 @@ static CFMutableDictionaryRef gExtensionSingletonDictionary = NULL;
+ (GPBExtensionRegistry *)extensionRegistry { + (GPBExtensionRegistry *)extensionRegistry {
// Is overridden in all the subclasses that provide extensions to provide the // Is overridden in all the subclasses that provide extensions to provide the
// per class one. // per class one.
return nil; return gDefaultExtensionRegistry;
} }
+ (void)globallyRegisterExtension:(GPBExtensionDescriptor *)field { + (void)globallyRegisterExtension:(GPBExtensionDescriptor *)field {
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
@class GPBUInt64Array; @class GPBUInt64Array;
@class GPBUnknownFieldSet; @class GPBUnknownFieldSet;
NS_ASSUME_NONNULL_BEGIN
@interface GPBUnknownField : NSObject<NSCopying> @interface GPBUnknownField : NSObject<NSCopying>
@property(nonatomic, readonly, assign) int32_t number; @property(nonatomic, readonly, assign) int32_t number;
...@@ -54,3 +56,5 @@ ...@@ -54,3 +56,5 @@
- (void)addGroup:(GPBUnknownFieldSet *)value; - (void)addGroup:(GPBUnknownFieldSet *)value;
@end @end
NS_ASSUME_NONNULL_END
...@@ -32,10 +32,12 @@ ...@@ -32,10 +32,12 @@
@class GPBUnknownField; @class GPBUnknownField;
NS_ASSUME_NONNULL_BEGIN
@interface GPBUnknownFieldSet : NSObject<NSCopying> @interface GPBUnknownFieldSet : NSObject<NSCopying>
- (BOOL)hasField:(int32_t)number; - (BOOL)hasField:(int32_t)number;
- (GPBUnknownField *)getField:(int32_t)number; - (nullable GPBUnknownField *)getField:(int32_t)number;
- (NSUInteger)countOfFields; - (NSUInteger)countOfFields;
- (void)addField:(GPBUnknownField *)field; - (void)addField:(GPBUnknownField *)field;
...@@ -44,3 +46,5 @@ ...@@ -44,3 +46,5 @@
- (NSArray *)sortedFields; - (NSArray *)sortedFields;
@end @end
NS_ASSUME_NONNULL_END
...@@ -36,13 +36,16 @@ ...@@ -36,13 +36,16 @@
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
// Generates a string that should be a valid "Text Format" for the C++ version // Generates a string that should be a valid "Text Format" for the C++ version
// of Protocol Buffers. lineIndent can be nil if no additional line indent is // of Protocol Buffers. lineIndent can be nil if no additional line indent is
// needed. The comments provide the names according to the ObjC library, they // needed. The comments provide the names according to the ObjC library, they
// most likely won't exactly match the original .proto file. // most likely won't exactly match the original .proto file.
NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *lineIndent); NSString *GPBTextFormatForMessage(GPBMessage *message,
NSString * __nullable lineIndent);
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *unknownSet, NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *unknownSet,
NSString *lineIndent); NSString * __nullable lineIndent);
// //
// Test if the given field is set on a message. // Test if the given field is set on a message.
...@@ -128,6 +131,8 @@ void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dicti ...@@ -128,6 +131,8 @@ void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dicti
// objects. // objects.
NSData *GPBEmptyNSData(void) __attribute__((pure)); NSData *GPBEmptyNSData(void) __attribute__((pure));
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
......
...@@ -1497,7 +1497,7 @@ static void AppendTextFormatForMessage(GPBMessage *message, ...@@ -1497,7 +1497,7 @@ static void AppendTextFormatForMessage(GPBMessage *message,
} }
NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *lineIndent) { NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *lineIndent) {
if (message == nil) return nil; if (message == nil) return @"";
if (lineIndent == nil) lineIndent = @""; if (lineIndent == nil) lineIndent = @"";
NSMutableString *buildString = [NSMutableString string]; NSMutableString *buildString = [NSMutableString string];
...@@ -1507,7 +1507,7 @@ NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *lineIndent) { ...@@ -1507,7 +1507,7 @@ NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *lineIndent) {
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *unknownSet, NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *unknownSet,
NSString *lineIndent) { NSString *lineIndent) {
if (unknownSet == nil) return nil; if (unknownSet == nil) return @"";
if (lineIndent == nil) lineIndent = @""; if (lineIndent == nil) lineIndent = @"";
NSMutableString *result = [NSMutableString string]; NSMutableString *result = [NSMutableString string];
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#import "google/protobuf/Timestamp.pbobjc.h" #import "google/protobuf/Timestamp.pbobjc.h"
#import "google/protobuf/Duration.pbobjc.h" #import "google/protobuf/Duration.pbobjc.h"
NS_ASSUME_NONNULL_BEGIN
// Extension to GPBTimestamp to work with standard Foundation time/date types. // Extension to GPBTimestamp to work with standard Foundation time/date types.
@interface GPBTimestamp (GBPWellKnownTypes) @interface GPBTimestamp (GBPWellKnownTypes)
@property(nonatomic, readwrite, strong) NSDate *date; @property(nonatomic, readwrite, strong) NSDate *date;
...@@ -46,3 +48,5 @@ ...@@ -46,3 +48,5 @@
@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970; @property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970;
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970; - (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970;
@end @end
NS_ASSUME_NONNULL_END
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
typedef enum { typedef enum {
GPBWireFormatVarint = 0, GPBWireFormatVarint = 0,
GPBWireFormatFixed64 = 1, GPBWireFormatFixed64 = 1,
...@@ -65,4 +67,6 @@ GPBWireFormat GPBWireFormatForType(GPBDataType dataType, BOOL isPacked) ...@@ -65,4 +67,6 @@ GPBWireFormat GPBWireFormatForType(GPBDataType dataType, BOOL isPacked)
(GPBWireFormatMakeTag(GPBWireFormatMessageSetMessage, \ (GPBWireFormatMakeTag(GPBWireFormatMessageSetMessage, \
GPBWireFormatLengthDelimited)) GPBWireFormatLengthDelimited))
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
...@@ -446,7 +446,7 @@ class GPBBridgeTests: XCTestCase { ...@@ -446,7 +446,7 @@ class GPBBridgeTests: XCTestCase {
let data = msg.data() let data = msg.data()
let msg2 = Message2(data: data, error:nil) let msg2 = Message2(data: data!, error:nil)
XCTAssertTrue(msg2 !== msg) // New instance XCTAssertTrue(msg2 !== msg) // New instance
XCTAssertEqual(msg.optionalInt32, Int32(100)) XCTAssertEqual(msg.optionalInt32, Int32(100))
XCTAssertEqual(msg.optionalInt64, Int64(101)) XCTAssertEqual(msg.optionalInt64, Int64(101))
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBAnyRoot #pragma mark - GPBAnyRoot
...@@ -88,13 +89,15 @@ typedef GPB_ENUM(GPBAny_FieldNumber) { ...@@ -88,13 +89,15 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
// namespace should use `type.googleapis.com/full.type.name` (without // namespace should use `type.googleapis.com/full.type.name` (without
// schema and path). A type service will eventually become available which // schema and path). A type service will eventually become available which
// serves those URLs (projected Q2/15). // serves those URLs (projected Q2/15).
@property(nonatomic, readwrite, copy) NSString *typeURL; @property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
// Must be valid serialized data of the above specified type. // Must be valid serialized data of the above specified type.
@property(nonatomic, readwrite, copy) NSData *value; @property(nonatomic, readwrite, copy, null_resettable) NSData *value;
@end @end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
...@@ -13,6 +13,7 @@ CF_EXTERN_C_BEGIN ...@@ -13,6 +13,7 @@ CF_EXTERN_C_BEGIN
@class GPBSourceContext; @class GPBSourceContext;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBApiRoot #pragma mark - GPBApiRoot
...@@ -40,16 +41,16 @@ typedef GPB_ENUM(GPBApi_FieldNumber) { ...@@ -40,16 +41,16 @@ typedef GPB_ENUM(GPBApi_FieldNumber) {
// The fully qualified name of this api, including package name // The fully qualified name of this api, including package name
// followed by the api's simple name. // followed by the api's simple name.
@property(nonatomic, readwrite, copy) NSString *name; @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
// The methods of this api, in unspecified order. // The methods of this api, in unspecified order.
// |methodsArray| contains |GPBMethod| // |methodsArray| contains |GPBMethod|
@property(nonatomic, readwrite, strong) NSMutableArray *methodsArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *methodsArray;
@property(nonatomic, readonly) NSUInteger methodsArray_Count; @property(nonatomic, readonly) NSUInteger methodsArray_Count;
// Any metadata attached to the API. // Any metadata attached to the API.
// |optionsArray| contains |GPBOption| // |optionsArray| contains |GPBOption|
@property(nonatomic, readwrite, strong) NSMutableArray *optionsArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
@property(nonatomic, readonly) NSUInteger optionsArray_Count; @property(nonatomic, readonly) NSUInteger optionsArray_Count;
// A version string for this api. If specified, must have the form // A version string for this api. If specified, must have the form
...@@ -74,12 +75,12 @@ typedef GPB_ENUM(GPBApi_FieldNumber) { ...@@ -74,12 +75,12 @@ typedef GPB_ENUM(GPBApi_FieldNumber) {
// experimental, none-GA apis. // experimental, none-GA apis.
// //
// See also: [design doc](http://go/api-versioning). // See also: [design doc](http://go/api-versioning).
@property(nonatomic, readwrite, copy) NSString *version; @property(nonatomic, readwrite, copy, null_resettable) NSString *version;
// Source context for the protocol buffer service represented by this // Source context for the protocol buffer service represented by this
// message. // message.
@property(nonatomic, readwrite) BOOL hasSourceContext; @property(nonatomic, readwrite) BOOL hasSourceContext;
@property(nonatomic, readwrite, strong) GPBSourceContext *sourceContext; @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
@end @end
...@@ -98,27 +99,29 @@ typedef GPB_ENUM(GPBMethod_FieldNumber) { ...@@ -98,27 +99,29 @@ typedef GPB_ENUM(GPBMethod_FieldNumber) {
@interface GPBMethod : GPBMessage @interface GPBMethod : GPBMessage
// The simple name of this method. // The simple name of this method.
@property(nonatomic, readwrite, copy) NSString *name; @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
// A URL of the input message type. // A URL of the input message type.
@property(nonatomic, readwrite, copy) NSString *requestTypeURL; @property(nonatomic, readwrite, copy, null_resettable) NSString *requestTypeURL;
// If true, the request is streamed. // If true, the request is streamed.
@property(nonatomic, readwrite) BOOL requestStreaming; @property(nonatomic, readwrite) BOOL requestStreaming;
// The URL of the output message type. // The URL of the output message type.
@property(nonatomic, readwrite, copy) NSString *responseTypeURL; @property(nonatomic, readwrite, copy, null_resettable) NSString *responseTypeURL;
// If true, the response is streamed. // If true, the response is streamed.
@property(nonatomic, readwrite) BOOL responseStreaming; @property(nonatomic, readwrite) BOOL responseStreaming;
// Any metadata attached to the method. // Any metadata attached to the method.
// |optionsArray| contains |GPBOption| // |optionsArray| contains |GPBOption|
@property(nonatomic, readwrite, strong) NSMutableArray *optionsArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
@property(nonatomic, readonly) NSUInteger optionsArray_Count; @property(nonatomic, readonly) NSUInteger optionsArray_Count;
@end @end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBDurationRoot #pragma mark - GPBDurationRoot
...@@ -86,6 +87,8 @@ typedef GPB_ENUM(GPBDuration_FieldNumber) { ...@@ -86,6 +87,8 @@ typedef GPB_ENUM(GPBDuration_FieldNumber) {
@end @end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBEmptyRoot #pragma mark - GPBEmptyRoot
...@@ -36,6 +37,8 @@ CF_EXTERN_C_BEGIN ...@@ -36,6 +37,8 @@ CF_EXTERN_C_BEGIN
@end @end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBFieldMaskRoot #pragma mark - GPBFieldMaskRoot
...@@ -151,11 +152,13 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) { ...@@ -151,11 +152,13 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) {
// The set of field mask paths. // The set of field mask paths.
// |pathsArray| contains |NSString| // |pathsArray| contains |NSString|
@property(nonatomic, readwrite, strong) NSMutableArray *pathsArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *pathsArray;
@property(nonatomic, readonly) NSUInteger pathsArray_Count; @property(nonatomic, readonly) NSUInteger pathsArray_Count;
@end @end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBSourceContextRoot #pragma mark - GPBSourceContextRoot
...@@ -35,10 +36,12 @@ typedef GPB_ENUM(GPBSourceContext_FieldNumber) { ...@@ -35,10 +36,12 @@ typedef GPB_ENUM(GPBSourceContext_FieldNumber) {
// The path-qualified name of the .proto file that contained the associated // The path-qualified name of the .proto file that contained the associated
// protobuf element. For example: `"google/protobuf/source.proto"`. // protobuf element. For example: `"google/protobuf/source.proto"`.
@property(nonatomic, readwrite, copy) NSString *fileName; @property(nonatomic, readwrite, copy, null_resettable) NSString *fileName;
@end @end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
...@@ -14,6 +14,8 @@ CF_EXTERN_C_BEGIN ...@@ -14,6 +14,8 @@ CF_EXTERN_C_BEGIN
@class GPBListValue; @class GPBListValue;
@class GPBStruct; @class GPBStruct;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Enum GPBNullValue #pragma mark - Enum GPBNullValue
// `NullValue` is a singleton enumeration to represent the null // `NullValue` is a singleton enumeration to represent the null
...@@ -28,7 +30,6 @@ GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void); ...@@ -28,7 +30,6 @@ GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void);
BOOL GPBNullValue_IsValidValue(int32_t value); BOOL GPBNullValue_IsValidValue(int32_t value);
#pragma mark - GPBStructRoot #pragma mark - GPBStructRoot
@interface GPBStructRoot : GPBRootObject @interface GPBStructRoot : GPBRootObject
...@@ -56,7 +57,7 @@ typedef GPB_ENUM(GPBStruct_FieldNumber) { ...@@ -56,7 +57,7 @@ typedef GPB_ENUM(GPBStruct_FieldNumber) {
// Map of dynamically typed values. // Map of dynamically typed values.
// |fields| values are |GPBValue| // |fields| values are |GPBValue|
@property(nonatomic, readwrite, strong) NSMutableDictionary *fields; @property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary *fields;
@property(nonatomic, readonly) NSUInteger fields_Count; @property(nonatomic, readonly) NSUInteger fields_Count;
@end @end
...@@ -97,16 +98,16 @@ typedef GPB_ENUM(GPBValue_Kind_OneOfCase) { ...@@ -97,16 +98,16 @@ typedef GPB_ENUM(GPBValue_Kind_OneOfCase) {
@property(nonatomic, readwrite) double numberValue; @property(nonatomic, readwrite) double numberValue;
// Represents a string value. // Represents a string value.
@property(nonatomic, readwrite, copy) NSString *stringValue; @property(nonatomic, readwrite, copy, null_resettable) NSString *stringValue;
// Represents a boolean value. // Represents a boolean value.
@property(nonatomic, readwrite) BOOL boolValue; @property(nonatomic, readwrite) BOOL boolValue;
// Represents a structured value. // Represents a structured value.
@property(nonatomic, readwrite, strong) GPBStruct *structValue; @property(nonatomic, readwrite, strong, null_resettable) GPBStruct *structValue;
// Represents a repeated `Value`. // Represents a repeated `Value`.
@property(nonatomic, readwrite, strong) GPBListValue *listValue; @property(nonatomic, readwrite, strong, null_resettable) GPBListValue *listValue;
@end @end
...@@ -126,11 +127,13 @@ typedef GPB_ENUM(GPBListValue_FieldNumber) { ...@@ -126,11 +127,13 @@ typedef GPB_ENUM(GPBListValue_FieldNumber) {
// Repeated field of dynamically typed values. // Repeated field of dynamically typed values.
// |valuesArray| contains |GPBValue| // |valuesArray| contains |GPBValue|
@property(nonatomic, readwrite, strong) NSMutableArray *valuesArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *valuesArray;
@property(nonatomic, readonly) NSUInteger valuesArray_Count; @property(nonatomic, readonly) NSUInteger valuesArray_Count;
@end @end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBTimestampRoot #pragma mark - GPBTimestampRoot
...@@ -97,6 +98,8 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) { ...@@ -97,6 +98,8 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
@end @end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
...@@ -14,6 +14,8 @@ CF_EXTERN_C_BEGIN ...@@ -14,6 +14,8 @@ CF_EXTERN_C_BEGIN
@class GPBAny; @class GPBAny;
@class GPBSourceContext; @class GPBSourceContext;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Enum GPBField_Kind #pragma mark - Enum GPBField_Kind
// Kind represents a basic field type. // Kind represents a basic field type.
...@@ -101,7 +103,6 @@ GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void); ...@@ -101,7 +103,6 @@ GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void);
BOOL GPBField_Cardinality_IsValidValue(int32_t value); BOOL GPBField_Cardinality_IsValidValue(int32_t value);
#pragma mark - GPBTypeRoot #pragma mark - GPBTypeRoot
@interface GPBTypeRoot : GPBRootObject @interface GPBTypeRoot : GPBRootObject
...@@ -127,27 +128,27 @@ typedef GPB_ENUM(GPBType_FieldNumber) { ...@@ -127,27 +128,27 @@ typedef GPB_ENUM(GPBType_FieldNumber) {
@interface GPBType : GPBMessage @interface GPBType : GPBMessage
// The fully qualified message name. // The fully qualified message name.
@property(nonatomic, readwrite, copy) NSString *name; @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
// The list of fields. // The list of fields.
// |fieldsArray| contains |GPBField| // |fieldsArray| contains |GPBField|
@property(nonatomic, readwrite, strong) NSMutableArray *fieldsArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *fieldsArray;
@property(nonatomic, readonly) NSUInteger fieldsArray_Count; @property(nonatomic, readonly) NSUInteger fieldsArray_Count;
// The list of oneof definitions. // The list of oneof definitions.
// The list of oneofs declared in this Type // The list of oneofs declared in this Type
// |oneofsArray| contains |NSString| // |oneofsArray| contains |NSString|
@property(nonatomic, readwrite, strong) NSMutableArray *oneofsArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *oneofsArray;
@property(nonatomic, readonly) NSUInteger oneofsArray_Count; @property(nonatomic, readonly) NSUInteger oneofsArray_Count;
// The proto options. // The proto options.
// |optionsArray| contains |GPBOption| // |optionsArray| contains |GPBOption|
@property(nonatomic, readwrite, strong) NSMutableArray *optionsArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
@property(nonatomic, readonly) NSUInteger optionsArray_Count; @property(nonatomic, readonly) NSUInteger optionsArray_Count;
// The source context. // The source context.
@property(nonatomic, readwrite) BOOL hasSourceContext; @property(nonatomic, readwrite) BOOL hasSourceContext;
@property(nonatomic, readwrite, strong) GPBSourceContext *sourceContext; @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
@end @end
...@@ -177,11 +178,11 @@ typedef GPB_ENUM(GPBField_FieldNumber) { ...@@ -177,11 +178,11 @@ typedef GPB_ENUM(GPBField_FieldNumber) {
@property(nonatomic, readwrite) int32_t number; @property(nonatomic, readwrite) int32_t number;
// The field name. // The field name.
@property(nonatomic, readwrite, copy) NSString *name; @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
// The type URL (without the scheme) when the type is MESSAGE or ENUM, // The type URL (without the scheme) when the type is MESSAGE or ENUM,
// such as `type.googleapis.com/google.protobuf.Empty`. // such as `type.googleapis.com/google.protobuf.Empty`.
@property(nonatomic, readwrite, copy) NSString *typeURL; @property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
// Index in Type.oneofs. Starts at 1. Zero means no oneof mapping. // Index in Type.oneofs. Starts at 1. Zero means no oneof mapping.
@property(nonatomic, readwrite) int32_t oneofIndex; @property(nonatomic, readwrite) int32_t oneofIndex;
...@@ -191,7 +192,7 @@ typedef GPB_ENUM(GPBField_FieldNumber) { ...@@ -191,7 +192,7 @@ typedef GPB_ENUM(GPBField_FieldNumber) {
// The proto options. // The proto options.
// |optionsArray| contains |GPBOption| // |optionsArray| contains |GPBOption|
@property(nonatomic, readwrite, strong) NSMutableArray *optionsArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
@property(nonatomic, readonly) NSUInteger optionsArray_Count; @property(nonatomic, readonly) NSUInteger optionsArray_Count;
@end @end
...@@ -215,21 +216,21 @@ typedef GPB_ENUM(GPBEnum_FieldNumber) { ...@@ -215,21 +216,21 @@ typedef GPB_ENUM(GPBEnum_FieldNumber) {
@interface GPBEnum : GPBMessage @interface GPBEnum : GPBMessage
// Enum type name. // Enum type name.
@property(nonatomic, readwrite, copy) NSString *name; @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
// Enum value definitions. // Enum value definitions.
// |enumvalueArray| contains |GPBEnumValue| // |enumvalueArray| contains |GPBEnumValue|
@property(nonatomic, readwrite, strong) NSMutableArray *enumvalueArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *enumvalueArray;
@property(nonatomic, readonly) NSUInteger enumvalueArray_Count; @property(nonatomic, readonly) NSUInteger enumvalueArray_Count;
// Proto options for the enum type. // Proto options for the enum type.
// |optionsArray| contains |GPBOption| // |optionsArray| contains |GPBOption|
@property(nonatomic, readwrite, strong) NSMutableArray *optionsArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
@property(nonatomic, readonly) NSUInteger optionsArray_Count; @property(nonatomic, readonly) NSUInteger optionsArray_Count;
// The source context. // The source context.
@property(nonatomic, readwrite) BOOL hasSourceContext; @property(nonatomic, readwrite) BOOL hasSourceContext;
@property(nonatomic, readwrite, strong) GPBSourceContext *sourceContext; @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
@end @end
...@@ -245,14 +246,14 @@ typedef GPB_ENUM(GPBEnumValue_FieldNumber) { ...@@ -245,14 +246,14 @@ typedef GPB_ENUM(GPBEnumValue_FieldNumber) {
@interface GPBEnumValue : GPBMessage @interface GPBEnumValue : GPBMessage
// Enum value name. // Enum value name.
@property(nonatomic, readwrite, copy) NSString *name; @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
// Enum value number. // Enum value number.
@property(nonatomic, readwrite) int32_t number; @property(nonatomic, readwrite) int32_t number;
// Proto options for the enum value. // Proto options for the enum value.
// |optionsArray| contains |GPBOption| // |optionsArray| contains |GPBOption|
@property(nonatomic, readwrite, strong) NSMutableArray *optionsArray; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
@property(nonatomic, readonly) NSUInteger optionsArray_Count; @property(nonatomic, readonly) NSUInteger optionsArray_Count;
@end @end
...@@ -268,14 +269,16 @@ typedef GPB_ENUM(GPBOption_FieldNumber) { ...@@ -268,14 +269,16 @@ typedef GPB_ENUM(GPBOption_FieldNumber) {
@interface GPBOption : GPBMessage @interface GPBOption : GPBMessage
// Proto option name. // Proto option name.
@property(nonatomic, readwrite, copy) NSString *name; @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
// Proto option value. // Proto option value.
@property(nonatomic, readwrite) BOOL hasValue; @property(nonatomic, readwrite) BOOL hasValue;
@property(nonatomic, readwrite, strong) GPBAny *value; @property(nonatomic, readwrite, strong, null_resettable) GPBAny *value;
@end @end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBWrappersRoot #pragma mark - GPBWrappersRoot
...@@ -131,7 +132,7 @@ typedef GPB_ENUM(GPBStringValue_FieldNumber) { ...@@ -131,7 +132,7 @@ typedef GPB_ENUM(GPBStringValue_FieldNumber) {
@interface GPBStringValue : GPBMessage @interface GPBStringValue : GPBMessage
// The string value. // The string value.
@property(nonatomic, readwrite, copy) NSString *value; @property(nonatomic, readwrite, copy, null_resettable) NSString *value;
@end @end
...@@ -145,10 +146,12 @@ typedef GPB_ENUM(GPBBytesValue_FieldNumber) { ...@@ -145,10 +146,12 @@ typedef GPB_ENUM(GPBBytesValue_FieldNumber) {
@interface GPBBytesValue : GPBMessage @interface GPBBytesValue : GPBMessage
// The bytes value. // The bytes value.
@property(nonatomic, readwrite, copy) NSData *value; @property(nonatomic, readwrite, copy, null_resettable) NSData *value;
@end @end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END CF_EXTERN_C_END
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
...@@ -331,7 +331,7 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration( ...@@ -331,7 +331,7 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration(
} }
printer->Print( printer->Print(
variables_, variables_,
"@property(nonatomic, readwrite, $property_storage_attribute$) $property_type$ *$name$$storage_attribute$;\n"); "@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$;\n");
if (IsInitName(variables_.find("name")->second)) { if (IsInitName(variables_.find("name")->second)) {
// If property name starts with init we need to annotate it to get past ARC. // If property name starts with init we need to annotate it to get past ARC.
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227 // http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
...@@ -379,7 +379,7 @@ void RepeatedFieldGenerator::GeneratePropertyDeclaration( ...@@ -379,7 +379,7 @@ void RepeatedFieldGenerator::GeneratePropertyDeclaration(
variables_, variables_,
"$comments$" "$comments$"
"$array_comment$" "$array_comment$"
"@property(nonatomic, readwrite, strong) $array_storage_type$ *$name$$storage_attribute$;\n" "@property(nonatomic, readwrite, strong, null_resettable) $array_storage_type$ *$name$$storage_attribute$;\n"
"@property(nonatomic, readonly) NSUInteger $name$_Count;\n"); "@property(nonatomic, readonly) NSUInteger $name$_Count;\n");
if (IsInitName(variables_.find("name")->second)) { if (IsInitName(variables_.find("name")->second)) {
// If property name starts with init we need to annotate it to get past ARC. // If property name starts with init we need to annotate it to get past ARC.
......
...@@ -117,10 +117,10 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { ...@@ -117,10 +117,10 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
printer->Print( printer->Print(
"// @@protoc_insertion_point(imports)\n" "// @@protoc_insertion_point(imports)\n"
"\n"
"CF_EXTERN_C_BEGIN\n"
"\n"); "\n");
printer->Print("CF_EXTERN_C_BEGIN\n\n");
set<string> fwd_decls; set<string> fwd_decls;
for (vector<MessageGenerator *>::iterator iter = message_generators_.begin(); for (vector<MessageGenerator *>::iterator iter = message_generators_.begin();
iter != message_generators_.end(); ++iter) { iter != message_generators_.end(); ++iter) {
...@@ -134,6 +134,10 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { ...@@ -134,6 +134,10 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
printer->Print("\n"); printer->Print("\n");
} }
printer->Print(
"NS_ASSUME_NONNULL_BEGIN\n"
"\n");
// need to write out all enums first // need to write out all enums first
for (vector<EnumGenerator *>::iterator iter = enum_generators_.begin(); for (vector<EnumGenerator *>::iterator iter = enum_generators_.begin();
iter != enum_generators_.end(); ++iter) { iter != enum_generators_.end(); ++iter) {
...@@ -148,7 +152,6 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { ...@@ -148,7 +152,6 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
// For extensions to chain together, the Root gets created even if there // For extensions to chain together, the Root gets created even if there
// are no extensions. // are no extensions.
printer->Print( printer->Print(
"\n"
"#pragma mark - $root_class_name$\n" "#pragma mark - $root_class_name$\n"
"\n" "\n"
"@interface $root_class_name$ : GPBRootObject\n" "@interface $root_class_name$ : GPBRootObject\n"
...@@ -182,9 +185,10 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { ...@@ -182,9 +185,10 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
(*iter)->GenerateMessageHeader(printer); (*iter)->GenerateMessageHeader(printer);
} }
printer->Print("CF_EXTERN_C_END\n");
printer->Print( printer->Print(
"NS_ASSUME_NONNULL_END\n"
"\n"
"CF_EXTERN_C_END\n"
"\n" "\n"
"// @@protoc_insertion_point(global_scope)\n"); "// @@protoc_insertion_point(global_scope)\n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment