Commit ec458973 authored by Thomas Van Lenten's avatar Thomas Van Lenten Committed by GitHub

Merge pull request #1712 from dkharrat/swift-error-handling

add nullable qualifier to return types that can be nil, to support Swift 2 try-catch syntax
parents cae3b0cb 523bfd4f
......@@ -97,7 +97,7 @@ CF_EXTERN_C_END
/// the data can not be parsed.
///
/// @return A new instance of the class messaged.
+ (instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr;
+ (nullable instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr;
/// Creates a new instance by parsing the data. This method should be sent to
/// the generated message class that the data should be interpreted as. If
......@@ -116,7 +116,7 @@ CF_EXTERN_C_END
/// reason if the data can not be parsed.
///
/// @return A new instance of the class messaged.
+ (instancetype)parseFromData:(NSData *)data
+ (nullable instancetype)parseFromData:(NSData *)data
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
......@@ -137,7 +137,7 @@ CF_EXTERN_C_END
/// reason if the data can not be parsed.
///
/// @return A new instance of the class messaged.
+ (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
+ (nullable instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
......@@ -160,7 +160,7 @@ CF_EXTERN_C_END
/// reason if the data can not be parsed.
///
/// @return A new instance of the class messaged.
+ (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
+ (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
......@@ -179,7 +179,7 @@ CF_EXTERN_C_END
/// @param data The data to parse.
/// @param errorPtr An optional error pointer to fill in with a failure reason if
/// the data can not be parsed.
- (instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr;
- (nullable instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr;
/// Initializes an instance by parsing the data. This method should be sent to
/// the generated message class that the data should be interpreted as. If
......@@ -196,7 +196,7 @@ CF_EXTERN_C_END
/// @param extensionRegistry The extension registry to use to look up extensions.
/// @param errorPtr An optional error pointer to fill in with a failure
/// reason if the data can not be parsed.
- (instancetype)initWithData:(NSData *)data
- (nullable instancetype)initWithData:(NSData *)data
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
......@@ -216,7 +216,7 @@ CF_EXTERN_C_END
/// @param extensionRegistry The extension registry to use to look up extensions.
/// @param errorPtr An optional error pointer to fill in with a failure
/// reason if the data can not be parsed.
- (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
- (nullable instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
......
......@@ -446,7 +446,7 @@ class GPBBridgeTests: XCTestCase {
let data = msg.data()
let msg2 = Message2(data: data!, error:nil)
let msg2 = try! Message2(data: data!)
XCTAssertTrue(msg2 !== msg) // New instance
XCTAssertEqual(msg.optionalInt32, Int32(100))
XCTAssertEqual(msg.optionalInt64, Int64(101))
......
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