From a906d29ffdb9210a48cb30e877f130b0716efa0f Mon Sep 17 00:00:00 2001 From: Nuntius Date: Mon, 27 Sep 2021 17:25:19 +0200 Subject: [PATCH] Add NS_SWIFT_NOTHROW and NS_NOESCAPE --- Headers/Foundation/NSObjCRuntime.h | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Headers/Foundation/NSObjCRuntime.h b/Headers/Foundation/NSObjCRuntime.h index f15c65c0ff..9d235c9266 100644 --- a/Headers/Foundation/NSObjCRuntime.h +++ b/Headers/Foundation/NSObjCRuntime.h @@ -162,6 +162,37 @@ extern "C" { # define NS_ASSUME_NONNULL_END #endif +#if !__has_feature(nullability) +# ifndef _Nullable +# define _Nullable +# endif +# ifndef _Nonnull +# define _Nonnull +# endif +# ifndef _Null_unspecified +# define _Null_unspecified +# endif +#endif + +/* + * Any argument that is passed inside a block is not going to escape + * the runtime of the function itself. + */ +#if __has_attribute(noescape) +# define NS_NOESCAPE __attribute__((noescape)) +#else +# define NS_NOESCAPE +#endif + +/* + * Prevent NSError from being imported by Swift as a method that throws. + */ +#if __has_attribute(swift_error) +# define NS_SWIFT_NOTHROW __attribute__((swift_error(none))) +#else +# define NS_SWIFT_NOTHROW +#endif + /* * Backwards compatibility macro for instance type. */