Skip to content

Commit

Permalink
Merge pull request #139 from drodriguez/bye-bye-needs-dispatch-retain…
Browse files Browse the repository at this point in the history
…-release

Remove uses of NEEDS_DISPATCH_RETAIN_RELEASE. Use OS_OBJECT_USE_OBJC.
  • Loading branch information
robbiehanson committed Apr 2, 2013
2 parents 7662e11 + 2e7fe01 commit 96dac82
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 611 deletions.
30 changes: 2 additions & 28 deletions Core/XMPPModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,6 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

/**
* Does ARC support support GCD objects?
* It does if the minimum deployment target is iOS 6+ or Mac OS X 10.8+
**/
#if TARGET_OS_IPHONE

// Compiling for iOS

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else // iOS 5.X or earlier
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif

#else

// Compiling for Mac OS X

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
#endif

#endif

// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;
Expand Down Expand Up @@ -60,7 +34,7 @@ - (id)initWithDispatchQueue:(dispatch_queue_t)queue
if (queue)
{
moduleQueue = queue;
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_retain(moduleQueue);
#endif
}
Expand All @@ -77,7 +51,7 @@ - (id)initWithDispatchQueue:(dispatch_queue_t)queue

- (void)dealloc
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(moduleQueue);
#endif
}
Expand Down
36 changes: 5 additions & 31 deletions Core/XMPPParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,6 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

/**
* Does ARC support support GCD objects?
* It does if the minimum deployment target is iOS 6+ or Mac OS X 10.8+
**/
#if TARGET_OS_IPHONE

// Compiling for iOS

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else // iOS 5.X or earlier
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif

#else

// Compiling for Mac OS X

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
#endif

#endif

// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_VERBOSE;
Expand Down Expand Up @@ -725,15 +699,15 @@ - (id)initWithDelegate:(id)aDelegate delegateQueue:(dispatch_queue_t)dq parserQu
delegate = aDelegate;
delegateQueue = dq;

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
if (delegateQueue)
dispatch_retain(delegateQueue);
#endif

if (pq) {
parserQueue = pq;

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_retain(parserQueue);
#endif
}
Expand Down Expand Up @@ -785,7 +759,7 @@ - (void)dealloc
xmlFreeParserCtxt(parserCtxt);
}

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
if (delegateQueue)
dispatch_release(delegateQueue);
if (parserQueue)
Expand All @@ -795,7 +769,7 @@ - (void)dealloc

- (void)setDelegate:(id)newDelegate delegateQueue:(dispatch_queue_t)newDelegateQueue
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
if (newDelegateQueue)
dispatch_retain(newDelegateQueue);
#endif
Expand All @@ -804,7 +778,7 @@ - (void)setDelegate:(id)newDelegate delegateQueue:(dispatch_queue_t)newDelegateQ

delegate = newDelegate;

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
if (delegateQueue)
dispatch_release(delegateQueue);
#endif
Expand Down
34 changes: 4 additions & 30 deletions Core/XMPPStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,6 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

/**
* Does ARC support support GCD objects?
* It does if the minimum deployment target is iOS 6+ or Mac OS X 10.8+
**/
#if TARGET_OS_IPHONE

// Compiling for iOS

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else // iOS 5.X or earlier
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif

#else

// Compiling for Mac OS X

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
#endif

#endif

// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_INFO | XMPP_LOG_FLAG_SEND_RECV; // | XMPP_LOG_FLAG_TRACE;
Expand Down Expand Up @@ -277,7 +251,7 @@ - (id)initP2PFrom:(XMPPJID *)jid
**/
- (void)dealloc
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(xmppQueue);
dispatch_release(willSendIqQueue);
dispatch_release(willSendMessageQueue);
Expand Down Expand Up @@ -2548,7 +2522,7 @@ - (void)continueReceiveIQ:(XMPPIQ *)iq
[self sendElement:iqResponse];
}

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(delSemaphore);
dispatch_release(delGroup);
#endif
Expand Down Expand Up @@ -3818,7 +3792,7 @@ - (void)setupKeepAliveTimer
[self keepAlive];
}});

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_source_t theKeepAliveTimer = keepAliveTimer;

dispatch_source_set_cancel_handler(keepAliveTimer, ^{
Expand Down Expand Up @@ -4282,7 +4256,7 @@ - (BOOL)wait:(NSTimeInterval)timeout_seconds

- (void)dealloc
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(semaphore);
#endif
}
Expand Down
28 changes: 1 addition & 27 deletions Extensions/CoreDataStorage/XMPPCoreDataStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,6 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

/**
* Does ARC support support GCD objects?
* It does if the minimum deployment target is iOS 6+ or Mac OS X 10.8+
**/
#if TARGET_OS_IPHONE

// Compiling for iOS

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else // iOS 5.X or earlier
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif

#else

// Compiling for Mac OS X

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
#endif

#endif

// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;
Expand Down Expand Up @@ -845,7 +819,7 @@ - (void)dealloc
[[self class] unregisterDatabaseFileName:databaseFileName];
}

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
if (storageQueue)
dispatch_release(storageQueue);
#endif
Expand Down
30 changes: 2 additions & 28 deletions Extensions/Reconnect/XMPPReconnect.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,6 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

/**
* Does ARC support support GCD objects?
* It does if the minimum deployment target is iOS 6+ or Mac OS X 10.8+
**/
#if TARGET_OS_IPHONE

// Compiling for iOS

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else // iOS 5.X or earlier
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif

#else

// Compiling for Mac OS X

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
#endif

#endif

#define IMPOSSIBLE_REACHABILITY_FLAGS 0xFFFFFFFF

// Log levels: off, error, warn, info, verbose
Expand Down Expand Up @@ -412,7 +386,7 @@ - (void)setupReconnectTimer

}});

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_source_t theReconnectTimer = reconnectTimer;

dispatch_source_set_cancel_handler(reconnectTimer, ^{
Expand Down Expand Up @@ -641,7 +615,7 @@ - (void)maybeAttemptReconnectWithReachabilityFlags:(SCNetworkReachabilityFlags)r

}});

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(delSemaphore);
dispatch_release(delGroup);
#endif
Expand Down
30 changes: 2 additions & 28 deletions Extensions/Roster/MemoryStorage/XMPPRosterMemoryStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,6 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

/**
* Does ARC support support GCD objects?
* It does if the minimum deployment target is iOS 6+ or Mac OS X 10.8+
**/
#if TARGET_OS_IPHONE

// Compiling for iOS

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else // iOS 5.X or earlier
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif

#else

// Compiling for Mac OS X

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
#endif

#endif

// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN; // | XMPP_LOG_FLAG_TRACE;
Expand Down Expand Up @@ -83,7 +57,7 @@ - (BOOL)configureWithParent:(XMPPRoster *)aParent queue:(dispatch_queue_t)queue
parent = aParent;
parentQueue = queue;

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_retain(parentQueue);
#endif

Expand All @@ -96,7 +70,7 @@ - (BOOL)configureWithParent:(XMPPRoster *)aParent queue:(dispatch_queue_t)queue

- (void)dealloc
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
if (parentQueue)
dispatch_release(parentQueue);
#endif
Expand Down
30 changes: 2 additions & 28 deletions Extensions/XEP-0009/XMPPJabberRPCModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,6 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

/**
* Does ARC support support GCD objects?
* It does if the minimum deployment target is iOS 6+ or Mac OS X 10.8+
**/
#if TARGET_OS_IPHONE

// Compiling for iOS

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else // iOS 5.X or earlier
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif

#else

// Compiling for Mac OS X

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
#endif

#endif

// Log levels: off, error, warn, info, verbose
// Log flags: trace
#if DEBUG
Expand Down Expand Up @@ -83,7 +57,7 @@ - (id)initWithRpcID:(NSString *)aRpcID timer:(dispatch_source_t)aTimer
rpcID = [aRpcID copy];

timer = aTimer;
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_retain(timer);
#endif
}
Expand All @@ -105,7 +79,7 @@ - (void)cancelTimer
if (timer)
{
dispatch_source_cancel(timer);
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(timer);
#endif
timer = NULL;
Expand Down
Loading

0 comments on commit 96dac82

Please sign in to comment.