aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/private
diff options
context:
space:
mode:
Diffstat (limited to 'src/objective-c/GRPCClient/private')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.h6
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m50
-rw-r--r--src/objective-c/GRPCClient/private/GRPCCompletionQueue.h2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCCompletionQueue.m5
-rw-r--r--src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h5
-rw-r--r--src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m11
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.h1
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.m56
-rw-r--r--src/objective-c/GRPCClient/private/GRPCOpBatchLog.h1
-rw-r--r--src/objective-c/GRPCClient/private/GRPCOpBatchLog.m6
-rw-r--r--src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h6
-rw-r--r--src/objective-c/GRPCClient/private/GRPCRequestHeaders.m20
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.h17
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m77
-rw-r--r--src/objective-c/GRPCClient/private/NSData+GRPC.m10
-rw-r--r--src/objective-c/GRPCClient/private/NSDictionary+GRPC.m5
-rw-r--r--src/objective-c/GRPCClient/private/NSError+GRPC.m4
-rw-r--r--src/objective-c/GRPCClient/private/version.h1
18 files changed, 130 insertions, 153 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.h b/src/objective-c/GRPCClient/private/GRPCChannel.h
index d37182f754..6499d4398c 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.h
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.h
@@ -23,7 +23,6 @@
@class GRPCCompletionQueue;
struct grpc_channel_credentials;
-
/**
* Each separate instance of this class represents at least one TCP connection to the provided host.
*/
@@ -52,8 +51,9 @@ struct grpc_channel_credentials;
* @c channelArgs. Only in tests should @c GRPC_SSL_TARGET_NAME_OVERRIDE_ARG channel arg be set.
*/
+ (nonnull GRPCChannel *)secureChannelWithHost:(nonnull NSString *)host
- credentials:(nonnull struct grpc_channel_credentials *)credentials
- channelArgs:(nullable NSDictionary *)channelArgs;
+ credentials:
+ (nonnull struct grpc_channel_credentials *)credentials
+ channelArgs:(nullable NSDictionary *)channelArgs;
/**
* Creates an insecure channel to the specified @c host using the specified @c channelArgs.
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index b53d84159d..a49a489ea8 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -32,7 +32,7 @@
#endif
#import "GRPCCompletionQueue.h"
-static void* copy_pointer_arg(void *p) {
+static void *copy_pointer_arg(void *p) {
// Add ref count to the object when making copy
id obj = (__bridge id)p;
return (__bridge_retained void *)obj;
@@ -43,12 +43,10 @@ static void destroy_pointer_arg(void *p) {
CFRelease((CFTreeRef)p);
}
-static int cmp_pointer_arg(void *p, void *q) {
- return p == q;
-}
+static int cmp_pointer_arg(void *p, void *q) { return p == q; }
-static const grpc_arg_pointer_vtable objc_arg_vtable = {
- copy_pointer_arg, destroy_pointer_arg, cmp_pointer_arg};
+static const grpc_arg_pointer_vtable objc_arg_vtable = {copy_pointer_arg, destroy_pointer_arg,
+ cmp_pointer_arg};
static void FreeChannelArgs(grpc_channel_args *channel_args) {
for (size_t i = 0; i < channel_args->num_args; ++i) {
@@ -124,10 +122,8 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) {
if (self = [super init]) {
_channelArgs = BuildChannelArgs(channelArgs);
_host = [host copy];
- _unmanagedChannel = grpc_cronet_secure_channel_create(cronetEngine,
- _host.UTF8String,
- _channelArgs,
- NULL);
+ _unmanagedChannel =
+ grpc_cronet_secure_channel_create(cronetEngine, _host.UTF8String, _channelArgs, NULL);
}
return self;
@@ -150,8 +146,8 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) {
_channelArgs = BuildChannelArgs(channelArgs);
_host = [host copy];
if (secure) {
- _unmanagedChannel = grpc_secure_channel_create(credentials, _host.UTF8String, _channelArgs,
- NULL);
+ _unmanagedChannel =
+ grpc_secure_channel_create(credentials, _host.UTF8String, _channelArgs, NULL);
} else {
_unmanagedChannel = grpc_insecure_channel_create(_host.UTF8String, _channelArgs, NULL);
}
@@ -172,8 +168,7 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) {
channelArgs:(NSDictionary *)channelArgs {
stream_engine *engine = [GRPCCall cronetEngine];
if (!engine) {
- [NSException raise:NSInvalidArgumentException
- format:@"cronet_engine is NULL. Set it first."];
+ [NSException raise:NSInvalidArgumentException format:@"cronet_engine is NULL. Set it first."];
return nil;
}
return [[GRPCChannel alloc] initWithHost:host cronetEngine:engine channelArgs:channelArgs];
@@ -191,15 +186,10 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) {
secure:YES
credentials:credentials
channelArgs:channelArgs];
-
}
-+ (GRPCChannel *)insecureChannelWithHost:(NSString *)host
- channelArgs:(NSDictionary *)channelArgs {
- return [[GRPCChannel alloc] initWithHost:host
- secure:NO
- credentials:NULL
- channelArgs:channelArgs];
++ (GRPCChannel *)insecureChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)channelArgs {
+ return [[GRPCChannel alloc] initWithHost:host secure:NO credentials:NULL channelArgs:channelArgs];
}
- (grpc_call *)unmanagedCallWithPath:(NSString *)path
@@ -215,17 +205,13 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) {
host_slice = grpc_slice_from_copied_string(serverName.UTF8String);
}
grpc_slice path_slice = grpc_slice_from_copied_string(path.UTF8String);
- gpr_timespec deadline_ms = timeout == 0 ?
- gpr_inf_future(GPR_CLOCK_REALTIME) :
- gpr_time_add(
- gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_millis((int64_t)(timeout * 1000), GPR_TIMESPAN));
- grpc_call *call = grpc_channel_create_call(_unmanagedChannel,
- NULL, GRPC_PROPAGATE_DEFAULTS,
- queue.unmanagedQueue,
- path_slice,
- serverName ? &host_slice : NULL,
- deadline_ms, NULL);
+ gpr_timespec deadline_ms =
+ timeout == 0 ? gpr_inf_future(GPR_CLOCK_REALTIME)
+ : gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_millis((int64_t)(timeout * 1000), GPR_TIMESPAN));
+ grpc_call *call = grpc_channel_create_call(_unmanagedChannel, NULL, GRPC_PROPAGATE_DEFAULTS,
+ queue.unmanagedQueue, path_slice,
+ serverName ? &host_slice : NULL, deadline_ms, NULL);
if (serverName) {
grpc_slice_unref(host_slice);
}
diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h
index 41f5da3dfc..5b017b45e6 100644
--- a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h
+++ b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h
@@ -19,7 +19,7 @@
#import <Foundation/Foundation.h>
#include <grpc/grpc.h>
-typedef void(^GRPCQueueCompletionHandler)(bool success);
+typedef void (^GRPCQueueCompletionHandler)(bool success);
/**
* This class lets one more easily use |grpc_completion_queue|. To use it, pass the value of the
diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m
index 7ba197810e..57dbde8d04 100644
--- a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m
+++ b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m
@@ -53,9 +53,8 @@
dispatch_async(gDefaultConcurrentQueue, ^{
while (YES) {
// The following call blocks until an event is available.
- grpc_event event = grpc_completion_queue_next(unmanagedQueue,
- gpr_inf_future(GPR_CLOCK_REALTIME),
- NULL);
+ grpc_event event =
+ grpc_completion_queue_next(unmanagedQueue, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
GRPCQueueCompletionHandler handler;
switch (event.type) {
case GRPC_OP_COMPLETE:
diff --git a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h
index 394d21792d..d4b49b1b28 100644
--- a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h
+++ b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h
@@ -26,7 +26,7 @@ typedef NS_ENUM(NSInteger, GRPCConnectivityStatus) {
GRPCConnectivityWiFi = 3,
};
-extern NSString * _Nonnull kGRPCConnectivityNotification;
+extern NSString* _Nonnull kGRPCConnectivityNotification;
// This interface monitors OS reachability interface for any network status
// change. Parties interested in these events should register themselves as
@@ -39,8 +39,7 @@ extern NSString * _Nonnull kGRPCConnectivityNotification;
// must have a notification method with one parameter of type
// (NSNotification *) and should pass it to parameter \a selector. The
// parameter of this notification method is not used for now.
-+ (void)registerObserver:(_Nonnull id)observer
- selector:(_Nonnull SEL)selector;
++ (void)registerObserver:(_Nonnull id)observer selector:(_Nonnull SEL)selector;
// Ungegister an object from observers of network status change.
+ (void)unregisterObserver:(_Nonnull id)observer;
diff --git a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
index 7f31c7e23e..a36788b35a 100644
--- a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
+++ b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
@@ -41,8 +41,8 @@ GRPCConnectivityStatus CalculateConnectivityStatus(SCNetworkReachabilityFlags fl
return result;
}
-static void ReachabilityCallback(
- SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) {
+static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags,
+ void *info) {
GRPCConnectivityStatus newStatus = CalculateConnectivityStatus(flags);
if (newStatus != currentStatus) {
@@ -69,15 +69,14 @@ static void ReachabilityCallback(
SCNetworkReachabilityContext context = {0, (__bridge void *)(self), NULL, NULL, NULL};
if (!SCNetworkReachabilitySetCallback(reachability, ReachabilityCallback, &context) ||
- !SCNetworkReachabilityScheduleWithRunLoop(
- reachability, CFRunLoopGetMain(), kCFRunLoopCommonModes)) {
+ !SCNetworkReachabilityScheduleWithRunLoop(reachability, CFRunLoopGetMain(),
+ kCFRunLoopCommonModes)) {
NSLog(@"gRPC connectivity monitor fail to set");
}
}
}
-+ (void)registerObserver:(_Nonnull id)observer
- selector:(SEL)selector {
++ (void)registerObserver:(_Nonnull id)observer selector:(SEL)selector {
[[NSNotificationCenter defaultCenter] addObserver:observer
selector:selector
name:kGRPCConnectivityNotification
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCHost.h
index a1d2e5fcdd..6697f61be4 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.h
+++ b/src/objective-c/GRPCClient/private/GRPCHost.h
@@ -47,7 +47,6 @@ struct grpc_channel_credentials;
/** The default response size limit is 4MB. Set this to override that default. */
@property(nonatomic, strong, nullable) NSNumber *responseSizeLimitOverride;
-
- (nullable instancetype)init NS_UNAVAILABLE;
/** Host objects initialized with the same address are the same. */
+ (nullable instancetype)hostWithAddress:(NSString *)address;
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m
index 152c3d3ed6..283306262a 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.m
+++ b/src/objective-c/GRPCClient/private/GRPCHost.m
@@ -18,10 +18,10 @@
#import "GRPCHost.h"
+#import <GRPCClient/GRPCCall+MobileLog.h>
+#import <GRPCClient/GRPCCall.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
-#import <GRPCClient/GRPCCall.h>
-#import <GRPCClient/GRPCCall+MobileLog.h>
#ifdef GRPC_COMPILE_WITH_CRONET
#import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Cronet.h>
@@ -91,16 +91,15 @@ static NSMutableDictionary *kHostCache;
+ (void)flushChannelCache {
@synchronized(kHostCache) {
- [kHostCache enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key,
- GRPCHost * _Nonnull host,
- BOOL * _Nonnull stop) {
+ [kHostCache enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, GRPCHost *_Nonnull host,
+ BOOL *_Nonnull stop) {
[host disconnect];
}];
}
}
+ (void)resetAllHostSettings {
- @synchronized (kHostCache) {
+ @synchronized(kHostCache) {
kHostCache = [NSMutableDictionary dictionary];
}
}
@@ -131,38 +130,38 @@ static NSMutableDictionary *kHostCache;
static NSError *kDefaultRootsError;
static dispatch_once_t loading;
dispatch_once(&loading, ^{
- NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem
+ NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem
// Do not use NSBundle.mainBundle, as it's nil for tests of library projects.
NSBundle *bundle = [NSBundle bundleForClass:self.class];
NSString *path = [bundle pathForResource:defaultPath ofType:@"pem"];
NSError *error;
// Files in PEM format can have non-ASCII characters in their comments (e.g. for the name of the
// issuer). Load them as UTF8 and produce an ASCII equivalent.
- NSString *contentInUTF8 = [NSString stringWithContentsOfFile:path
- encoding:NSUTF8StringEncoding
- error:&error];
+ NSString *contentInUTF8 =
+ [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
if (contentInUTF8 == nil) {
kDefaultRootsError = error;
return;
}
- kDefaultRootsASCII = [contentInUTF8 dataUsingEncoding:NSASCIIStringEncoding
- allowLossyConversion:YES];
+ kDefaultRootsASCII =
+ [contentInUTF8 dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
});
NSData *rootsASCII;
if (pemRootCerts != nil) {
- rootsASCII = [pemRootCerts dataUsingEncoding:NSASCIIStringEncoding
- allowLossyConversion:YES];
+ rootsASCII = [pemRootCerts dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
} else {
if (kDefaultRootsASCII == nil) {
if (errorPtr) {
*errorPtr = kDefaultRootsError;
}
- NSAssert(kDefaultRootsASCII, @"Could not read gRPCCertificates.bundle/roots.pem. This file, "
- "with the root certificates, is needed to establish secure (TLS) connections. "
- "Because the file is distributed with the gRPC library, this error is usually a sign "
- "that the library wasn't configured correctly for your project. Error: %@",
- kDefaultRootsError);
+ NSAssert(
+ kDefaultRootsASCII,
+ @"Could not read gRPCCertificates.bundle/roots.pem. This file, "
+ "with the root certificates, is needed to establish secure (TLS) connections. "
+ "Because the file is distributed with the gRPC library, this error is usually a sign "
+ "that the library wasn't configured correctly for your project. Error: %@",
+ kDefaultRootsError);
return NO;
}
rootsASCII = kDefaultRootsASCII;
@@ -173,10 +172,10 @@ static NSMutableDictionary *kHostCache;
creds = grpc_ssl_credentials_create(rootsASCII.bytes, NULL, NULL);
} else {
grpc_ssl_pem_key_cert_pair key_cert_pair;
- NSData *privateKeyASCII = [pemPrivateKey dataUsingEncoding:NSASCIIStringEncoding
- allowLossyConversion:YES];
- NSData *certChainASCII = [pemCertChain dataUsingEncoding:NSASCIIStringEncoding
- allowLossyConversion:YES];
+ NSData *privateKeyASCII =
+ [pemPrivateKey dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
+ NSData *certChainASCII =
+ [pemCertChain dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
key_cert_pair.private_key = privateKeyASCII.bytes;
key_cert_pair.cert_chain = certChainASCII.bytes;
creds = grpc_ssl_credentials_create(rootsASCII.bytes, &key_cert_pair, NULL);
@@ -212,8 +211,7 @@ static NSMutableDictionary *kHostCache;
}
if (_compressAlgorithm != GRPC_COMPRESS_NONE) {
- args[@GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM] =
- [NSNumber numberWithInt:_compressAlgorithm];
+ args[@GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM] = [NSNumber numberWithInt:_compressAlgorithm];
}
if (_keepaliveInterval != 0) {
@@ -247,14 +245,12 @@ static NSMutableDictionary *kHostCache;
}
#ifdef GRPC_COMPILE_WITH_CRONET
if (useCronet) {
- channel = [GRPCChannel secureCronetChannelWithHost:_address
- channelArgs:args];
+ channel = [GRPCChannel secureCronetChannelWithHost:_address channelArgs:args];
} else
#endif
{
- channel = [GRPCChannel secureChannelWithHost:_address
- credentials:_channelCreds
- channelArgs:args];
+ channel =
+ [GRPCChannel secureChannelWithHost:_address credentials:_channelCreds channelArgs:args];
}
}
return channel;
diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h
index ca4b6c5885..700d19a206 100644
--- a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h
+++ b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h
@@ -16,7 +16,6 @@
*
*/
-
#ifdef GRPC_TEST_OBJC
/**
diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m
index fdf0fcd25e..008232464d 100644
--- a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m
+++ b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m
@@ -25,7 +25,7 @@ static NSMutableArray *opBatchLog = nil;
@implementation GRPCOpBatchLog
+ (void)enableOpBatchLog:(BOOL)enabled {
- @synchronized (opBatchLog) {
+ @synchronized(opBatchLog) {
if (enabled) {
if (!opBatchLog) {
opBatchLog = [NSMutableArray array];
@@ -39,13 +39,13 @@ static NSMutableArray *opBatchLog = nil;
}
+ (void)addOpBatchToLog:(NSArray *)batch {
- @synchronized (opBatchLog) {
+ @synchronized(opBatchLog) {
[opBatchLog addObject:batch];
}
}
+ (NSArray *)obtainAndCleanOpBatchLog {
- @synchronized (opBatchLog) {
+ @synchronized(opBatchLog) {
NSArray *out = opBatchLog;
opBatchLog = [NSMutableArray array];
return out;
diff --git a/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h b/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h
index 9e32fb5df8..2e8e34ee30 100644
--- a/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h
+++ b/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h
@@ -17,7 +17,8 @@
*/
/**
- * "X-macro" file that lists the flags names of Apple's Network Reachability API, along with a nice
+ * "X-macro" file that lists the flags names of Apple's Network Reachability
+API, along with a nice
* Objective-C method name used to query each of them.
*
* Example usage: To generate a dictionary from flag value to name, one can do:
@@ -29,7 +30,8 @@
#undef GRPC_XMACRO_ITEM
};
- XCTAssertEqualObjects(flagNames[@(kSCNetworkReachabilityFlagsIsWWAN)], @"isCell");
+ XCTAssertEqualObjects(flagNames[@(kSCNetworkReachabilityFlagsIsWWAN)],
+@"isCell");
*/
diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
index 5de1d8fff5..fa4f022ff0 100644
--- a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
+++ b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
@@ -23,7 +23,7 @@
#import "NSDictionary+GRPC.h"
// Used by the setter.
-static void CheckIsNonNilASCII(NSString *name, NSString* value) {
+static void CheckIsNonNilASCII(NSString *name, NSString *value) {
if (!value) {
[NSException raise:NSInvalidArgumentException format:@"%@ cannot be nil", name];
}
@@ -38,14 +38,18 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
if ([key hasSuffix:@"-bin"]) {
if (![value isKindOfClass:NSData.class]) {
[NSException raise:NSInvalidArgumentException
- format:@"Expected NSData value for header %@ ending in \"-bin\", "
- @"instead got %@", key, value];
+ format:
+ @"Expected NSData value for header %@ ending in \"-bin\", "
+ @"instead got %@",
+ key, value];
}
} else {
if (![value isKindOfClass:NSString.class]) {
[NSException raise:NSInvalidArgumentException
- format:@"Expected NSString value for header %@ not ending in \"-bin\", "
- @"instead got %@", key, value];
+ format:
+ @"Expected NSString value for header %@ not ending in \"-bin\", "
+ @"instead got %@",
+ key, value];
}
CheckIsNonNilASCII(@"Text header value", (NSString *)value);
}
@@ -85,8 +89,8 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
return self;
}
-- (instancetype)initWithObjects:(const id _Nonnull __unsafe_unretained *)objects
- forKeys:(const id<NSCopying> _Nonnull __unsafe_unretained *)keys
+- (instancetype)initWithObjects:(const id _Nonnull __unsafe_unretained *)objects
+ forKeys:(const id<NSCopying> _Nonnull __unsafe_unretained *)keys
count:(NSUInteger)cnt {
return [self init];
}
@@ -118,7 +122,7 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
return _delegate.count;
}
-- (NSEnumerator * _Nonnull)keyEnumerator {
+- (NSEnumerator *_Nonnull)keyEnumerator {
return [_delegate keyEnumerator];
}
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
index f569895e7c..f711850c2f 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
@@ -29,43 +29,42 @@
@interface GRPCOpSendMetadata : GRPCOperation
-- (instancetype)initWithMetadata:(NSDictionary *)metadata
- handler:(void(^)(void))handler;
+- (instancetype)initWithMetadata:(NSDictionary *)metadata handler:(void (^)(void))handler;
- (instancetype)initWithMetadata:(NSDictionary *)metadata
flags:(uint32_t)flags
- handler:(void(^)(void))handler NS_DESIGNATED_INITIALIZER;
+ handler:(void (^)(void))handler NS_DESIGNATED_INITIALIZER;
@end
@interface GRPCOpSendMessage : GRPCOperation
- (instancetype)initWithMessage:(NSData *)message
- handler:(void(^)(void))handler NS_DESIGNATED_INITIALIZER;
+ handler:(void (^)(void))handler NS_DESIGNATED_INITIALIZER;
@end
@interface GRPCOpSendClose : GRPCOperation
-- (instancetype)initWithHandler:(void(^)(void))handler NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithHandler:(void (^)(void))handler NS_DESIGNATED_INITIALIZER;
@end
@interface GRPCOpRecvMetadata : GRPCOperation
-- (instancetype)initWithHandler:(void(^)(NSDictionary *))handler NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithHandler:(void (^)(NSDictionary *))handler NS_DESIGNATED_INITIALIZER;
@end
@interface GRPCOpRecvMessage : GRPCOperation
-- (instancetype)initWithHandler:(void(^)(grpc_byte_buffer *))handler NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithHandler:(void (^)(grpc_byte_buffer *))handler NS_DESIGNATED_INITIALIZER;
@end
@interface GRPCOpRecvStatus : GRPCOperation
-- (instancetype)initWithHandler:(void(^)(NSError *, NSDictionary *))handler
+- (instancetype)initWithHandler:(void (^)(NSError *, NSDictionary *))handler
NS_DESIGNATED_INITIALIZER;
@end
@@ -79,7 +78,7 @@
path:(NSString *)path
timeout:(NSTimeInterval)timeout NS_DESIGNATED_INITIALIZER;
-- (void)startBatchWithOperations:(NSArray *)ops errorHandler:(void(^)(void))errorHandler;
+- (void)startBatchWithOperations:(NSArray *)ops errorHandler:(void (^)(void))errorHandler;
- (void)startBatchWithOperations:(NSArray *)ops;
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
index 9a0fa5954a..f28e494868 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
@@ -19,29 +19,29 @@
#import "GRPCWrappedCall.h"
#import <Foundation/Foundation.h>
-#include <grpc/grpc.h>
#include <grpc/byte_buffer.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#import "GRPCCompletionQueue.h"
#import "GRPCHost.h"
-#import "NSDictionary+GRPC.h"
#import "NSData+GRPC.h"
+#import "NSDictionary+GRPC.h"
#import "NSError+GRPC.h"
#import "GRPCOpBatchLog.h"
@implementation GRPCOperation {
-@protected
+ @protected
// Most operation subclasses don't set any flags in the grpc_op, and rely on the flag member being
// initialized to zero.
grpc_op _op;
- void(^_handler)(void);
+ void (^_handler)(void);
}
- (void)finish {
if (_handler) {
- void(^handler)(void) = _handler;
+ void (^handler)(void) = _handler;
_handler = nil;
handler();
}
@@ -54,8 +54,7 @@
return [self initWithMetadata:nil flags:0 handler:nil];
}
-- (instancetype)initWithMetadata:(NSDictionary *)metadata
- handler:(void (^)(void))handler {
+- (instancetype)initWithMetadata:(NSDictionary *)metadata handler:(void (^)(void))handler {
return [self initWithMetadata:metadata flags:0 handler:handler];
}
@@ -128,11 +127,11 @@
grpc_metadata_array _headers;
}
-- (instancetype) init {
+- (instancetype)init {
return [self initWithHandler:nil];
}
-- (instancetype) initWithHandler:(void (^)(NSDictionary *))handler {
+- (instancetype)initWithHandler:(void (^)(NSDictionary *))handler {
if (self = [super init]) {
_op.op = GRPC_OP_RECV_INITIAL_METADATA;
grpc_metadata_array_init(&_headers);
@@ -142,8 +141,8 @@
__weak typeof(self) weakSelf = self;
_handler = ^{
__strong typeof(self) strongSelf = weakSelf;
- NSDictionary *metadata = [NSDictionary
- grpc_dictionaryFromMetadataArray:strongSelf->_headers];
+ NSDictionary *metadata =
+ [NSDictionary grpc_dictionaryFromMetadataArray:strongSelf->_headers];
handler(metadata);
};
}
@@ -157,7 +156,7 @@
@end
-@implementation GRPCOpRecvMessage{
+@implementation GRPCOpRecvMessage {
grpc_byte_buffer *_receivedMessage;
}
@@ -183,18 +182,18 @@
@end
-@implementation GRPCOpRecvStatus{
+@implementation GRPCOpRecvStatus {
grpc_status_code _statusCode;
grpc_slice _details;
size_t _detailsCapacity;
grpc_metadata_array _trailers;
}
-- (instancetype) init {
+- (instancetype)init {
return [self initWithHandler:nil];
}
-- (instancetype) initWithHandler:(void (^)(NSError *, NSDictionary *))handler {
+- (instancetype)initWithHandler:(void (^)(NSError *, NSDictionary *))handler {
if (self = [super init]) {
_op.op = GRPC_OP_RECV_STATUS_ON_CLIENT;
_op.data.recv_status_on_client.status = &_statusCode;
@@ -208,10 +207,10 @@
__strong typeof(self) strongSelf = weakSelf;
if (strongSelf) {
char *details = grpc_slice_to_c_string(strongSelf->_details);
- NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode
- details:details];
- NSDictionary *trailers = [NSDictionary
- grpc_dictionaryFromMetadataArray:strongSelf->_trailers];
+ NSError *error =
+ [NSError grpc_errorFromStatusCode:strongSelf->_statusCode details:details];
+ NSDictionary *trailers =
+ [NSDictionary grpc_dictionaryFromMetadataArray:strongSelf->_trailers];
handler(error, trailers);
gpr_free(details);
}
@@ -244,8 +243,7 @@
path:(NSString *)path
timeout:(NSTimeInterval)timeout {
if (!path || !host) {
- [NSException raise:NSInvalidArgumentException
- format:@"path and host cannot be nil."];
+ [NSException raise:NSInvalidArgumentException format:@"path and host cannot be nil."];
}
if (self = [super init]) {
@@ -270,8 +268,8 @@
}
- (void)startBatchWithOperations:(NSArray *)operations errorHandler:(void (^)(void))errorHandler {
- // Keep logs of op batches when we are running tests. Disabled when in production for improved
- // performance.
+// Keep logs of op batches when we are running tests. Disabled when in production for improved
+// performance.
#ifdef GRPC_TEST_OBJC
[GRPCOpBatchLog addOpBatchToLog:operations];
#endif
@@ -282,25 +280,26 @@
for (GRPCOperation *operation in operations) {
ops_array[i++] = operation.op;
}
- grpc_call_error error = grpc_call_start_batch(_call, ops_array, nops,
- (__bridge_retained void *)(^(bool success){
- if (!success) {
- if (errorHandler) {
- errorHandler();
- } else {
- return;
- }
- }
- for (GRPCOperation *operation in operations) {
- [operation finish];
- }
- }), NULL);
+ grpc_call_error error =
+ grpc_call_start_batch(_call, ops_array, nops, (__bridge_retained void *)(^(bool success) {
+ if (!success) {
+ if (errorHandler) {
+ errorHandler();
+ } else {
+ return;
+ }
+ }
+ for (GRPCOperation *operation in operations) {
+ [operation finish];
+ }
+ }),
+ NULL);
gpr_free(ops_array);
if (error != GRPC_CALL_OK) {
- [NSException raise:NSInternalInconsistencyException
- format:@"A precondition for calling grpc_call_start_batch wasn't met. Error %i",
- error];
+ [NSException
+ raise:NSInternalInconsistencyException
+ format:@"A precondition for calling grpc_call_start_batch wasn't met. Error %i", error];
}
}
diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.m b/src/objective-c/GRPCClient/private/NSData+GRPC.m
index 7c46594dd5..5064da310e 100644
--- a/src/objective-c/GRPCClient/private/NSData+GRPC.m
+++ b/src/objective-c/GRPCClient/private/NSData+GRPC.m
@@ -24,8 +24,8 @@
// TODO(jcanizales): Move these two incantations to the C library.
-static void MallocAndCopyByteBufferToCharArray(grpc_byte_buffer *buffer,
- size_t *length, char **array) {
+static void MallocAndCopyByteBufferToCharArray(grpc_byte_buffer *buffer, size_t *length,
+ char **array) {
grpc_byte_buffer_reader reader;
if (!grpc_byte_buffer_reader_init(&reader, buffer)) {
// grpc_byte_buffer_reader_init can fail if the data sent by the server
@@ -51,8 +51,7 @@ static void MallocAndCopyByteBufferToCharArray(grpc_byte_buffer *buffer,
grpc_byte_buffer_reader_destroy(&reader);
}
-static grpc_byte_buffer *CopyCharArrayToNewByteBuffer(const char *array,
- size_t length) {
+static grpc_byte_buffer *CopyCharArrayToNewByteBuffer(const char *array, size_t length) {
grpc_slice slice = grpc_slice_from_copied_buffer(array, length);
grpc_byte_buffer *buffer = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
@@ -89,7 +88,6 @@ static grpc_byte_buffer *CopyCharArrayToNewByteBuffer(const char *array,
// to create an array of grpc_slice objects to pass to
// grpc_raw_byte_buffer_create.
// That would make it do exactly one copy, always.
- return CopyCharArrayToNewByteBuffer((const char *)self.bytes,
- (size_t)self.length);
+ return CopyCharArrayToNewByteBuffer((const char *)self.bytes, (size_t)self.length);
}
@end
diff --git a/src/objective-c/GRPCClient/private/NSDictionary+GRPC.m b/src/objective-c/GRPCClient/private/NSDictionary+GRPC.m
index 4af7cb9a01..af1ce0bf23 100644
--- a/src/objective-c/GRPCClient/private/NSDictionary+GRPC.m
+++ b/src/objective-c/GRPCClient/private/NSDictionary+GRPC.m
@@ -74,8 +74,7 @@
NSMutableDictionary *metadata = [NSMutableDictionary dictionaryWithCapacity:count];
for (grpc_metadata *entry = entries; entry < entries + count; entry++) {
char *key = grpc_slice_to_c_string(entry->key);
- NSString *name = [NSString stringWithCString:key
- encoding:NSASCIIStringEncoding];
+ NSString *name = [NSString stringWithCString:key encoding:NSASCIIStringEncoding];
gpr_free(key);
if (!name || metadata[name]) {
// Log if name is nil?
@@ -97,7 +96,7 @@
- (grpc_metadata *)grpc_metadataArray {
grpc_metadata *metadata = gpr_malloc([self count] * sizeof(grpc_metadata));
grpc_metadata *current = metadata;
- for (NSString* key in self) {
+ for (NSString *key in self) {
id value = self[key];
current->key = grpc_slice_from_copied_string(key.UTF8String);
if ([value respondsToSelector:@selector(grpc_initMetadata:)]) {
diff --git a/src/objective-c/GRPCClient/private/NSError+GRPC.m b/src/objective-c/GRPCClient/private/NSError+GRPC.m
index 6ba7235df4..74cfa943cc 100644
--- a/src/objective-c/GRPCClient/private/NSError+GRPC.m
+++ b/src/objective-c/GRPCClient/private/NSError+GRPC.m
@@ -20,7 +20,7 @@
#include <grpc/grpc.h>
-NSString * const kGRPCErrorDomain = @"io.grpc";
+NSString *const kGRPCErrorDomain = @"io.grpc";
@implementation NSError (GRPC)
+ (instancetype)grpc_errorFromStatusCode:(grpc_status_code)statusCode details:(char *)details {
@@ -30,6 +30,6 @@ NSString * const kGRPCErrorDomain = @"io.grpc";
NSString *message = [NSString stringWithCString:details encoding:NSASCIIStringEncoding];
return [NSError errorWithDomain:kGRPCErrorDomain
code:statusCode
- userInfo:@{NSLocalizedDescriptionKey: message}];
+ userInfo:@{NSLocalizedDescriptionKey : message}];
}
@end
diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h
index a99eb289c3..1298e7e191 100644
--- a/src/objective-c/GRPCClient/private/version.h
+++ b/src/objective-c/GRPCClient/private/version.h
@@ -22,5 +22,4 @@
// instead. This file can be regenerated from the template by running
// `tools/buildgen/generate_projects.sh`.
-
#define GRPC_OBJC_VERSION_STRING @"1.12.0-dev"