jens@13
|
1 |
//
|
jens@13
|
2 |
// GTMDefines.h
|
jens@13
|
3 |
//
|
jens@13
|
4 |
// Copyright 2008 Google Inc.
|
jens@13
|
5 |
//
|
jens@13
|
6 |
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
jens@13
|
7 |
// use this file except in compliance with the License. You may obtain a copy
|
jens@13
|
8 |
// of the License at
|
jens@13
|
9 |
//
|
jens@13
|
10 |
// http://www.apache.org/licenses/LICENSE-2.0
|
jens@13
|
11 |
//
|
jens@13
|
12 |
// Unless required by applicable law or agreed to in writing, software
|
jens@13
|
13 |
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
jens@13
|
14 |
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
jens@13
|
15 |
// License for the specific language governing permissions and limitations under
|
jens@13
|
16 |
// the License.
|
jens@13
|
17 |
//
|
jens@13
|
18 |
|
jens@13
|
19 |
// ============================================================================
|
jens@13
|
20 |
|
jens@13
|
21 |
// ----------------------------------------------------------------------------
|
jens@13
|
22 |
// CPP symbols that can be overridden in a prefix to control how the toolbox
|
jens@13
|
23 |
// is compiled.
|
jens@13
|
24 |
// ----------------------------------------------------------------------------
|
jens@13
|
25 |
|
jens@13
|
26 |
|
jens@13
|
27 |
// GTMHTTPFetcher will support logging by default but only hook its input
|
jens@13
|
28 |
// stream support for logging when requested. You can control the inclusion of
|
jens@13
|
29 |
// the code by providing your own definitions for these w/in a prefix header.
|
jens@13
|
30 |
//
|
jens@13
|
31 |
#ifndef GTM_HTTPFETCHER_ENABLE_LOGGING
|
jens@13
|
32 |
# define GTM_HTTPFETCHER_ENABLE_LOGGING 1
|
jens@13
|
33 |
#endif // GTM_HTTPFETCHER_ENABLE_LOGGING
|
jens@13
|
34 |
#ifndef GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING
|
jens@13
|
35 |
# define GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING 0
|
jens@13
|
36 |
#endif // GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING
|
jens@13
|
37 |
|
jens@13
|
38 |
|
jens@13
|
39 |
// _GTMDevLog & _GTMDevAssert
|
jens@13
|
40 |
//
|
jens@13
|
41 |
// _GTMDevLog & _GTMDevAssert are meant to be a very lightweight shell for
|
jens@13
|
42 |
// developer level errors. This implementation simply macros to NSLog/NSAssert.
|
jens@13
|
43 |
// It is not intended to be a general logging/reporting system.
|
jens@13
|
44 |
//
|
jens@13
|
45 |
// Please see http://code.google.com/p/google-toolbox-for-mac/wiki/DevLogNAssert
|
jens@13
|
46 |
// for a little more background on the usage of these macros.
|
jens@13
|
47 |
//
|
jens@13
|
48 |
// _GTMDevLog log some error/problem in debug builds
|
jens@13
|
49 |
// _GTMDevAssert assert if conditon isn't met w/in a method/function
|
jens@13
|
50 |
// in all builds.
|
jens@13
|
51 |
//
|
jens@13
|
52 |
// To replace this system, just provide different macro definitions in your
|
jens@13
|
53 |
// prefix header. Remember, any implementation you provide *must* be thread
|
jens@13
|
54 |
// safe since this could be called by anything in what ever situtation it has
|
jens@13
|
55 |
// been placed in.
|
jens@13
|
56 |
//
|
jens@13
|
57 |
|
jens@13
|
58 |
// We only define the simple macros if nothing else has defined this.
|
jens@13
|
59 |
#ifndef _GTMDevLog
|
jens@13
|
60 |
|
jens@13
|
61 |
#ifdef DEBUG
|
jens@13
|
62 |
#define _GTMDevLog(...) NSLog(__VA_ARGS__)
|
jens@13
|
63 |
#else
|
jens@13
|
64 |
#define _GTMDevLog(...) do { } while (0)
|
jens@13
|
65 |
#endif
|
jens@13
|
66 |
|
jens@13
|
67 |
// we directly invoke the NSAssert handler so we can pass on the varargs
|
jens@13
|
68 |
// (NSAssert doesn't have a macro we can use that takes varargs)
|
jens@13
|
69 |
#if !defined(NS_BLOCK_ASSERTIONS)
|
jens@13
|
70 |
#define _GTMDevAssert(condition, ...) \
|
jens@13
|
71 |
do { \
|
jens@13
|
72 |
if (!(condition)) { \
|
jens@13
|
73 |
[[NSAssertionHandler currentHandler] \
|
jens@13
|
74 |
handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__] \
|
jens@13
|
75 |
file:[NSString stringWithCString:__FILE__] \
|
jens@13
|
76 |
lineNumber:__LINE__ \
|
jens@13
|
77 |
description:__VA_ARGS__]; \
|
jens@13
|
78 |
} \
|
jens@13
|
79 |
} while(0)
|
jens@13
|
80 |
#else // !defined(NS_BLOCK_ASSERTIONS)
|
jens@13
|
81 |
#define _GTMDevAssert(condition, ...) do { } while (0)
|
jens@13
|
82 |
#endif // !defined(NS_BLOCK_ASSERTIONS)
|
jens@13
|
83 |
|
jens@13
|
84 |
#endif // _GTMDevLog
|
jens@13
|
85 |
|
jens@13
|
86 |
// ============================================================================
|
jens@13
|
87 |
|
jens@13
|
88 |
// ----------------------------------------------------------------------------
|
jens@13
|
89 |
// CPP symbols defined based on the project settings so the GTM code has
|
jens@13
|
90 |
// simple things to test against w/o scattering the knowledge of project
|
jens@13
|
91 |
// setting through all the code.
|
jens@13
|
92 |
// ----------------------------------------------------------------------------
|
jens@13
|
93 |
|
jens@13
|
94 |
// Provide a single constant CPP symbol that all of GTM uses for ifdefing
|
jens@13
|
95 |
// iPhone code.
|
jens@13
|
96 |
#include <TargetConditionals.h>
|
jens@13
|
97 |
#if TARGET_OS_IPHONE // iPhone SDK
|
jens@13
|
98 |
// For iPhone specific stuff
|
jens@13
|
99 |
#define GTM_IPHONE_SDK 1
|
jens@13
|
100 |
#else
|
jens@13
|
101 |
// For MacOS specific stuff
|
jens@13
|
102 |
#define GTM_MACOS_SDK 1
|
jens@13
|
103 |
#endif
|
jens@13
|
104 |
|
jens@13
|
105 |
// To simplify support for 64bit (and Leopard in general), we provide the type
|
jens@13
|
106 |
// defines for non Leopard SDKs
|
jens@13
|
107 |
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
|
jens@13
|
108 |
// NSInteger/NSUInteger and Max/Mins
|
jens@13
|
109 |
#ifndef NSINTEGER_DEFINED
|
jens@13
|
110 |
#if __LP64__ || NS_BUILD_32_LIKE_64
|
jens@13
|
111 |
typedef long NSInteger;
|
jens@13
|
112 |
typedef unsigned long NSUInteger;
|
jens@13
|
113 |
#else
|
jens@13
|
114 |
typedef int NSInteger;
|
jens@13
|
115 |
typedef unsigned int NSUInteger;
|
jens@13
|
116 |
#endif
|
jens@13
|
117 |
#define NSIntegerMax LONG_MAX
|
jens@13
|
118 |
#define NSIntegerMin LONG_MIN
|
jens@13
|
119 |
#define NSUIntegerMax ULONG_MAX
|
jens@13
|
120 |
#define NSINTEGER_DEFINED 1
|
jens@13
|
121 |
#endif // NSINTEGER_DEFINED
|
jens@13
|
122 |
// CGFloat
|
jens@13
|
123 |
#ifndef CGFLOAT_DEFINED
|
jens@13
|
124 |
#if defined(__LP64__) && __LP64__
|
jens@13
|
125 |
// This really is an untested path (64bit on Tiger?)
|
jens@13
|
126 |
typedef double CGFloat;
|
jens@13
|
127 |
#define CGFLOAT_MIN DBL_MIN
|
jens@13
|
128 |
#define CGFLOAT_MAX DBL_MAX
|
jens@13
|
129 |
#define CGFLOAT_IS_DOUBLE 1
|
jens@13
|
130 |
#else /* !defined(__LP64__) || !__LP64__ */
|
jens@13
|
131 |
typedef float CGFloat;
|
jens@13
|
132 |
#define CGFLOAT_MIN FLT_MIN
|
jens@13
|
133 |
#define CGFLOAT_MAX FLT_MAX
|
jens@13
|
134 |
#define CGFLOAT_IS_DOUBLE 0
|
jens@13
|
135 |
#endif /* !defined(__LP64__) || !__LP64__ */
|
jens@13
|
136 |
#define CGFLOAT_DEFINED 1
|
jens@13
|
137 |
#endif // CGFLOAT_DEFINED
|
jens@13
|
138 |
#endif // MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
|