PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/GDataDefines.h

http://macfuse.googlecode.com/
C++ Header | 172 lines | 98 code | 25 blank | 49 comment | 6 complexity | acbb1e947135878eb1968c4bbca73793 MD5 | raw file
  1/* Copyright (c) 2008 Google Inc.
  2*
  3* Licensed under the Apache License, Version 2.0 (the "License");
  4* you may not use this file except in compliance with the License.
  5* You may obtain a copy of the License at
  6*
  7*     http://www.apache.org/licenses/LICENSE-2.0
  8*
  9* Unless required by applicable law or agreed to in writing, software
 10* distributed under the License is distributed on an "AS IS" BASIS,
 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12* See the License for the specific language governing permissions and
 13* limitations under the License.
 14*/
 15
 16//
 17// GDataDefines.h
 18//
 19
 20// Ensure Apple's conditionals we depend on are defined.
 21#import <TargetConditionals.h>
 22#import <AvailabilityMacros.h>
 23
 24//
 25// The developer may choose to define these in the project:
 26//
 27//   #define GDATA_TARGET_NAMESPACE Xxx  // preface all GData class names with Xxx (recommended for building plug-ins)
 28//   #define GDATA_FOUNDATION_ONLY 1     // builds without AppKit or Carbon (default for iPhone builds)
 29//   #define GDATA_SIMPLE_DESCRIPTIONS 1 // remove elaborate -description methods, reducing code size (default for iPhone release builds)
 30//   #define STRIP_GDATA_FETCH_LOGGING 1 // omit http logging code (default for iPhone release builds)
 31//
 32// Mac developers may find GDATA_SIMPLE_DESCRIPTIONS and STRIP_GDATA_FETCH_LOGGING useful for
 33// reducing code size.
 34//
 35
 36// Define later OS versions when building on earlier versions
 37#ifdef MAC_OS_X_VERSION_10_0
 38  #ifndef MAC_OS_X_VERSION_10_6
 39    #define MAC_OS_X_VERSION_10_6 1060
 40  #endif
 41#endif
 42
 43
 44#ifdef GDATA_TARGET_NAMESPACE
 45// prefix all GData class names with GDATA_TARGET_NAMESPACE for this target
 46  #import "GDataTargetNamespace.h"
 47#endif
 48
 49// Provide a common definition for externing constants/functions
 50#if defined(__cplusplus)
 51#define GDATA_EXTERN extern "C"
 52#else
 53#define GDATA_EXTERN extern
 54#endif
 55
 56#if TARGET_OS_IPHONE // iPhone SDK
 57
 58  #define GDATA_IPHONE 1
 59
 60#endif
 61
 62#if GDATA_IPHONE
 63
 64  #define GDATA_FOUNDATION_ONLY 1
 65
 66  #define GDATA_USES_LIBXML 1
 67
 68  #import "GDataXMLNode.h"
 69
 70  #define NSXMLDocument                  GDataXMLDocument
 71  #define NSXMLElement                   GDataXMLElement
 72  #define NSXMLNode                      GDataXMLNode
 73  #define NSXMLNodeKind                  GDataXMLNodeKind
 74  #define NSXMLInvalidKind               GDataXMLInvalidKind
 75  #define NSXMLDocumentKind              GDataXMLDocumentKind
 76  #define NSXMLElementKind               GDataXMLElementKind
 77  #define NSXMLAttributeKind             GDataXMLAttributeKind
 78  #define NSXMLNamespaceKind             GDataXMLNamespaceKind
 79  #define NSXMLProcessingInstructionKind GDataXMLDocumentKind
 80  #define NSXMLCommentKind               GDataXMLCommentKind
 81  #define NSXMLTextKind                  GDataXMLTextKind
 82  #define NSXMLDTDKind                   GDataXMLDTDKind
 83  #define NSXMLEntityDeclarationKind     GDataXMLEntityDeclarationKind
 84  #define NSXMLAttributeDeclarationKind  GDataXMLAttributeDeclarationKind
 85  #define NSXMLElementDeclarationKind    GDataXMLElementDeclarationKind
 86  #define NSXMLNotationDeclarationKind   GDataXMLNotationDeclarationKind
 87
 88  // properties used for retaining the XML tree in the classes that use them
 89  #define kGDataXMLDocumentPropertyKey @"_XMLDocument"
 90  #define kGDataXMLElementPropertyKey  @"_XMLElement"
 91#endif
 92
 93//
 94// GDATA_ASSERT is like NSAssert, but takes a variable number of arguments:
 95//
 96//     GDATA_ASSERT(condition, @"Problem in argument %@", argStr);
 97//
 98// GDATA_DEBUG_ASSERT is similar, but compiles in only for debug builds
 99//
100
101#ifndef GDATA_ASSERT
102  // we directly invoke the NSAssert handler so we can pass on the varargs
103  #if !defined(NS_BLOCK_ASSERTIONS)
104    #define GDATA_ASSERT(condition, ...)                                       \
105      do {                                                                     \
106        if (!(condition)) {                                                    \
107          [[NSAssertionHandler currentHandler]                                 \
108              handleFailureInFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
109                                 file:[NSString stringWithUTF8String:__FILE__] \
110                           lineNumber:__LINE__                                 \
111                          description:__VA_ARGS__];                            \
112        }                                                                      \
113      } while(0)
114  #else
115    #define GDATA_ASSERT(condition, ...) do { } while (0)
116  #endif // !defined(NS_BLOCK_ASSERTIONS)
117#endif // GDATA_ASSERT
118
119#ifndef GDATA_DEBUG_ASSERT
120  #if DEBUG
121    #define GDATA_DEBUG_ASSERT(condition, ...) GDATA_ASSERT(condition, __VA_ARGS__)
122  #else
123    #define GDATA_DEBUG_ASSERT(condition, ...) do { } while (0)
124  #endif
125#endif
126
127#ifndef GDATA_DEBUG_LOG
128  #if DEBUG
129    #define GDATA_DEBUG_LOG(...) NSLog(__VA_ARGS__)
130  #else
131    #define GDATA_DEBUG_LOG(...) do { } while (0)
132  #endif
133#endif
134
135//
136// Simple macros to allow building headers for non-ARC files
137// into ARC apps
138//
139
140#ifndef GDATA_REQUIRES_ARC
141  #if defined(__clang__)
142    #if __has_feature(objc_arc)
143      #define GDATA_REQUIRES_ARC 1
144    #endif
145  #endif
146#endif
147
148#if GDATA_REQUIRES_ARC
149  #define GDATA_UNSAFE_UNRETAINED __unsafe_unretained
150#else
151  #define GDATA_UNSAFE_UNRETAINED
152#endif
153
154//
155// To reduce code size on iPhone release builds, we compile out the helpful
156// description methods for GData objects
157//
158#ifndef GDATA_SIMPLE_DESCRIPTIONS
159  #if GDATA_IPHONE && !DEBUG
160    #define GDATA_SIMPLE_DESCRIPTIONS 1
161  #else
162    #define GDATA_SIMPLE_DESCRIPTIONS 0
163  #endif
164#endif
165
166#ifndef STRIP_GDATA_FETCH_LOGGING
167  #if GDATA_IPHONE && !DEBUG
168    #define STRIP_GDATA_FETCH_LOGGING 1
169  #else
170    #define STRIP_GDATA_FETCH_LOGGING 0
171  #endif
172#endif