2 * Copyright 2017 Google
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef FIRMessaging_xcodeproj_FIRMessagingDefines_h
18 #define FIRMessaging_xcodeproj_FIRMessagingDefines_h
20 #define _FIRMessaging_VERBOSE_LOGGING 1
23 #if (_FIRMessaging_VERBOSE_LOGGING)
24 #define FIRMessaging_DEV_VERBOSE_LOG(...) NSLog(__VA_ARGS__)
26 #define FIRMessaging_DEV_VERBOSE_LOG(...) do { } while (0)
27 #endif // FIRMessaging_VERBOSE_LOGGING
30 // WEAKIFY & STRONGIFY
32 #define _FIRMessaging_WEAKNAME(VAR) VAR ## _weak_
34 #define FIRMessaging_WEAKIFY(VAR) __weak __typeof__(VAR) _FIRMessaging_WEAKNAME(VAR) = (VAR);
36 #define FIRMessaging_STRONGIFY(VAR) \
37 _Pragma("clang diagnostic push") \
38 _Pragma("clang diagnostic ignored \"-Wshadow\"") \
39 __strong __typeof__(VAR) VAR = _FIRMessaging_WEAKNAME(VAR); \
40 _Pragma("clang diagnostic pop")
43 // Type Conversions (used for NSInteger etc)
44 #ifndef _FIRMessaging_L
45 #define _FIRMessaging_L(v) (long)(v)
48 #ifndef _FIRMessaging_UL
49 #define _FIRMessaging_UL(v) (unsigned long)(v)
55 #ifndef _FIRMessagingDevAssert
56 // we directly invoke the NSAssert handler so we can pass on the varargs
57 // (NSAssert doesn't have a macro we can use that takes varargs)
58 #if !defined(NS_BLOCK_ASSERTIONS)
59 #define _FIRMessagingDevAssert(condition, ...) \
62 [[NSAssertionHandler currentHandler] \
63 handleFailureInFunction:(NSString *) \
64 [NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
65 file:(NSString *)[NSString stringWithUTF8String:__FILE__] \
67 description:__VA_ARGS__]; \
70 #else // !defined(NS_BLOCK_ASSERTIONS)
71 #define _FIRMessagingDevAssert(condition, ...) do { } while (0)
72 #endif // !defined(NS_BLOCK_ASSERTIONS)
74 #endif // _FIRMessagingDevAssert
76 // Invalidates the initializer from which it's called.
77 #ifndef FIRMessagingInvalidateInitializer
78 #define FIRMessagingInvalidateInitializer() \
80 [self class]; /* Avoid warning of dead store to |self|. */ \
81 _FIRMessagingDevAssert(NO, @"Invalid initializer."); \