Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Commit 51d18b3

Browse files
committed
Add macros for backward compatible nullability support.
1 parent fb0e813 commit 51d18b3

File tree

1 file changed

+48
-9
lines changed

1 file changed

+48
-9
lines changed

ParseUI/Other/ParseUIConstants.h

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,58 @@
1919
*
2020
*/
2121

22+
#import <Availability.h>
23+
#import <TargetConditionals.h>
24+
2225
#ifndef ParseUI_ParseUIConstants_h
2326
#define ParseUI_ParseUIConstants_h
2427

28+
///--------------------------------------
29+
/// @name Deprecated Macros
30+
///--------------------------------------
31+
2532
#ifndef PARSE_UI_DEPRECATED
26-
#ifdef __deprecated_msg
27-
#define PARSE_UI_DEPRECATED(_MSG) (deprecated(_MSG))
28-
#else
29-
#ifdef __deprecated
30-
#define PARSE_UI_DEPRECATED(_MSG) (deprecated)
31-
#else
32-
#define PARSE_UI_DEPRECATED(_MSG)
33-
#endif
34-
#endif
33+
# ifdef __deprecated_msg
34+
# define PARSE_UI_DEPRECATED(_MSG) (deprecated(_MSG))
35+
# else
36+
# ifdef __deprecated
37+
# define PARSE_UI_DEPRECATED(_MSG) (deprecated)
38+
# else
39+
# define PARSE_UI_DEPRECATED(_MSG)
40+
# endif
41+
# endif
42+
#endif
43+
44+
///--------------------------------------
45+
/// @name Nullability Support
46+
///--------------------------------------
47+
48+
#if __has_feature(nullability)
49+
# define PFUI_NULLABLE nullable
50+
# define PFUI_NULLABLE_S __nullable
51+
# define PFUI_NULL_UNSPECIFIED null_unspecified
52+
# define PFUI_NULLABLE_PROPERTY nullable,
53+
#else
54+
# define PFUI_NULLABLE
55+
# define PFUI_NULLABLE_S
56+
# define PFUI_NULL_UNSPECIFIED
57+
# define PFUI_NULLABLE_PROPERTY
58+
#endif
59+
60+
#if __has_feature(assume_nonnull)
61+
# ifdef NS_ASSUME_NONNULL_BEGIN
62+
# define PFUI_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
63+
# else
64+
# define PFUI_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
65+
# endif
66+
# ifdef NS_ASSUME_NONNULL_END
67+
# define PFUI_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
68+
# else
69+
# define PFUI_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
70+
# endif
71+
#else
72+
# define PFUI_ASSUME_NONNULL_BEGIN
73+
# define PFUI_ASSUME_NONNULL_END
3574
#endif
3675

3776
#endif

0 commit comments

Comments
 (0)