Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 89156eb

Browse files
authored
Add availability check for noescape attribute (#2897)
1 parent f52bc78 commit 89156eb

10 files changed

Lines changed: 27 additions & 18 deletions

File tree

AsyncDisplayKit/ASCollectionNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ NS_ASSUME_NONNULL_BEGIN
171171
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
172172
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
173173
*/
174-
- (void)performBatchAnimated:(BOOL)animated updates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
174+
- (void)performBatchAnimated:(BOOL)animated updates:(nullable AS_NOESCAPE void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
175175

176176
/**
177177
* Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread.
@@ -182,7 +182,7 @@ NS_ASSUME_NONNULL_BEGIN
182182
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
183183
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
184184
*/
185-
- (void)performBatchUpdates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
185+
- (void)performBatchUpdates:(nullable AS_NOESCAPE void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
186186

187187
/**
188188
* Blocks execution of the main thread until all section and item updates are committed to the view. This method must be called from the main thread.

AsyncDisplayKit/ASCollectionView.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ NS_ASSUME_NONNULL_BEGIN
225225
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
226226
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
227227
*/
228-
- (void)performBatchAnimated:(BOOL)animated updates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion ASDISPLAYNODE_DEPRECATED_MSG("Use ASCollectionNode method instead.");
228+
- (void)performBatchAnimated:(BOOL)animated updates:(nullable AS_NOESCAPE void (^)())updates completion:(nullable void (^)(BOOL finished))completion ASDISPLAYNODE_DEPRECATED_MSG("Use ASCollectionNode method instead.");
229229

230230
/**
231231
* Perform a batch of updates asynchronously. This method must be called from the main thread.
@@ -236,7 +236,7 @@ NS_ASSUME_NONNULL_BEGIN
236236
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
237237
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
238238
*/
239-
- (void)performBatchUpdates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion ASDISPLAYNODE_DEPRECATED_MSG("Use ASCollectionNode method instead.");
239+
- (void)performBatchUpdates:(nullable AS_NOESCAPE void (^)())updates completion:(nullable void (^)(BOOL finished))completion ASDISPLAYNODE_DEPRECATED_MSG("Use ASCollectionNode method instead.");
240240

241241
/**
242242
* Reload everything from scratch, destroying the working range and all cached nodes.

AsyncDisplayKit/ASDisplayNode+Subclasses.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ NS_ASSUME_NONNULL_BEGIN
195195
* @note Called on the display queue and/or main queue (MUST BE THREAD SAFE)
196196
*/
197197
+ (void)drawRect:(CGRect)bounds withParameters:(nullable id <NSObject>)parameters
198-
isCancelled:(__attribute((noescape)) asdisplaynode_iscancelled_block_t)isCancelledBlock
198+
isCancelled:(AS_NOESCAPE asdisplaynode_iscancelled_block_t)isCancelledBlock
199199
isRasterizing:(BOOL)isRasterizing;
200200

201201
/**
@@ -212,7 +212,7 @@ NS_ASSUME_NONNULL_BEGIN
212212
* @note Called on the display queue and/or main queue (MUST BE THREAD SAFE)
213213
*/
214214
+ (nullable UIImage *)displayWithParameters:(nullable id<NSObject>)parameters
215-
isCancelled:(__attribute((noescape)) asdisplaynode_iscancelled_block_t)isCancelledBlock;
215+
isCancelled:(AS_NOESCAPE asdisplaynode_iscancelled_block_t)isCancelledBlock;
216216

217217
/**
218218
* @abstract Delegate override for drawParameters

AsyncDisplayKit/ASTableNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ NS_ASSUME_NONNULL_BEGIN
148148
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
149149
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
150150
*/
151-
- (void)performBatchAnimated:(BOOL)animated updates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
151+
- (void)performBatchAnimated:(BOOL)animated updates:(nullable AS_NOESCAPE void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
152152

153153
/**
154154
* Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread.
@@ -159,7 +159,7 @@ NS_ASSUME_NONNULL_BEGIN
159159
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
160160
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
161161
*/
162-
- (void)performBatchUpdates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
162+
- (void)performBatchUpdates:(nullable AS_NOESCAPE void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
163163

164164
/**
165165
* Blocks execution of the main thread until all section and row updates are committed. This method must be called from the main thread.

AsyncDisplayKit/Details/_ASDisplayLayer.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//
1010

1111
#import <UIKit/UIKit.h>
12+
#import <AsyncDisplayKit/ASBaseDefines.h>
1213

1314
@class ASDisplayNode;
1415
@protocol _ASDisplayLayerDelegate;
@@ -103,27 +104,27 @@ typedef BOOL(^asdisplaynode_iscancelled_block_t)(void);
103104
@param isCancelledBlock Execute this block to check whether the current drawing operation has been cancelled to avoid unnecessary work. A return value of YES means cancel drawing and return.
104105
@param isRasterizing YES if the layer is being rasterized into another layer, in which case drawRect: probably wants to avoid doing things like filling its bounds with a zero-alpha color to clear the backing store.
105106
*/
106-
+ (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancelled:(__attribute((noescape)) asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing;
107+
+ (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancelled:(AS_NOESCAPE asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing;
107108

108109
/**
109110
@summary Delegate override to provide new layer contents as a UIImage.
110111
@param parameters An object describing all of the properties you need to draw. Return this from -drawParametersForAsyncLayer:
111112
@param isCancelledBlock Execute this block to check whether the current drawing operation has been cancelled to avoid unnecessary work. A return value of YES means cancel drawing and return.
112113
@return A UIImage with contents that are ready to display on the main thread. Make sure that the image is already decoded before returning it here.
113114
*/
114-
+ (UIImage *)displayWithParameters:(id<NSObject>)parameters isCancelled:(__attribute((noescape)) asdisplaynode_iscancelled_block_t)isCancelledBlock;
115+
+ (UIImage *)displayWithParameters:(id<NSObject>)parameters isCancelled:(AS_NOESCAPE asdisplaynode_iscancelled_block_t)isCancelledBlock;
115116

116117
/**
117118
* @abstract instance version of drawRect class method
118119
* @see drawRect:withParameters:isCancelled:isRasterizing class method
119120
*/
120-
- (void)drawRect:(CGRect)bounds withParameters:(id <NSObject>)parameters isCancelled:(__attribute((noescape)) asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing;
121+
- (void)drawRect:(CGRect)bounds withParameters:(id <NSObject>)parameters isCancelled:(AS_NOESCAPE asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing;
121122

122123
/**
123124
* @abstract instance version of display class method
124125
* @see displayWithParameters:isCancelled class method
125126
*/
126-
- (UIImage *)displayWithParameters:(id <NSObject>)parameters isCancelled:(__attribute((noescape)) asdisplaynode_iscancelled_block_t)isCancelled;
127+
- (UIImage *)displayWithParameters:(id <NSObject>)parameters isCancelled:(AS_NOESCAPE asdisplaynode_iscancelled_block_t)isCancelled;
127128

128129
// Called on the main thread only
129130

AsyncDisplayKit/Layout/ASLayoutElement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ extern NSString * const ASLayoutElementStyleLayoutPositionProperty;
315315

316316
@protocol ASLayoutElementStylability
317317

318-
- (instancetype)styledWithBlock:(__attribute__((noescape)) void (^)(__kindof ASLayoutElementStyle *style))styleBlock;
318+
- (instancetype)styledWithBlock:(AS_NOESCAPE void (^)(__kindof ASLayoutElementStyle *style))styleBlock;
319319

320320
@end
321321

AsyncDisplayKit/Private/ASCollectionView+Undeprecated.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ NS_ASSUME_NONNULL_BEGIN
131131
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
132132
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
133133
*/
134-
- (void)performBatchAnimated:(BOOL)animated updates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
134+
- (void)performBatchAnimated:(BOOL)animated updates:(nullable AS_NOESCAPE void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
135135

136136
/**
137137
* Perform a batch of updates asynchronously. This method must be called from the main thread.
@@ -142,7 +142,7 @@ NS_ASSUME_NONNULL_BEGIN
142142
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
143143
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
144144
*/
145-
- (void)performBatchUpdates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
145+
- (void)performBatchUpdates:(nullable AS_NOESCAPE void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
146146

147147
/**
148148
* Reload everything from scratch, destroying the working range and all cached nodes.

AsyncDisplayKitTests/ASPerformanceTestContext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import <Foundation/Foundation.h>
1010
#import <XCTest/XCTestAssertionsImpl.h>
11+
#import <AsyncDisplayKit/ASBaseDefines.h>
1112

1213
#define ASXCTAssertRelativePerformanceInRange(test, caseName, min, max) \
1314
_XCTPrimitiveAssertLessThanOrEqual(self, test.results[caseName].relativePerformance, @#caseName, max, @#max);\
@@ -32,7 +33,7 @@ typedef void (^ASTestPerformanceCaseBlock)(NSUInteger i, dispatch_block_t startM
3233
/**
3334
* The first case you add here will be considered the reference case.
3435
*/
35-
- (void)addCaseWithName:(NSString *)caseName block:(__attribute((noescape)) ASTestPerformanceCaseBlock)block;
36+
- (void)addCaseWithName:(NSString *)caseName block:(AS_NOESCAPE ASTestPerformanceCaseBlock)block;
3637

3738
@property (nonatomic, copy, readonly) NSDictionary<NSString *, ASPerformanceTestResult *> *results;
3839

AsyncDisplayKitTests/ASPerformanceTestContext.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ - (BOOL)areAllUserInfosEqual
7474
return YES;
7575
}
7676

77-
- (void)addCaseWithName:(NSString *)caseName block:(__attribute((noescape)) ASTestPerformanceCaseBlock)block
77+
- (void)addCaseWithName:(NSString *)caseName block:(AS_NOESCAPE ASTestPerformanceCaseBlock)block
7878
{
7979
ASDisplayNodeAssert(_results[caseName] == nil, @"Already have a case named %@", caseName);
8080
ASPerformanceTestResult *result = [[ASPerformanceTestResult alloc] init];
@@ -91,7 +91,7 @@ - (void)addCaseWithName:(NSString *)caseName block:(__attribute((noescape)) ASTe
9191
}
9292

9393
/// Returns total work time
94-
- (CFTimeInterval)_testPerformanceForCaseWithBlock:(__attribute((noescape)) ASTestPerformanceCaseBlock)block
94+
- (CFTimeInterval)_testPerformanceForCaseWithBlock:(AS_NOESCAPE ASTestPerformanceCaseBlock)block
9595
{
9696
__block CFTimeInterval time = 0;
9797
for (NSInteger i = 0; i < _iterationCount; i++) {

Base/ASBaseDefines.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@
183183

184184
#define ASOVERLOADABLE __attribute__((overloadable))
185185

186+
187+
#if __has_attribute(noescape)
188+
#define AS_NOESCAPE __attribute__((noescape))
189+
#else
190+
#define AS_NOESCAPE
191+
#endif
192+
186193
/// Ensure that class is of certain kind
187194
#define ASDynamicCast(x, c) ({ \
188195
id __val = x;\

0 commit comments

Comments
 (0)