Skip to content

Commit

Permalink
Use built-in OS_OBJECT_USE_OBJC definition instead of custom one.
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiehanson committed Mar 28, 2013
1 parent e15589e commit c615608
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 113 deletions.
39 changes: 7 additions & 32 deletions Core/HTTPConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,23 @@
#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 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
// Other flags: trace
static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE;

// Define chunk size used to read in data for responses
// This is how much data will be read from disk into RAM at a time
#if TARGET_OS_IPHONE
#define READ_CHUNKSIZE (1024 * /*128*/256)
#define READ_CHUNKSIZE (1024 * 256)
#else
#define READ_CHUNKSIZE (1024 * 512)
#endif

// Define chunk size used to read in POST upload data
#if TARGET_OS_IPHONE
#define POST_CHUNKSIZE (1024 * /*32*/256)
#define POST_CHUNKSIZE (1024 * 256)
#else
#define POST_CHUNKSIZE (1024 * /*128*/512)
#define POST_CHUNKSIZE (1024 * 512)
#endif

// Define the various timeouts (in seconds) for various parts of the HTTP process
Expand Down Expand Up @@ -207,7 +182,7 @@ - (id)initWithAsyncSocket:(GCDAsyncSocket *)newSocket configuration:(HTTPConfig
if (aConfig.queue)
{
connectionQueue = aConfig.queue;
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_retain(connectionQueue);
#endif
}
Expand Down Expand Up @@ -245,7 +220,7 @@ - (void)dealloc
{
HTTPLogTrace();

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(connectionQueue);
#endif

Expand Down Expand Up @@ -2715,7 +2690,7 @@ - (id)initWithServer:(HTTPServer *)aServer documentRoot:(NSString *)aDocumentRoo
if (q)
{
queue = q;
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_retain(queue);
#endif
}
Expand All @@ -2725,7 +2700,7 @@ - (id)initWithServer:(HTTPServer *)aServer documentRoot:(NSString *)aDocumentRoo

- (void)dealloc
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
if (queue) dispatch_release(queue);
#endif
}
Expand Down
27 changes: 1 addition & 26 deletions Core/HTTPServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +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 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
// Other flags: trace
static const int httpLogLevel = HTTP_LOG_LEVEL_INFO; // | HTTP_LOG_FLAG_TRACE;
Expand Down Expand Up @@ -139,7 +114,7 @@ - (void)dealloc

// Release all instance variables

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(serverQueue);
dispatch_release(connectionQueue);
#endif
Expand Down
32 changes: 3 additions & 29 deletions Core/Responses/HTTPAsyncFileResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,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 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
// Other flags: trace
static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE;
Expand Down Expand Up @@ -258,7 +232,7 @@ - (BOOL)openFileAndSetupReadSource
});

int theFileFD = fileFD;
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_source_t theReadSource = readSource;
#endif

Expand All @@ -270,7 +244,7 @@ - (BOOL)openFileAndSetupReadSource

HTTPLogTrace2(@"%@: cancelBlock - Close fd[%i]", THIS_FILE, theFileFD);

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(theReadSource);
#endif
close(theFileFD);
Expand Down Expand Up @@ -420,7 +394,7 @@ - (void)dealloc
{
HTTPLogTrace();

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
if (readQueue) dispatch_release(readQueue);
#endif

Expand Down
27 changes: 1 addition & 26 deletions Core/WebSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,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 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
// Other flags : trace
static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE;
Expand Down Expand Up @@ -218,7 +193,7 @@ - (void)dealloc
{
HTTPLogTrace();

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(websocketQueue);
#endif

Expand Down

0 comments on commit c615608

Please sign in to comment.