clang-format

pull/16190/head
Muxi Yan 6 years ago
parent ae99d3a5ed
commit 9a15b6a5cf
  1. 16
      src/objective-c/GRPCClient/GRPCCall.h
  2. 2
      src/objective-c/GRPCClient/GRPCCall.m
  3. 8
      src/objective-c/GRPCClient/GRPCCallOptions.h
  4. 14
      src/objective-c/GRPCClient/GRPCCallOptions.m
  5. 14
      src/objective-c/GRPCClient/private/ChannelArgsUtil.h
  6. 2
      src/objective-c/GRPCClient/private/GRPCChannel.h
  7. 2
      src/objective-c/GRPCClient/private/GRPCChannel.m
  8. 2
      src/objective-c/GRPCClient/private/GRPCChannelFactory.h
  9. 11
      src/objective-c/ProtoRPC/ProtoRPC.h
  10. 11
      src/objective-c/ProtoRPC/ProtoRPC.m
  11. 7
      src/objective-c/tests/GRPCClientTests.m
  12. 7
      src/objective-c/tests/InteropTests.m

@ -147,8 +147,8 @@ typedef NS_ENUM(NSUInteger, GRPCErrorCode) {
* Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by
* the server.
*/
extern NSString * const kGRPCHeadersKey;
extern NSString * const kGRPCTrailersKey;
extern NSString *const kGRPCHeadersKey;
extern NSString *const kGRPCTrailersKey;
/** An object can implement this protocol to receive responses from server from a call. */
@protocol GRPCResponseHandler<NSObject>
@ -156,13 +156,13 @@ extern NSString * const kGRPCTrailersKey;
@optional
/** Issued when initial metadata is received from the server. */
- (void)receivedInitialMetadata:(NSDictionary * _Nullable)initialMetadata;
- (void)receivedInitialMetadata:(NSDictionary *_Nullable)initialMetadata;
/**
* Issued when a message is received from the server. The message is the raw data received from the
* server, with decompression and without proto deserialization.
*/
- (void)receivedRawMessage:(NSData * _Nullable)message;
- (void)receivedRawMessage:(NSData *_Nullable)message;
/**
* Issued when a call finished. If the call finished successfully, \a error is nil and \a
@ -170,7 +170,8 @@ extern NSString * const kGRPCTrailersKey;
* is non-nil and contains the corresponding error information, including gRPC error codes and
* error descriptions.
*/
- (void)closedWithTrailingMetadata:(NSDictionary * _Nullable)trailingMetadata error:(NSError * _Nullable)error;
- (void)closedWithTrailingMetadata:(NSDictionary *_Nullable)trailingMetadata
error:(NSError *_Nullable)error;
@required
@ -218,7 +219,7 @@ extern NSString * const kGRPCTrailersKey;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;
/**
* Designated initializer for a call.
@ -228,7 +229,8 @@ extern NSString * const kGRPCTrailersKey;
*/
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
responseHandler:(id<GRPCResponseHandler>)responseHandler
callOptions:(GRPCCallOptions * _Nullable)callOptions NS_DESIGNATED_INITIALIZER;
callOptions:(GRPCCallOptions *_Nullable)callOptions
NS_DESIGNATED_INITIALIZER;
/**
* Convenience initializer for a call that uses default call options (see GRPCCallOptions.m for
* the default options).

@ -108,7 +108,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
responseHandler:(id<GRPCResponseHandler>)responseHandler
callOptions:(GRPCCallOptions * _Nullable)callOptions {
callOptions:(GRPCCallOptions *_Nullable)callOptions {
if (requestOptions.host.length == 0 || requestOptions.path.length == 0) {
[NSException raise:NSInvalidArgumentException format:@"Neither host nor path can be nil."];
}

@ -27,14 +27,12 @@ typedef NS_ENUM(NSUInteger, GRPCCallSafety) {
/** Signal that the call is idempotent. gRPC is free to use PUT verb. */
GRPCCallSafetyIdempotentRequest = 1,
/**
* Signal that the call is cacheable and will not affect server state. gRPC is free to use GET
* verb.
*/
* Signal that the call is cacheable and will not affect server state. gRPC is free to use GET
* verb.
*/
GRPCCallSafetyCacheableRequest = 2,
};
// Compression algorithm to be used by a gRPC call
typedef NS_ENUM(NSInteger, GRPCCompressionAlgorithm) {
GRPCCompressNone = 0,

@ -102,7 +102,7 @@ static const NSUInteger kDefaultChannelID = 0;
initialMetadata:kDefaultInitialMetadata
userAgentPrefix:kDefaultUserAgentPrefix
responseSizeLimit:kDefaultResponseSizeLimit
compressionAlgorithm:kDefaultCompressionAlgorithm
compressionAlgorithm:kDefaultCompressionAlgorithm
enableRetry:kDefaultEnableRetry
keepaliveInterval:kDefaultKeepaliveInterval
keepaliveTimeout:kDefaultKeepaliveTimeout
@ -127,7 +127,7 @@ static const NSUInteger kDefaultChannelID = 0;
initialMetadata:(NSDictionary *)initialMetadata
userAgentPrefix:(NSString *)userAgentPrefix
responseSizeLimit:(NSUInteger)responseSizeLimit
compressionAlgorithm:(GRPCCompressionAlgorithm)compressionAlgorithm
compressionAlgorithm:(GRPCCompressionAlgorithm)compressionAlgorithm
enableRetry:(BOOL)enableRetry
keepaliveInterval:(NSTimeInterval)keepaliveInterval
keepaliveTimeout:(NSTimeInterval)keepaliveTimeout
@ -181,7 +181,7 @@ static const NSUInteger kDefaultChannelID = 0;
initialMetadata:_initialMetadata
userAgentPrefix:_userAgentPrefix
responseSizeLimit:_responseSizeLimit
compressionAlgorithm:_compressionAlgorithm
compressionAlgorithm:_compressionAlgorithm
enableRetry:_enableRetry
keepaliveInterval:_keepaliveInterval
keepaliveTimeout:_keepaliveTimeout
@ -209,7 +209,7 @@ static const NSUInteger kDefaultChannelID = 0;
initialMetadata:_initialMetadata
userAgentPrefix:_userAgentPrefix
responseSizeLimit:_responseSizeLimit
compressionAlgorithm:_compressionAlgorithm
compressionAlgorithm:_compressionAlgorithm
enableRetry:_enableRetry
keepaliveInterval:_keepaliveInterval
keepaliveTimeout:_keepaliveTimeout
@ -326,7 +326,7 @@ static const NSUInteger kDefaultChannelID = 0;
initialMetadata:kDefaultInitialMetadata
userAgentPrefix:kDefaultUserAgentPrefix
responseSizeLimit:kDefaultResponseSizeLimit
compressionAlgorithm:kDefaultCompressionAlgorithm
compressionAlgorithm:kDefaultCompressionAlgorithm
enableRetry:kDefaultEnableRetry
keepaliveInterval:kDefaultKeepaliveInterval
keepaliveTimeout:kDefaultKeepaliveTimeout
@ -353,7 +353,7 @@ static const NSUInteger kDefaultChannelID = 0;
initialMetadata:_initialMetadata
userAgentPrefix:_userAgentPrefix
responseSizeLimit:_responseSizeLimit
compressionAlgorithm:_compressionAlgorithm
compressionAlgorithm:_compressionAlgorithm
enableRetry:_enableRetry
keepaliveInterval:_keepaliveInterval
keepaliveTimeout:_keepaliveTimeout
@ -381,7 +381,7 @@ static const NSUInteger kDefaultChannelID = 0;
initialMetadata:_initialMetadata
userAgentPrefix:_userAgentPrefix
responseSizeLimit:_responseSizeLimit
compressionAlgorithm:_compressionAlgorithm
compressionAlgorithm:_compressionAlgorithm
enableRetry:_enableRetry
keepaliveInterval:_keepaliveInterval
keepaliveTimeout:_keepaliveTimeout

@ -24,11 +24,15 @@
void GRPCFreeChannelArgs(grpc_channel_args* channel_args);
/**
* Allocates a @c grpc_channel_args and populates it with the options specified in the
* @c dictionary. Keys must be @c NSString, @c NSNumber, or a pointer. If the value responds to
* @c @selector(UTF8String) then it will be mapped to @c GRPC_ARG_STRING. If the value responds to
* @c @selector(intValue), it will be mapped to @c GRPC_ARG_INTEGER. Otherwise, if the value is not
* nil, it is mapped as a pointer. The caller of this function is responsible for calling
* Allocates a @c grpc_channel_args and populates it with the options specified
* in the
* @c dictionary. Keys must be @c NSString, @c NSNumber, or a pointer. If the
* value responds to
* @c @selector(UTF8String) then it will be mapped to @c GRPC_ARG_STRING. If the
* value responds to
* @c @selector(intValue), it will be mapped to @c GRPC_ARG_INTEGER. Otherwise,
* if the value is not nil, it is mapped as a pointer. The caller of this
* function is responsible for calling
* @c GRPCFreeChannelArgs to free the @c grpc_channel_args struct.
*/
grpc_channel_args* GRPCBuildChannelArgs(NSDictionary* dictionary);

@ -32,7 +32,7 @@ struct grpc_channel_credentials;
- (nullable instancetype)init NS_UNAVAILABLE;
+ (nullable instancetype)new NS_UNAVAILABLE;
+ (nullable instancetype) new NS_UNAVAILABLE;
/**
* Returns a channel connecting to \a host with options as \a callOptions. The channel may be new

@ -222,7 +222,7 @@ static GRPCChannelPool *gChannelPool;
});
}
- (nullable instancetype)initWithUnmanagedChannel:(grpc_channel * _Nullable)unmanagedChannel
- (nullable instancetype)initWithUnmanagedChannel:(grpc_channel *_Nullable)unmanagedChannel
configuration:(GRPCChannelConfiguration *)configuration {
NSAssert(configuration, @"Configuration must not be empty.");
if (!unmanagedChannel) {

@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
/** A factory interface which generates new channel. */
@protocol GRPCChannelFactory
/** Create a channel with specific channel args to a specific host. */
/** Create a channel with specific channel args to a specific host. */
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
channelArgs:(nullable NSDictionary *)args;

@ -31,12 +31,12 @@ NS_ASSUME_NONNULL_BEGIN
@optional
/** Issued when initial metadata is received from the server. */
- (void)receivedInitialMetadata:(NSDictionary * _Nullable)initialMetadata;
- (void)receivedInitialMetadata:(NSDictionary *_Nullable)initialMetadata;
/**
* Issued when a message is received from the server. The message is the deserialized proto object.
*/
- (void)receivedProtoMessage:(GPBMessage * _Nullable)message;
- (void)receivedProtoMessage:(GPBMessage *_Nullable)message;
/**
* Issued when a call finished. If the call finished successfully, \a error is nil and \a
@ -44,7 +44,8 @@ NS_ASSUME_NONNULL_BEGIN
* is non-nil and contains the corresponding error information, including gRPC error codes and
* error descriptions.
*/
- (void)closedWithTrailingMetadata:(NSDictionary * _Nullable)trailingMetadata error:(NSError * _Nullable)error;
- (void)closedWithTrailingMetadata:(NSDictionary *_Nullable)trailingMetadata
error:(NSError *_Nullable)error;
@required
@ -70,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
message:(GPBMessage *)message
responseHandler:(id<GRPCProtoResponseHandler>)handler
callOptions:(GRPCCallOptions * _Nullable)callOptions
callOptions:(GRPCCallOptions *_Nullable)callOptions
responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
/**
@ -95,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
responseHandler:(id<GRPCProtoResponseHandler>)handler
callOptions:(GRPCCallOptions * _Nullable)callOptions
callOptions:(GRPCCallOptions *_Nullable)callOptions
responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
/**

@ -34,7 +34,7 @@
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
message:(GPBMessage *)message
responseHandler:(id<GRPCProtoResponseHandler>)handler
callOptions:(GRPCCallOptions * _Nullable)callOptions
callOptions:(GRPCCallOptions *_Nullable)callOptions
responseClass:(Class)responseClass {
if ((self = [super init])) {
_call = [[GRPCStreamingProtoCall alloc] initWithRequestOptions:requestOptions
@ -70,7 +70,7 @@
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
responseHandler:(id<GRPCProtoResponseHandler>)handler
callOptions:(GRPCCallOptions * _Nullable)callOptions
callOptions:(GRPCCallOptions *_Nullable)callOptions
responseClass:(Class)responseClass {
if (requestOptions.host.length == 0 || requestOptions.path.length == 0) {
[NSException raise:NSInvalidArgumentException format:@"Neither host nor path can be nil."];
@ -153,7 +153,7 @@
});
}
- (void)receivedInitialMetadata:(NSDictionary * _Nullable)initialMetadata {
- (void)receivedInitialMetadata:(NSDictionary *_Nullable)initialMetadata {
if (_handler && initialMetadata != nil) {
id<GRPCProtoResponseHandler> handler = _handler;
if ([handler respondsToSelector:@selector(initialMetadata:)]) {
@ -164,7 +164,7 @@
}
}
- (void)receivedRawMessage:(NSData * _Nullable)message {
- (void)receivedRawMessage:(NSData *_Nullable)message {
if (_handler && message != nil) {
id<GRPCProtoResponseHandler> handler = _handler;
NSError *error = nil;
@ -188,7 +188,8 @@
}
}
- (void)closedWithTrailingMetadata:(NSDictionary * _Nullable)trailingMetadata error:(NSError * _Nullable)error {
- (void)closedWithTrailingMetadata:(NSDictionary *_Nullable)trailingMetadata
error:(NSError *_Nullable)error {
if (_handler) {
id<GRPCProtoResponseHandler> handler = _handler;
if ([handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) {

@ -114,19 +114,20 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
return self;
}
- (void)receivedInitialMetadata:(NSDictionary * _Nullable)initialMetadata {
- (void)receivedInitialMetadata:(NSDictionary *_Nullable)initialMetadata {
if (_initialMetadataCallback) {
_initialMetadataCallback(initialMetadata);
}
}
- (void)receivedProtoMessage:(GPBMessage * _Nullable)message {
- (void)receivedProtoMessage:(GPBMessage *_Nullable)message {
if (_messageCallback) {
_messageCallback(message);
}
}
- (void)closedWithTrailingMetadata:(NSDictionary * _Nullable)trailingMetadata error:(NSError * _Nullable)error {
- (void)closedWithTrailingMetadata:(NSDictionary *_Nullable)trailingMetadata
error:(NSError *_Nullable)error {
if (_closeCallback) {
_closeCallback(trailingMetadata, error);
}

@ -102,19 +102,20 @@ BOOL isRemoteInteropTest(NSString *host) {
return self;
}
- (void)receivedInitialMetadata:(NSDictionary * _Nullable)initialMetadata {
- (void)receivedInitialMetadata:(NSDictionary *_Nullable)initialMetadata {
if (_initialMetadataCallback) {
_initialMetadataCallback(initialMetadata);
}
}
- (void)receivedProtoMessage:(GPBMessage * _Nullable)message {
- (void)receivedProtoMessage:(GPBMessage *_Nullable)message {
if (_messageCallback) {
_messageCallback(message);
}
}
- (void)closedWithTrailingMetadata:(NSDictionary * _Nullable)trailingMetadata error:(NSError * _Nullable)error {
- (void)closedWithTrailingMetadata:(NSDictionary *_Nullable)trailingMetadata
error:(NSError *_Nullable)error {
if (_closeCallback) {
_closeCallback(trailingMetadata, error);
}

Loading…
Cancel
Save