Formatting and naming fixes

pull/4985/head
Kristopher Wuollett 9 years ago
parent 55484da58a
commit 99354c3cad
  1. 2
      src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
  2. 2
      src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
  3. 19
      src/objective-c/GRPCClient/private/GRPCChannel.m
  4. 2
      src/objective-c/GRPCClient/private/GRPCHost.m

@ -42,6 +42,6 @@
*/ */
+ (void)setUserAgentPrefix:(NSString *)userAgentPrefix; + (void)setUserAgentPrefix:(NSString *)userAgentPrefix;
+ (NSString *)useUserAgentPrefix; + (NSString *)userAgentPrefix;
@end @end

@ -45,7 +45,7 @@ static NSString *_userAgentPrefix;
} }
} }
+ (NSString *)useUserAgentPrefix { + (NSString *)userAgentPrefix {
@synchronized(self) { @synchronized(self) {
return _userAgentPrefix; return _userAgentPrefix;
} }

@ -39,7 +39,7 @@
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
/** /**
* Returns @c grpc_channel_credentials from the specifie @c path. If the file at the path could not * Returns @c grpc_channel_credentials from the specified @c path. If the file at the path could not
* be read then NULL is returned. If NULL is returned, @c errorPtr may not be NULL if there are * be read then NULL is returned. If NULL is returned, @c errorPtr may not be NULL if there are
* details available describing what went wrong. * details available describing what went wrong.
*/ */
@ -73,7 +73,8 @@ void freeChannelArgs(grpc_channel_args *channel_args) {
* Allocates a @c grpc_channel_args and populates it with the options specified in the * Allocates a @c grpc_channel_args and populates it with the options specified in the
* @c dictionary. Keys must be @c NSString. If the value responds to @c @selector(UTF8String) then * @c dictionary. Keys must be @c NSString. If the value responds to @c @selector(UTF8String) then
* it will be mapped to @c GRPC_ARG_STRING. If not, it will be mapped to @c GRPC_ARG_INTEGER if the * it will be mapped to @c GRPC_ARG_STRING. If not, it will be mapped to @c GRPC_ARG_INTEGER if the
* value responds to @c @selector(intValue). Otherwise, an exception will be raised. * value responds to @c @selector(intValue). Otherwise, an exception will be raised. The caller of
* this function is responsible for calling @c freeChannelArgs on a non-NULL returned value.
*/ */
grpc_channel_args * buildChannelArgs(NSDictionary *dictionary) { grpc_channel_args * buildChannelArgs(NSDictionary *dictionary) {
if (!dictionary) { if (!dictionary) {
@ -89,8 +90,6 @@ grpc_channel_args * buildChannelArgs(NSDictionary *dictionary) {
// TODO(kriswuollett) Check that keys adhere to GRPC core library requirements // TODO(kriswuollett) Check that keys adhere to GRPC core library requirements
Class invalidValueType = NULL;
for (NSUInteger i = 0; i < argCount; ++i) { for (NSUInteger i = 0; i < argCount; ++i) {
grpc_arg *arg = &channelArgs->args[i]; grpc_arg *arg = &channelArgs->args[i];
arg->key = gpr_strdup([keys[i] UTF8String]); arg->key = gpr_strdup([keys[i] UTF8String]);
@ -103,15 +102,9 @@ grpc_channel_args * buildChannelArgs(NSDictionary *dictionary) {
arg->type = GRPC_ARG_INTEGER; arg->type = GRPC_ARG_INTEGER;
arg->value.integer = [value intValue]; arg->value.integer = [value intValue];
} else { } else {
invalidValueType = [value class];
break;
}
}
if (invalidValueType) {
freeChannelArgs(channelArgs);
[NSException raise:NSInvalidArgumentException [NSException raise:NSInvalidArgumentException
format:@"Invalid value type: %@", invalidValueType]; format:@"Invalid value type: %@", [value class]];
}
} }
return channelArgs; return channelArgs;
@ -144,7 +137,7 @@ grpc_channel_args * buildChannelArgs(NSDictionary *dictionary) {
_unmanagedChannel = grpc_secure_channel_create(credentials, _host.UTF8String, _channelArgs, _unmanagedChannel = grpc_secure_channel_create(credentials, _host.UTF8String, _channelArgs,
NULL); NULL);
} else { } else {
_unmanagedChannel = grpc_insecure_channel_create(host.UTF8String, _channelArgs, NULL); _unmanagedChannel = grpc_insecure_channel_create(_host.UTF8String, _channelArgs, NULL);
} }
} }

@ -109,7 +109,7 @@
if (!_channel) { if (!_channel) {
NSMutableDictionary *args = [NSMutableDictionary dictionary]; NSMutableDictionary *args = [NSMutableDictionary dictionary];
NSString *userAgentPrefix = [[GRPCCall useUserAgentPrefix] copy]; NSString *userAgentPrefix = [[GRPCCall userAgentPrefix] copy];
if (userAgentPrefix) { if (userAgentPrefix) {
args[@GRPC_ARG_PRIMARY_USER_AGENT_STRING] = userAgentPrefix; args[@GRPC_ARG_PRIMARY_USER_AGENT_STRING] = userAgentPrefix;
} }

Loading…
Cancel
Save