FIRMessagingDefines.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef FIRMessaging_xcodeproj_FIRMessagingDefines_h
  17. #define FIRMessaging_xcodeproj_FIRMessagingDefines_h
  18. // WEAKIFY & STRONGIFY
  19. // Helper macro.
  20. #define _FIRMessaging_WEAKNAME(VAR) VAR##_weak_
  21. #define FIRMessaging_WEAKIFY(VAR) __weak __typeof__(VAR) _FIRMessaging_WEAKNAME(VAR) = (VAR);
  22. #define FIRMessaging_STRONGIFY(VAR) \
  23. _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\"") \
  24. __strong __typeof__(VAR) VAR = _FIRMessaging_WEAKNAME(VAR); \
  25. _Pragma("clang diagnostic pop")
  26. #ifndef _FIRMessaging_UL
  27. #define _FIRMessaging_UL(v) (unsigned long)(v)
  28. #endif
  29. #endif
  30. // Invalidates the initializer from which it's called.
  31. #ifndef FIRMessagingInvalidateInitializer
  32. #define FIRMessagingInvalidateInitializer() \
  33. do { \
  34. [self class]; /* Avoid warning of dead store to |self|. */ \
  35. NSAssert(NO, @"Invalid initializer."); \
  36. return nil; \
  37. } while (0)
  38. #endif