1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/GoogleToolboxSubset/GTMDefines.h Sat Mar 28 09:39:31 2009 -0700
1.3 @@ -0,0 +1,138 @@
1.4 +//
1.5 +// GTMDefines.h
1.6 +//
1.7 +// Copyright 2008 Google Inc.
1.8 +//
1.9 +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
1.10 +// use this file except in compliance with the License. You may obtain a copy
1.11 +// of the License at
1.12 +//
1.13 +// http://www.apache.org/licenses/LICENSE-2.0
1.14 +//
1.15 +// Unless required by applicable law or agreed to in writing, software
1.16 +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
1.17 +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1.18 +// License for the specific language governing permissions and limitations under
1.19 +// the License.
1.20 +//
1.21 +
1.22 +// ============================================================================
1.23 +
1.24 +// ----------------------------------------------------------------------------
1.25 +// CPP symbols that can be overridden in a prefix to control how the toolbox
1.26 +// is compiled.
1.27 +// ----------------------------------------------------------------------------
1.28 +
1.29 +
1.30 +// GTMHTTPFetcher will support logging by default but only hook its input
1.31 +// stream support for logging when requested. You can control the inclusion of
1.32 +// the code by providing your own definitions for these w/in a prefix header.
1.33 +//
1.34 +#ifndef GTM_HTTPFETCHER_ENABLE_LOGGING
1.35 +# define GTM_HTTPFETCHER_ENABLE_LOGGING 1
1.36 +#endif // GTM_HTTPFETCHER_ENABLE_LOGGING
1.37 +#ifndef GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING
1.38 +# define GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING 0
1.39 +#endif // GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING
1.40 +
1.41 +
1.42 +// _GTMDevLog & _GTMDevAssert
1.43 +//
1.44 +// _GTMDevLog & _GTMDevAssert are meant to be a very lightweight shell for
1.45 +// developer level errors. This implementation simply macros to NSLog/NSAssert.
1.46 +// It is not intended to be a general logging/reporting system.
1.47 +//
1.48 +// Please see http://code.google.com/p/google-toolbox-for-mac/wiki/DevLogNAssert
1.49 +// for a little more background on the usage of these macros.
1.50 +//
1.51 +// _GTMDevLog log some error/problem in debug builds
1.52 +// _GTMDevAssert assert if conditon isn't met w/in a method/function
1.53 +// in all builds.
1.54 +//
1.55 +// To replace this system, just provide different macro definitions in your
1.56 +// prefix header. Remember, any implementation you provide *must* be thread
1.57 +// safe since this could be called by anything in what ever situtation it has
1.58 +// been placed in.
1.59 +//
1.60 +
1.61 +// We only define the simple macros if nothing else has defined this.
1.62 +#ifndef _GTMDevLog
1.63 +
1.64 +#ifdef DEBUG
1.65 + #define _GTMDevLog(...) NSLog(__VA_ARGS__)
1.66 +#else
1.67 + #define _GTMDevLog(...) do { } while (0)
1.68 +#endif
1.69 +
1.70 +// we directly invoke the NSAssert handler so we can pass on the varargs
1.71 +// (NSAssert doesn't have a macro we can use that takes varargs)
1.72 +#if !defined(NS_BLOCK_ASSERTIONS)
1.73 +#define _GTMDevAssert(condition, ...) \
1.74 + do { \
1.75 + if (!(condition)) { \
1.76 + [[NSAssertionHandler currentHandler] \
1.77 + handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__] \
1.78 + file:[NSString stringWithCString:__FILE__] \
1.79 + lineNumber:__LINE__ \
1.80 + description:__VA_ARGS__]; \
1.81 + } \
1.82 + } while(0)
1.83 +#else // !defined(NS_BLOCK_ASSERTIONS)
1.84 +#define _GTMDevAssert(condition, ...) do { } while (0)
1.85 +#endif // !defined(NS_BLOCK_ASSERTIONS)
1.86 +
1.87 +#endif // _GTMDevLog
1.88 +
1.89 +// ============================================================================
1.90 +
1.91 +// ----------------------------------------------------------------------------
1.92 +// CPP symbols defined based on the project settings so the GTM code has
1.93 +// simple things to test against w/o scattering the knowledge of project
1.94 +// setting through all the code.
1.95 +// ----------------------------------------------------------------------------
1.96 +
1.97 +// Provide a single constant CPP symbol that all of GTM uses for ifdefing
1.98 +// iPhone code.
1.99 +#include <TargetConditionals.h>
1.100 +#if TARGET_OS_IPHONE // iPhone SDK
1.101 + // For iPhone specific stuff
1.102 + #define GTM_IPHONE_SDK 1
1.103 +#else
1.104 + // For MacOS specific stuff
1.105 + #define GTM_MACOS_SDK 1
1.106 +#endif
1.107 +
1.108 +// To simplify support for 64bit (and Leopard in general), we provide the type
1.109 +// defines for non Leopard SDKs
1.110 +#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
1.111 + // NSInteger/NSUInteger and Max/Mins
1.112 + #ifndef NSINTEGER_DEFINED
1.113 + #if __LP64__ || NS_BUILD_32_LIKE_64
1.114 + typedef long NSInteger;
1.115 + typedef unsigned long NSUInteger;
1.116 + #else
1.117 + typedef int NSInteger;
1.118 + typedef unsigned int NSUInteger;
1.119 + #endif
1.120 + #define NSIntegerMax LONG_MAX
1.121 + #define NSIntegerMin LONG_MIN
1.122 + #define NSUIntegerMax ULONG_MAX
1.123 + #define NSINTEGER_DEFINED 1
1.124 + #endif // NSINTEGER_DEFINED
1.125 + // CGFloat
1.126 + #ifndef CGFLOAT_DEFINED
1.127 + #if defined(__LP64__) && __LP64__
1.128 + // This really is an untested path (64bit on Tiger?)
1.129 + typedef double CGFloat;
1.130 + #define CGFLOAT_MIN DBL_MIN
1.131 + #define CGFLOAT_MAX DBL_MAX
1.132 + #define CGFLOAT_IS_DOUBLE 1
1.133 + #else /* !defined(__LP64__) || !__LP64__ */
1.134 + typedef float CGFloat;
1.135 + #define CGFLOAT_MIN FLT_MIN
1.136 + #define CGFLOAT_MAX FLT_MAX
1.137 + #define CGFLOAT_IS_DOUBLE 0
1.138 + #endif /* !defined(__LP64__) || !__LP64__ */
1.139 + #define CGFLOAT_DEFINED 1
1.140 + #endif // CGFLOAT_DEFINED
1.141 +#endif // MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4