jens@13: // jens@13: // GTMDefines.h jens@13: // jens@13: // Copyright 2008 Google Inc. jens@13: // jens@13: // Licensed under the Apache License, Version 2.0 (the "License"); you may not jens@13: // use this file except in compliance with the License. You may obtain a copy jens@13: // of the License at jens@13: // jens@13: // http://www.apache.org/licenses/LICENSE-2.0 jens@13: // jens@13: // Unless required by applicable law or agreed to in writing, software jens@13: // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT jens@13: // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the jens@13: // License for the specific language governing permissions and limitations under jens@13: // the License. jens@13: // jens@13: jens@13: // ============================================================================ jens@13: jens@13: // ---------------------------------------------------------------------------- jens@13: // CPP symbols that can be overridden in a prefix to control how the toolbox jens@13: // is compiled. jens@13: // ---------------------------------------------------------------------------- jens@13: jens@13: jens@13: // GTMHTTPFetcher will support logging by default but only hook its input jens@13: // stream support for logging when requested. You can control the inclusion of jens@13: // the code by providing your own definitions for these w/in a prefix header. jens@13: // jens@13: #ifndef GTM_HTTPFETCHER_ENABLE_LOGGING jens@13: # define GTM_HTTPFETCHER_ENABLE_LOGGING 1 jens@13: #endif // GTM_HTTPFETCHER_ENABLE_LOGGING jens@13: #ifndef GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING jens@13: # define GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING 0 jens@13: #endif // GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING jens@13: jens@13: jens@13: // _GTMDevLog & _GTMDevAssert jens@13: // jens@13: // _GTMDevLog & _GTMDevAssert are meant to be a very lightweight shell for jens@13: // developer level errors. This implementation simply macros to NSLog/NSAssert. jens@13: // It is not intended to be a general logging/reporting system. jens@13: // jens@13: // Please see http://code.google.com/p/google-toolbox-for-mac/wiki/DevLogNAssert jens@13: // for a little more background on the usage of these macros. jens@13: // jens@13: // _GTMDevLog log some error/problem in debug builds jens@13: // _GTMDevAssert assert if conditon isn't met w/in a method/function jens@13: // in all builds. jens@13: // jens@13: // To replace this system, just provide different macro definitions in your jens@13: // prefix header. Remember, any implementation you provide *must* be thread jens@13: // safe since this could be called by anything in what ever situtation it has jens@13: // been placed in. jens@13: // jens@13: jens@13: // We only define the simple macros if nothing else has defined this. jens@13: #ifndef _GTMDevLog jens@13: jens@13: #ifdef DEBUG jens@13: #define _GTMDevLog(...) NSLog(__VA_ARGS__) jens@13: #else jens@13: #define _GTMDevLog(...) do { } while (0) jens@13: #endif jens@13: jens@13: // we directly invoke the NSAssert handler so we can pass on the varargs jens@13: // (NSAssert doesn't have a macro we can use that takes varargs) jens@13: #if !defined(NS_BLOCK_ASSERTIONS) jens@13: #define _GTMDevAssert(condition, ...) \ jens@13: do { \ jens@13: if (!(condition)) { \ jens@13: [[NSAssertionHandler currentHandler] \ jens@13: handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__] \ jens@13: file:[NSString stringWithCString:__FILE__] \ jens@13: lineNumber:__LINE__ \ jens@13: description:__VA_ARGS__]; \ jens@13: } \ jens@13: } while(0) jens@13: #else // !defined(NS_BLOCK_ASSERTIONS) jens@13: #define _GTMDevAssert(condition, ...) do { } while (0) jens@13: #endif // !defined(NS_BLOCK_ASSERTIONS) jens@13: jens@13: #endif // _GTMDevLog jens@13: jens@13: // ============================================================================ jens@13: jens@13: // ---------------------------------------------------------------------------- jens@13: // CPP symbols defined based on the project settings so the GTM code has jens@13: // simple things to test against w/o scattering the knowledge of project jens@13: // setting through all the code. jens@13: // ---------------------------------------------------------------------------- jens@13: jens@13: // Provide a single constant CPP symbol that all of GTM uses for ifdefing jens@13: // iPhone code. jens@13: #include jens@13: #if TARGET_OS_IPHONE // iPhone SDK jens@13: // For iPhone specific stuff jens@13: #define GTM_IPHONE_SDK 1 jens@13: #else jens@13: // For MacOS specific stuff jens@13: #define GTM_MACOS_SDK 1 jens@13: #endif jens@13: jens@13: // To simplify support for 64bit (and Leopard in general), we provide the type jens@13: // defines for non Leopard SDKs jens@13: #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 jens@13: // NSInteger/NSUInteger and Max/Mins jens@13: #ifndef NSINTEGER_DEFINED jens@13: #if __LP64__ || NS_BUILD_32_LIKE_64 jens@13: typedef long NSInteger; jens@13: typedef unsigned long NSUInteger; jens@13: #else jens@13: typedef int NSInteger; jens@13: typedef unsigned int NSUInteger; jens@13: #endif jens@13: #define NSIntegerMax LONG_MAX jens@13: #define NSIntegerMin LONG_MIN jens@13: #define NSUIntegerMax ULONG_MAX jens@13: #define NSINTEGER_DEFINED 1 jens@13: #endif // NSINTEGER_DEFINED jens@13: // CGFloat jens@13: #ifndef CGFLOAT_DEFINED jens@13: #if defined(__LP64__) && __LP64__ jens@13: // This really is an untested path (64bit on Tiger?) jens@13: typedef double CGFloat; jens@13: #define CGFLOAT_MIN DBL_MIN jens@13: #define CGFLOAT_MAX DBL_MAX jens@13: #define CGFLOAT_IS_DOUBLE 1 jens@13: #else /* !defined(__LP64__) || !__LP64__ */ jens@13: typedef float CGFloat; jens@13: #define CGFLOAT_MIN FLT_MIN jens@13: #define CGFLOAT_MAX FLT_MAX jens@13: #define CGFLOAT_IS_DOUBLE 0 jens@13: #endif /* !defined(__LP64__) || !__LP64__ */ jens@13: #define CGFLOAT_DEFINED 1 jens@13: #endif // CGFLOAT_DEFINED jens@13: #endif // MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4