Polish nullabitily

pull/16190/head
Muxi Yan 6 years ago
parent 1cbb484729
commit 3c33020357
  1. 4
      src/objective-c/GRPCClient/private/GRPCChannelFactory.h
  2. 8
      src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h
  3. 14
      src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m
  4. 8
      src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h
  5. 6
      src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m
  6. 12
      src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h
  7. 18
      src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m

@ -26,8 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
@protocol GRPCChannelFactory
/** Create a channel with specific channel args to a specific host. */
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
channelArgs:(nullable NSDictionary *)args;
- (grpc_channel * _Nullable)createChannelWithHost:(NSString *)host
channelArgs:(NSDictionary * _Nullable)args;
@end

@ -24,12 +24,12 @@ NS_ASSUME_NONNULL_BEGIN
@interface GRPCCronetChannelFactory : NSObject<GRPCChannelFactory>
+ (nullable instancetype)sharedInstance;
+ (instancetype _Nullable)sharedInstance;
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
channelArgs:(nullable NSDictionary *)args;
- (grpc_channel * _Nullable)createChannelWithHost:(NSString *)host
channelArgs:(NSDictionary * _Nullable)args;
- (nullable instancetype)init NS_UNAVAILABLE;
- (instancetype _Nullable)init NS_UNAVAILABLE;
@end

@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
stream_engine *_cronetEngine;
}
+ (nullable instancetype)sharedInstance {
+ (instancetype _Nullable)sharedInstance {
static GRPCCronetChannelFactory *instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
@ -41,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
return instance;
}
- (nullable instancetype)initWithEngine:(stream_engine *)engine {
- (instancetype _Nullable)initWithEngine:(stream_engine *)engine {
if (!engine) {
[NSException raise:NSInvalidArgumentException format:@"Cronet engine is NULL. Set it first."];
return nil;
@ -52,8 +52,8 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
channelArgs:(NSDictionary *)args {
- (grpc_channel * _Nullable)createChannelWithHost:(NSString *)host
channelArgs:(NSDictionary * _Nullable)args {
// Remove client authority filter since that is not supported
args[@GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER] = [NSNumber numberWithInt:1];
@ -74,14 +74,14 @@ NS_ASSUME_NONNULL_BEGIN
@implementation GRPCCronetChannelFactory
+ (nullable instancetype)sharedInstance {
+ (instancetype _Nullable)sharedInstance {
[NSException raise:NSInvalidArgumentException
format:@"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."];
return nil;
}
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
channelArgs:(nullable NSDictionary *)args {
- (grpc_channel * _Nullable)createChannelWithHost:(NSString *)host
channelArgs:(NSDictionary * _Nullable)args {
[NSException raise:NSInvalidArgumentException
format:@"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."];
return NULL;

@ -23,12 +23,12 @@ NS_ASSUME_NONNULL_BEGIN
@interface GRPCInsecureChannelFactory : NSObject<GRPCChannelFactory>
+ (nullable instancetype)sharedInstance;
+ (instancetype _Nullable)sharedInstance;
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
channelArgs:(nullable NSDictionary *)args;
- (grpc_channel * _Nullable)createChannelWithHost:(NSString *)host
channelArgs:(NSDictionary * _Nullable)args;
- (nullable instancetype)init NS_UNAVAILABLE;
- (instancetype _Nullable)init NS_UNAVAILABLE;
@end

@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation GRPCInsecureChannelFactory
+ (nullable instancetype)sharedInstance {
+ (instancetype _Nullable)sharedInstance {
static GRPCInsecureChannelFactory *instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
@ -34,8 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
return instance;
}
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
channelArgs:(nullable NSDictionary *)args {
- (grpc_channel * _Nullable)createChannelWithHost:(NSString *)host
channelArgs:(NSDictionary * _Nullable)args {
grpc_channel_args *coreChannelArgs = GRPCBuildChannelArgs([args copy]);
grpc_channel *unmanagedChannel =
grpc_insecure_channel_create(host.UTF8String, coreChannelArgs, NULL);

@ -23,15 +23,15 @@ NS_ASSUME_NONNULL_BEGIN
@interface GRPCSecureChannelFactory : NSObject<GRPCChannelFactory>
+ (nullable instancetype)factoryWithPEMRootCertificates:(nullable NSString *)rootCerts
privateKey:(nullable NSString *)privateKey
certChain:(nullable NSString *)certChain
+ (instancetype _Nullable)factoryWithPEMRootCertificates:(NSString * _Nullable)rootCerts
privateKey:(NSString * _Nullable)privateKey
certChain:(NSString * _Nullable)certChain
error:(NSError **)errorPtr;
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
channelArgs:(nullable NSDictionary *)args;
- (grpc_channel * _Nullable)createChannelWithHost:(NSString *)host
channelArgs:(NSDictionary * _Nullable)args;
- (nullable instancetype)init NS_UNAVAILABLE;
- (instancetype _Nullable)init NS_UNAVAILABLE;
@end

@ -29,9 +29,9 @@ NS_ASSUME_NONNULL_BEGIN
grpc_channel_credentials *_channelCreds;
}
+ (nullable instancetype)factoryWithPEMRootCertificates:(nullable NSString *)rootCerts
privateKey:(nullable NSString *)privateKey
certChain:(nullable NSString *)certChain
+ (instancetype _Nullable)factoryWithPEMRootCertificates:(NSString * _Nullable)rootCerts
privateKey:(NSString * _Nullable)privateKey
certChain:(NSString * _Nullable)certChain
error:(NSError **)errorPtr {
return [[self alloc] initWithPEMRootCerts:rootCerts
privateKey:privateKey
@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
error:errorPtr];
}
- (NSData *)nullTerminatedDataWithString:(NSString *)string {
- (NSData * _Nullable)nullTerminatedDataWithString:(NSString * _Nullable)string {
// dataUsingEncoding: does not return a null-terminated string.
NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
if (data == nil) {
@ -50,9 +50,9 @@ NS_ASSUME_NONNULL_BEGIN
return nullTerminated;
}
- (nullable instancetype)initWithPEMRootCerts:(nullable NSString *)rootCerts
privateKey:(nullable NSString *)privateKey
certChain:(nullable NSString *)certChain
- (instancetype _Nullable)initWithPEMRootCerts:(NSString * _Nullable)rootCerts
privateKey:(NSString * _Nullable)privateKey
certChain:(NSString * _Nullable)certChain
error:(NSError **)errorPtr {
static NSData *defaultRootsASCII;
static NSError *defaultRootsError;
@ -116,8 +116,8 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
channelArgs:(nullable NSDictionary *)args {
- (grpc_channel * _Nullable)createChannelWithHost:(NSString *)host
channelArgs:(NSDictionary * _Nullable)args {
grpc_channel_args *coreChannelArgs = GRPCBuildChannelArgs([args copy]);
grpc_channel *unmanagedChannel =
grpc_secure_channel_create(_channelCreds, host.UTF8String, coreChannelArgs, NULL);

Loading…
Cancel
Save