/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 · 7 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. // GDataDefines.h
  17. //
  18. // Ensure Apple's conditionals we depend on are defined.
  19. #import <TargetConditionals.h>
  20. #import <AvailabilityMacros.h>
  21. //
  22. // The developer may choose to define these in the project:
  23. //
  24. // #define GDATA_TARGET_NAMESPACE Xxx // preface all GData class names with Xxx (recommended for building plug-ins)
  25. // #define GDATA_FOUNDATION_ONLY 1 // builds without AppKit or Carbon (default for iPhone builds)
  26. // #define GDATA_SIMPLE_DESCRIPTIONS 1 // remove elaborate -description methods, reducing code size (default for iPhone release builds)
  27. // #define STRIP_GDATA_FETCH_LOGGING 1 // omit http logging code (default for iPhone release builds)
  28. //
  29. // Mac developers may find GDATA_SIMPLE_DESCRIPTIONS and STRIP_GDATA_FETCH_LOGGING useful for
  30. // reducing code size.
  31. //
  32. // Define later OS versions when building on earlier versions
  33. #ifdef MAC_OS_X_VERSION_10_0
  34. #ifndef MAC_OS_X_VERSION_10_6
  35. #define MAC_OS_X_VERSION_10_6 1060
  36. #endif
  37. #endif
  38. #ifdef GDATA_TARGET_NAMESPACE
  39. // prefix all GData class names with GDATA_TARGET_NAMESPACE for this target
  40. #import "GDataTargetNamespace.h"
  41. #endif
  42. // Provide a common definition for externing constants/functions
  43. #if defined(__cplusplus)
  44. #define GDATA_EXTERN extern "C"
  45. #else
  46. #define GDATA_EXTERN extern
  47. #endif
  48. #if TARGET_OS_IPHONE // iPhone SDK
  49. #define GDATA_IPHONE 1
  50. #endif
  51. #if GDATA_IPHONE
  52. #define GDATA_FOUNDATION_ONLY 1
  53. #define GDATA_USES_LIBXML 1
  54. #import "GDataXMLNode.h"
  55. #define NSXMLDocument GDataXMLDocument
  56. #define NSXMLElement GDataXMLElement
  57. #define NSXMLNode GDataXMLNode
  58. #define NSXMLNodeKind GDataXMLNodeKind
  59. #define NSXMLInvalidKind GDataXMLInvalidKind
  60. #define NSXMLDocumentKind GDataXMLDocumentKind
  61. #define NSXMLElementKind GDataXMLElementKind
  62. #define NSXMLAttributeKind GDataXMLAttributeKind
  63. #define NSXMLNamespaceKind GDataXMLNamespaceKind
  64. #define NSXMLProcessingInstructionKind GDataXMLDocumentKind
  65. #define NSXMLCommentKind GDataXMLCommentKind
  66. #define NSXMLTextKind GDataXMLTextKind
  67. #define NSXMLDTDKind GDataXMLDTDKind
  68. #define NSXMLEntityDeclarationKind GDataXMLEntityDeclarationKind
  69. #define NSXMLAttributeDeclarationKind GDataXMLAttributeDeclarationKind
  70. #define NSXMLElementDeclarationKind GDataXMLElementDeclarationKind
  71. #define NSXMLNotationDeclarationKind GDataXMLNotationDeclarationKind
  72. // properties used for retaining the XML tree in the classes that use them
  73. #define kGDataXMLDocumentPropertyKey @"_XMLDocument"
  74. #define kGDataXMLElementPropertyKey @"_XMLElement"
  75. #endif
  76. //
  77. // GDATA_ASSERT is like NSAssert, but takes a variable number of arguments:
  78. //
  79. // GDATA_ASSERT(condition, @"Problem in argument %@", argStr);
  80. //
  81. // GDATA_DEBUG_ASSERT is similar, but compiles in only for debug builds
  82. //
  83. #ifndef GDATA_ASSERT
  84. // we directly invoke the NSAssert handler so we can pass on the varargs
  85. #if !defined(NS_BLOCK_ASSERTIONS)
  86. #define GDATA_ASSERT(condition, ...) \
  87. do { \
  88. if (!(condition)) { \
  89. [[NSAssertionHandler currentHandler] \
  90. handleFailureInFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
  91. file:[NSString stringWithUTF8String:__FILE__] \
  92. lineNumber:__LINE__ \
  93. description:__VA_ARGS__]; \
  94. } \
  95. } while(0)
  96. #else
  97. #define GDATA_ASSERT(condition, ...) do { } while (0)
  98. #endif // !defined(NS_BLOCK_ASSERTIONS)
  99. #endif // GDATA_ASSERT
  100. #ifndef GDATA_DEBUG_ASSERT
  101. #if DEBUG
  102. #define GDATA_DEBUG_ASSERT(condition, ...) GDATA_ASSERT(condition, __VA_ARGS__)
  103. #else
  104. #define GDATA_DEBUG_ASSERT(condition, ...) do { } while (0)
  105. #endif
  106. #endif
  107. #ifndef GDATA_DEBUG_LOG
  108. #if DEBUG
  109. #define GDATA_DEBUG_LOG(...) NSLog(__VA_ARGS__)
  110. #else
  111. #define GDATA_DEBUG_LOG(...) do { } while (0)
  112. #endif
  113. #endif
  114. //
  115. // Simple macros to allow building headers for non-ARC files
  116. // into ARC apps
  117. //
  118. #ifndef GDATA_REQUIRES_ARC
  119. #if defined(__clang__)
  120. #if __has_feature(objc_arc)
  121. #define GDATA_REQUIRES_ARC 1
  122. #endif
  123. #endif
  124. #endif
  125. #if GDATA_REQUIRES_ARC
  126. #define GDATA_UNSAFE_UNRETAINED __unsafe_unretained
  127. #else
  128. #define GDATA_UNSAFE_UNRETAINED
  129. #endif
  130. //
  131. // To reduce code size on iPhone release builds, we compile out the helpful
  132. // description methods for GData objects
  133. //
  134. #ifndef GDATA_SIMPLE_DESCRIPTIONS
  135. #if GDATA_IPHONE && !DEBUG
  136. #define GDATA_SIMPLE_DESCRIPTIONS 1
  137. #else
  138. #define GDATA_SIMPLE_DESCRIPTIONS 0
  139. #endif
  140. #endif
  141. #ifndef STRIP_GDATA_FETCH_LOGGING
  142. #if GDATA_IPHONE && !DEBUG
  143. #define STRIP_GDATA_FETCH_LOGGING 1
  144. #else
  145. #define STRIP_GDATA_FETCH_LOGGING 0
  146. #endif
  147. #endif