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 ...@@ -97,7 +97,7 @@ CF_EXTERN_C_END
/// the data can not be parsed. /// the data can not be parsed.
/// ///
/// @return A new instance of the class messaged. /// @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 /// 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 /// the generated message class that the data should be interpreted as. If
...@@ -116,7 +116,7 @@ CF_EXTERN_C_END ...@@ -116,7 +116,7 @@ CF_EXTERN_C_END
/// reason if the data can not be parsed. /// reason if the data can not be parsed.
/// ///
/// @return A new instance of the class messaged. /// @return A new instance of the class messaged.
+ (instancetype)parseFromData:(NSData *)data + (nullable instancetype)parseFromData:(NSData *)data
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr; error:(NSError **)errorPtr;
...@@ -137,7 +137,7 @@ CF_EXTERN_C_END ...@@ -137,7 +137,7 @@ CF_EXTERN_C_END
/// reason if the data can not be parsed. /// reason if the data can not be parsed.
/// ///
/// @return A new instance of the class messaged. /// @return A new instance of the class messaged.
+ (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input + (nullable instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry: extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry (nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr; error:(NSError **)errorPtr;
...@@ -160,7 +160,7 @@ CF_EXTERN_C_END ...@@ -160,7 +160,7 @@ CF_EXTERN_C_END
/// reason if the data can not be parsed. /// reason if the data can not be parsed.
/// ///
/// @return A new instance of the class messaged. /// @return A new instance of the class messaged.
+ (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input + (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry: extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry (nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr; error:(NSError **)errorPtr;
...@@ -179,7 +179,7 @@ CF_EXTERN_C_END ...@@ -179,7 +179,7 @@ CF_EXTERN_C_END
/// @param data The data to parse. /// @param data The data to parse.
/// @param errorPtr An optional error pointer to fill in with a failure reason if /// @param errorPtr An optional error pointer to fill in with a failure reason if
/// the data can not be parsed. /// 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 /// 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 /// the generated message class that the data should be interpreted as. If
...@@ -196,7 +196,7 @@ CF_EXTERN_C_END ...@@ -196,7 +196,7 @@ CF_EXTERN_C_END
/// @param extensionRegistry The extension registry to use to look up extensions. /// @param extensionRegistry The extension registry to use to look up extensions.
/// @param errorPtr An optional error pointer to fill in with a failure /// @param errorPtr An optional error pointer to fill in with a failure
/// reason if the data can not be parsed. /// reason if the data can not be parsed.
- (instancetype)initWithData:(NSData *)data - (nullable instancetype)initWithData:(NSData *)data
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr; error:(NSError **)errorPtr;
...@@ -216,7 +216,7 @@ CF_EXTERN_C_END ...@@ -216,7 +216,7 @@ CF_EXTERN_C_END
/// @param extensionRegistry The extension registry to use to look up extensions. /// @param extensionRegistry The extension registry to use to look up extensions.
/// @param errorPtr An optional error pointer to fill in with a failure /// @param errorPtr An optional error pointer to fill in with a failure
/// reason if the data can not be parsed. /// reason if the data can not be parsed.
- (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input - (nullable instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry: extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry (nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr; error:(NSError **)errorPtr;
......
...@@ -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 = try! Message2(data: data!)
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))
......
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