PPOTMacros.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // PPOTMacros.h
  3. // Copyright © 2015 PayPal, Inc. All rights reserved.
  4. //
  5. #import <Foundation/Foundation.h>
  6. #define PPSDKLog(format, args...) NSLog(@"%@", [NSString stringWithFormat:@"PayPal OneTouchCoreSDK: %@", [NSString stringWithFormat:format, ## args]])
  7. // PPLog is a replacement for NSLog that logs iff DEBUG is set.
  8. #ifdef DEBUG
  9. #define PPLog(format, args...) NSLog(format, ## args)
  10. #else
  11. #define PPLog(format, args...)
  12. #endif
  13. // PPAssert* are replacements for NSAssert, NSAssert1, etc.
  14. // Whether the latter are enabled or disabled depends upon NS_BLOCK_ASSERTIONS;
  15. // we set NS_BLOCK_ASSERTIONS inside our .pch files based upon DEBUG.
  16. // Those #defines are a little bit fragile, and could easily accidentally get broken in the future.
  17. // So PPAssert* depend explicitly on DEBUG, just to be a bit more safe.
  18. #ifdef DEBUG
  19. #define PPAssert(condition, desc...) NSAssert(condition, desc)
  20. #define PPAssert1(condition, desc, arg1) NSAssert1(condition, desc, arg1)
  21. #define PPAssert2(condition, desc, arg1, arg2) NSAssert2(condition, desc, arg1, arg2)
  22. #define PPAssert3(condition, desc, arg1, arg2, arg3) NSAssert3(condition, desc, arg1, arg2, arg3)
  23. #define PPAssert4(condition, desc, arg1, arg2, arg3, arg4) NSAssert4(condition, desc, arg1, arg2, arg3, arg4)
  24. #define PPAssert5(condition, desc, arg1, arg2, arg3, arg4, arg5) NSAssert5(condition, desc, arg1, arg2, arg3, arg4, arg5)
  25. #define PPParameterAssert(condition) NSParameterAssert(condition)
  26. #else
  27. #define PPAssert(condition, desc, ...)
  28. #define PPAssert1(condition, desc, arg1)
  29. #define PPAssert2(condition, desc, arg1, arg2)
  30. #define PPAssert3(condition, desc, arg1, arg2, arg3)
  31. #define PPAssert4(condition, desc, arg1, arg2, arg3, arg4)
  32. #define PPAssert5(condition, desc, arg1, arg2, arg3, arg4, arg5)
  33. #define PPParameterAssert(condition)
  34. #endif
  35. /**
  36. Macros used by PayPal payments
  37. */
  38. @interface PPOTMacros : NSObject
  39. /**
  40. @return the iOS major version number
  41. */
  42. + (NSUInteger)deviceSystemMajorVersion;
  43. @end
  44. #define iOS_MAJOR_VERSION [PPOTMacros deviceSystemMajorVersion]
  45. #define iOS_9_PLUS ([PPOTMacros deviceSystemMajorVersion] >= 9)
  46. #define iOS_8_PLUS ([PPOTMacros deviceSystemMajorVersion] >= 8)
  47. #define iOS_7_PLUS ([PPOTMacros deviceSystemMajorVersion] >= 7)
  48. #define iOS_6_PLUS ([PPOTMacros deviceSystemMajorVersion] >= 6)
  49. #define iOS_6 ([PPOTMacros deviceSystemMajorVersion] == 6)
  50. #define iOS_5 ([PPOTMacros deviceSystemMajorVersion] == 5)
  51. #define FORCE_VALUE_OR_NULL(x) (x ? x : [NSNull null])
  52. // Use the CARDIO_STR() macro around sensitive string literals.
  53. // E.g., `CARDIO_STR(@"http://top_secret_url.paypal.com")`.
  54. // For release builds, uses of this macro get preprocessed by fabfile.py to obfuscate the string.
  55. // PLEASE do not include any whitespace on either side of the string inside the parentheses;
  56. // i.e., between `CARDIO_STR(` and `@"abc"`, or between `@"abc"` and the closing `)`.
  57. #define CARDIO_STR(string) string
  58. #define PPRGBAUIColor(RR, GG, BB, AA) ([UIColor colorWithRed:(RR)/255.0f green:(GG)/255.0f blue:(BB)/255.0f alpha:(AA)/255.0f])