aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-09-02 17:41:43 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2015-09-02 22:03:06 -0700
commit5c339d15b322952c71b7f3ecef94f6d2eb7dd2b4 (patch)
treea2436ff329537e9ade585987e195dcde7bc72284
parent86e5a050f7db82f49e92bc79be3a0f8623353be3 (diff)
Remove -[asDictionary]
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m5
-rw-r--r--src/objective-c/GRPCClient/GRPCRequestHeaders.h5
-rw-r--r--src/objective-c/GRPCClient/GRPCRequestHeaders.m10
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.h4
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m4
5 files changed, 19 insertions, 9 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index e6d845c9c2..d5f775c6e6 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -236,9 +236,8 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
- (void)sendHeaders:(GRPCRequestHeaders *)headers {
// TODO(jcanizales): Add error handlers for async failures
- [_wrappedCall startBatchWithOperations:@[[[GRPCOpSendMetadata alloc]
- initWithMetadata:[headers asDictionary] ?: @{}
- handler:nil]]];
+ [_wrappedCall startBatchWithOperations:@[[[GRPCOpSendMetadata alloc] initWithMetadata:headers
+ handler:nil]]];
}
#pragma mark GRXWriteable implementation
diff --git a/src/objective-c/GRPCClient/GRPCRequestHeaders.h b/src/objective-c/GRPCClient/GRPCRequestHeaders.h
index 320545190f..5a93f82cd8 100644
--- a/src/objective-c/GRPCClient/GRPCRequestHeaders.h
+++ b/src/objective-c/GRPCClient/GRPCRequestHeaders.h
@@ -38,6 +38,9 @@
@interface GRPCRequestHeaders : NSObject
+@property(nonatomic, readonly) NSUInteger count;
+@property(nonatomic, readonly) grpc_metadata *grpc_metadataArray;
+
- (instancetype)initWithCall:(GRPCCall *)call;
- (id)objectForKeyedSubscript:(NSString *)key;
@@ -46,6 +49,4 @@
- (void)removeAllObjects;
- (void)removeObjectForKey:(NSString *)aKey;
-- (NSDictionary *)asDictionary;
-
@end \ No newline at end of file
diff --git a/src/objective-c/GRPCClient/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/GRPCRequestHeaders.m
index f479ed7501..041bc4e7a8 100644
--- a/src/objective-c/GRPCClient/GRPCRequestHeaders.m
+++ b/src/objective-c/GRPCClient/GRPCRequestHeaders.m
@@ -34,6 +34,7 @@
#import <Foundation/Foundation.h>
#import "GRPCRequestHeaders.h"
#import "GRPCCall.h"
+#import "NSDictionary+GRPC.h"
static NSString* normalizeKey(NSString* key) {
if ([key canBeConvertedToEncoding:NSASCIIStringEncoding]) {
@@ -121,8 +122,13 @@ static bool isKeyValuePairValid(NSString *key, id value) {
}
}
-- (NSDictionary *)asDictionary {
- return [NSDictionary dictionaryWithDictionary:_proxy];
+// TODO(jcanizales): Just forward all invocations?
+
+- (NSUInteger)count {
+ return _proxy.count;
}
+- (grpc_metadata *)grpc_metadataArray {
+ return _proxy.grpc_metadataArray;
+}
@end \ No newline at end of file
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
index da11cbb761..ba34c0a6e7 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
@@ -36,6 +36,8 @@
#import "GRPCChannel.h"
+@class GRPCRequestHeaders;
+
@interface GRPCOperation : NSObject
@property(nonatomic, readonly) grpc_op op;
// Guaranteed to be called when the operation has finished.
@@ -44,7 +46,7 @@
@interface GRPCOpSendMetadata : GRPCOperation
-- (instancetype)initWithMetadata:(NSDictionary *)metadata
+- (instancetype)initWithMetadata:(GRPCRequestHeaders *)metadata
handler:(void(^)())handler NS_DESIGNATED_INITIALIZER;
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
index fe3d51da53..3cb5613bd0 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
@@ -38,6 +38,8 @@
#include <grpc/byte_buffer.h>
#include <grpc/support/alloc.h>
+#import "GRPCRequestHeaders.h"
+
#import "GRPCCompletionQueue.h"
#import "GRPCHost.h"
#import "NSDictionary+GRPC.h"
@@ -65,7 +67,7 @@
return [self initWithMetadata:nil handler:nil];
}
-- (instancetype)initWithMetadata:(NSDictionary *)metadata handler:(void (^)())handler {
+- (instancetype)initWithMetadata:(GRPCRequestHeaders *)metadata handler:(void (^)())handler {
if (self = [super init]) {
_op.op = GRPC_OP_SEND_INITIAL_METADATA;
_op.data.send_initial_metadata.count = metadata.count;