id<GRXWriter> -> GRXWriter * in the runtime

pull/2488/head
Jorge Canizales 10 years ago
parent 7b52c98e62
commit 5604712b03
  1. 2
      src/objective-c/GRPCClient/GRPCCall.h
  2. 4
      src/objective-c/GRPCClient/GRPCCall.m
  3. 2
      src/objective-c/GRPCClient/private/GRPCDelegateWrapper.h
  4. 4
      src/objective-c/GRPCClient/private/GRPCDelegateWrapper.m
  5. 2
      src/objective-c/ProtoRPC/ProtoRPC.h
  6. 4
      src/objective-c/ProtoRPC/ProtoRPC.m
  7. 4
      src/objective-c/ProtoRPC/ProtoService.h
  8. 2
      src/objective-c/ProtoRPC/ProtoService.m
  9. 2
      src/objective-c/RxLibrary/GRXForwardingWriter.h
  10. 6
      src/objective-c/RxLibrary/GRXForwardingWriter.m
  11. 12
      src/objective-c/RxLibrary/GRXImmediateWriter.h
  12. 12
      src/objective-c/RxLibrary/GRXImmediateWriter.m
  13. 2
      src/objective-c/RxLibrary/transformations/GRXMappingWriter.h
  14. 4
      src/objective-c/RxLibrary/transformations/GRXMappingWriter.m

@ -89,7 +89,7 @@ extern id const kGRPCStatusMetadataKey;
// To finish a call right away, invoke cancel.
- (instancetype)initWithHost:(NSString *)host
path:(NSString *)path
requestsWriter:(id<GRXWriter>)requestsWriter NS_DESIGNATED_INITIALIZER;
requestsWriter:(GRXWriter *)requestsWriter NS_DESIGNATED_INITIALIZER;
// Finishes the request side of this call, notifies the server that the RPC
// should be cancelled, and finishes the response side of the call with an error

@ -79,7 +79,7 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey";
// all. This wrapper over our actual writeable ensures thread-safety and
// correct ordering.
GRPCDelegateWrapper *_responseWriteable;
id<GRXWriter> _requestWriter;
GRXWriter *_requestWriter;
NSMutableDictionary *_requestMetadata;
NSMutableDictionary *_responseMetadata;
@ -94,7 +94,7 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey";
// Designated initializer
- (instancetype)initWithHost:(NSString *)host
path:(NSString *)path
requestsWriter:(id<GRXWriter>)requestWriter {
requestsWriter:(GRXWriter *)requestWriter {
if (!host || !path) {
[NSException raise:NSInvalidArgumentException format:@"Neither host nor method can be nil."];
}

@ -54,7 +54,7 @@
// writesFinishedWithError: is sent to the writeable, and released after that.
// This is used to create a retain cycle that keeps both objects alive until the
// writing is explicitly finished.
- (instancetype)initWithWriteable:(id<GRXWriteable>)writeable writer:(id<GRXWriter>)writer
- (instancetype)initWithWriteable:(id<GRXWriteable>)writeable writer:(GRXWriter *)writer
NS_DESIGNATED_INITIALIZER;
// Enqueues writeValue: to be sent to the writeable in the main thread.

@ -38,7 +38,7 @@
@interface GRPCDelegateWrapper ()
// These are atomic so that cancellation can nillify them from any thread.
@property(atomic, strong) id<GRXWriteable> writeable;
@property(atomic, strong) id<GRXWriter> writer;
@property(atomic, strong) GRXWriter *writer;
@end
@implementation GRPCDelegateWrapper {
@ -52,7 +52,7 @@
}
// Designated initializer
- (instancetype)initWithWriteable:(id<GRXWriteable>)writeable writer:(id<GRXWriter>)writer {
- (instancetype)initWithWriteable:(id<GRXWriteable>)writeable writer:(GRXWriter *)writer {
if (self = [super init]) {
_writeableQueue = dispatch_get_main_queue();
_writeable = writeable;

@ -40,7 +40,7 @@
- (instancetype)initWithHost:(NSString *)host
method:(ProtoMethod *)method
requestsWriter:(id<GRXWriter>)requestsWriter
requestsWriter:(GRXWriter *)requestsWriter
responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable NS_DESIGNATED_INITIALIZER;

@ -46,7 +46,7 @@
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
- (instancetype)initWithHost:(NSString *)host
path:(NSString *)path
requestsWriter:(id<GRXWriter>)requestsWriter {
requestsWriter:(GRXWriter *)requestsWriter {
[NSException raise:NSInvalidArgumentException
format:@"Please use ProtoRPC's designated initializer instead."];
return nil;
@ -56,7 +56,7 @@
// Designated initializer
- (instancetype)initWithHost:(NSString *)host
method:(ProtoMethod *)method
requestsWriter:(id<GRXWriter>)requestsWriter
requestsWriter:(GRXWriter *)requestsWriter
responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable {
// Because we can't tell the type system to constrain the class, we need to check at runtime:

@ -35,7 +35,7 @@
@class ProtoRPC;
@protocol GRXWriteable;
@protocol GRXWriter;
@class GRXWriter;
@interface ProtoService : NSObject
- (instancetype)initWithHost:(NSString *)host
@ -43,7 +43,7 @@
serviceName:(NSString *)serviceName NS_DESIGNATED_INITIALIZER;
- (ProtoRPC *)RPCToMethod:(NSString *)method
requestsWriter:(id<GRXWriter>)requestsWriter
requestsWriter:(GRXWriter *)requestsWriter
responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable;
@end

@ -66,7 +66,7 @@
}
- (ProtoRPC *)RPCToMethod:(NSString *)method
requestsWriter:(id<GRXWriter>)requestsWriter
requestsWriter:(GRXWriter *)requestsWriter
responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable {
ProtoMethod *methodName = [[ProtoMethod alloc] initWithPackage:_packageName

@ -39,5 +39,5 @@
// input writer, and for classes that represent objects with input and
// output sequences of values, like an RPC.
@interface GRXForwardingWriter : GRXWriter
- (instancetype)initWithWriter:(id<GRXWriter>)writer NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithWriter:(GRXWriter *)writer NS_DESIGNATED_INITIALIZER;
@end

@ -37,7 +37,7 @@
@end
@implementation GRXForwardingWriter {
id<GRXWriter> _writer;
GRXWriter *_writer;
id<GRXWriteable> _writeable;
}
@ -46,7 +46,7 @@
}
// Designated initializer
- (instancetype)initWithWriter:(id<GRXWriter>)writer {
- (instancetype)initWithWriter:(GRXWriter *)writer {
if (!writer) {
[NSException raise:NSInvalidArgumentException format:@"writer can't be nil."];
}
@ -68,7 +68,7 @@
// This is used to stop the input writer. It nillifies our reference to it
// to release it.
- (void)finishInput {
id<GRXWriter> writer = _writer;
GRXWriter *writer = _writer;
_writer = nil;
writer.state = GRXWriterStateFinished;
}

@ -44,11 +44,11 @@
// Returns a writer that pulls values from the passed NSEnumerator instance and pushes them to
// its writeable. The NSEnumerator is released when it finishes.
+ (id<GRXWriter>)writerWithEnumerator:(NSEnumerator *)enumerator;
+ (GRXWriter *)writerWithEnumerator:(NSEnumerator *)enumerator;
// Returns a writer that pushes to its writeable the successive values returned by the passed
// block. When the block first returns nil, it is released.
+ (id<GRXWriter>)writerWithValueSupplier:(id (^)())block;
+ (GRXWriter *)writerWithValueSupplier:(id (^)())block;
// Returns a writer that iterates over the values of the passed container and pushes them to
// its writeable. The container is released when the iteration is over.
@ -56,18 +56,18 @@
// Note that the usual speed gain of NSFastEnumeration over NSEnumerator results from not having to
// call one method per element. Because GRXWriteable instances accept values one by one, that speed
// gain doesn't happen here.
+ (id<GRXWriter>)writerWithContainer:(id<NSFastEnumeration>)container;
+ (GRXWriter *)writerWithContainer:(id<NSFastEnumeration>)container;
// Returns a writer that sends the passed value to its writeable and then finishes (releasing the
// value).
+ (id<GRXWriter>)writerWithValue:(id)value;
+ (GRXWriter *)writerWithValue:(id)value;
// Returns a writer that, as part of its start method, sends the passed error to the writeable
// (then releasing the error).
+ (id<GRXWriter>)writerWithError:(NSError *)error;
+ (GRXWriter *)writerWithError:(NSError *)error;
// Returns a writer that, as part of its start method, finishes immediately without sending any
// values to its writeable.
+ (id<GRXWriter>)emptyWriter;
+ (GRXWriter *)emptyWriter;
@end

@ -63,19 +63,19 @@
return [[self alloc] initWithEnumerator:enumerator error:errorOrNil];
}
+ (id<GRXWriter>)writerWithEnumerator:(NSEnumerator *)enumerator {
+ (GRXWriter *)writerWithEnumerator:(NSEnumerator *)enumerator {
return [self writerWithEnumerator:enumerator error:nil];
}
+ (id<GRXWriter>)writerWithValueSupplier:(id (^)())block {
+ (GRXWriter *)writerWithValueSupplier:(id (^)())block {
return [self writerWithEnumerator:[NSEnumerator grx_enumeratorWithValueSupplier:block]];
}
+ (id<GRXWriter>)writerWithContainer:(id<NSFastEnumeration>)container {
+ (GRXWriter *)writerWithContainer:(id<NSFastEnumeration>)container {
return [self writerWithEnumerator:[NSEnumerator grx_enumeratorWithContainer:container]];;
}
+ (id<GRXWriter>)writerWithValue:(id)value {
+ (GRXWriter *)writerWithValue:(id)value {
if (value) {
return [self writerWithEnumerator:[NSEnumerator grx_enumeratorWithSingleValue:value]];
} else {
@ -83,7 +83,7 @@
}
}
+ (id<GRXWriter>)writerWithError:(NSError *)error {
+ (GRXWriter *)writerWithError:(NSError *)error {
if (error) {
return [self writerWithEnumerator:nil error:error];
} else {
@ -91,7 +91,7 @@
}
}
+ (id<GRXWriter>)emptyWriter {
+ (GRXWriter *)emptyWriter {
static GRXImmediateWriter *emptyWriter;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{

@ -35,6 +35,6 @@
// A "proxy" writer that transforms all the values of its input writer by using a mapping function.
@interface GRXMappingWriter : GRXForwardingWriter
- (instancetype)initWithWriter:(id<GRXWriter>)writer map:(id (^)(id value))map
- (instancetype)initWithWriter:(GRXWriter *)writer map:(id (^)(id value))map
NS_DESIGNATED_INITIALIZER;
@end

@ -44,12 +44,12 @@ static id (^kIdentity)(id value) = ^id(id value) {
id (^_map)(id value);
}
- (instancetype)initWithWriter:(id<GRXWriter>)writer {
- (instancetype)initWithWriter:(GRXWriter *)writer {
return [self initWithWriter:writer map:nil];
}
// Designated initializer
- (instancetype)initWithWriter:(id<GRXWriter>)writer map:(id (^)(id value))map {
- (instancetype)initWithWriter:(GRXWriter *)writer map:(id (^)(id value))map {
if ((self = [super initWithWriter:writer])) {
_map = map ?: kIdentity;
}

Loading…
Cancel
Save