Skip to content
This repository has been archived by the owner on Apr 19, 2021. It is now read-only.

Commit

Permalink
Obj-C generics
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Fischer committed Jul 14, 2015
1 parent c1913b2 commit 03687ad
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion SuperSocket/SuperSocket/STCPSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ - (void)getInterfaceAddress4:(NSMutableData **)interfaceAddr4Ptr

NSString *interface = nil;

NSArray *components = [interfaceDescription componentsSeparatedByString:@":"];
NSArray<NSString *> *components = [interfaceDescription componentsSeparatedByString:@":"];
if ([components count] > 0) {
NSString *temp = [components objectAtIndex:0];
if ([temp length] > 0) {
Expand Down
2 changes: 1 addition & 1 deletion SuperSocket/SuperSocket/SUDPSendPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
BOOL resolveInProgress;
BOOL filterInProgress;

NSArray *resolvedAddresses;
NSArray<NSData *> *resolvedAddresses;
NSError *resolveError;

NSData *address;
Expand Down
16 changes: 7 additions & 9 deletions SuperSocket/SuperSocket/SUDPSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ - (BOOL)preOp:(NSError **)errPtr {
**/
- (void)asyncResolveHost:(NSString *)aHost
port:(uint16_t)port
withCompletionBlock:(void (^)(NSArray *addresses, NSError *error))completionBlock {
withCompletionBlock:(void (^)(NSArray<NSData *> *addresses, NSError *error))completionBlock {
LogTrace();

// Check parameter(s)
Expand All @@ -1020,10 +1020,8 @@ - (void)asyncResolveHost:(NSString *)aHost
// It's possible that the given aHost parameter is actually a NSMutableString.
// So we want to copy it now, within this block that will be executed synchronously.
// This way the asynchronous lookup block below doesn't have to worry about it changing.

NSString *host = [aHost copy];


dispatch_queue_t globalConcurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(globalConcurrentQueue, ^{
@autoreleasepool {
Expand Down Expand Up @@ -1103,7 +1101,7 @@ - (void)asyncResolveHost:(NSString *)aHost
* Returns the address family (AF_INET or AF_INET6) of the picked address,
* or AF_UNSPEC and the corresponding error is there's a problem.
**/
- (int)getAddress:(NSData **)addressPtr error:(NSError **)errorPtr fromAddresses:(NSArray *)addresses {
- (int)getAddress:(NSData **)addressPtr error:(NSError **)errorPtr fromAddresses:(NSArray<NSData *> *)addresses {
NSAssert(dispatch_get_specific(IsOnSocketQueueOrTargetQueueKey), @"Must be dispatched on socketQueue");
NSAssert([addresses count] > 0, @"Expected at least one address");

Expand Down Expand Up @@ -2757,8 +2755,8 @@ - (BOOL)connectToHost:(NSString *)host onPort:(uint16_t)port error:(NSError **)e
LogVerbose(@"Dispatching DNS resolve for connect...");

[self asyncResolveHost:host
port:port
withCompletionBlock:^(NSArray *addresses, NSError *error) {
port:port
withCompletionBlock:^(NSArray<NSData *> *addresses, NSError *error) {

// The asyncResolveHost:port:: method asynchronously dispatches a task onto the global concurrent queue,
// and immediately returns. Once the async resolve task completes,
Expand Down Expand Up @@ -2830,7 +2828,7 @@ - (BOOL)connectToAddress:(NSData *)remoteAddr error:(NSError **)errPtr {
// So we copy it to be safe.

NSData *address = [remoteAddr copy];
NSArray *addresses = [NSArray arrayWithObject:address];
NSArray<NSData *> *addresses = @[address];

SUDPSpecialPacket *packet = [[SUDPSpecialPacket alloc] init];
packet->addresses = addresses;
Expand Down Expand Up @@ -3191,8 +3189,8 @@ - (void)sendData:(NSData *)data
packet->resolveInProgress = YES;

[self asyncResolveHost:host
port:port
withCompletionBlock:^(NSArray *addresses, NSError *error) {
port:port
withCompletionBlock:^(NSArray<NSData *> *addresses, NSError *error) {

// The asyncResolveHost:port:: method asynchronously dispatches a task onto the global concurrent queue,
// and immediately returns. Once the async resolve task completes,
Expand Down
2 changes: 1 addition & 1 deletion SuperSocket/SuperSocket/SUDPSpecialPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

BOOL resolveInProgress;

NSArray *addresses;
NSArray<NSData *> *addresses;
NSError *error;
}

Expand Down

0 comments on commit 03687ad

Please sign in to comment.