From 883c7485c28b3b919f09c305f8b07370f00f929e Mon Sep 17 00:00:00 2001 From: Greg Bolsinga Date: Wed, 20 May 2020 14:05:44 -0700 Subject: [PATCH 1/2] Update Texture Xcode project to 11.4 and fix resulting warnings - 4 --- AsyncDisplayKit.xcodeproj/project.pbxproj | 11 +++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++ .../xcschemes/AsyncDisplayKit.xcscheme | 2 +- Source/ASCellNode.mm | 4 +- Source/ASCollectionView.mm | 16 ++--- Source/ASControlNode.mm | 18 +++--- Source/ASDisplayNode+Layout.mm | 16 ++--- Source/ASDisplayNode.mm | 58 +++++++++---------- Source/ASEditableTextNode.mm | 34 +++++------ Source/ASImageNode.mm | 8 +-- Source/ASMultiplexImageNode.mm | 2 +- Source/ASTableView.mm | 10 ++-- Source/ASVideoNode.mm | 6 +- Source/ASVideoPlayerNode.mm | 18 +++--- Source/Debug/AsyncDisplayKit+Debug.mm | 12 ++-- Source/Details/ASBasicImageDownloader.mm | 2 +- Source/Details/ASDataController.mm | 18 +++--- Source/Details/ASMainSerialQueue.mm | 6 +- ...SCollectionViewFlowLayoutInspectorTests.mm | 20 +++---- Tests/ASCollectionViewTests.mm | 10 ++-- Tests/ASCollectionViewThrashTests.mm | 4 +- Tests/ASDisplayNodeAppearanceTests.mm | 4 +- Tests/ASLayoutEngineTests.mm | 22 +++---- Tests/ASRecursiveUnfairLockTests.mm | 6 +- Tests/ASTableViewTests.mm | 16 ++--- Tests/ASThrashUtility.m | 6 +- 26 files changed, 175 insertions(+), 162 deletions(-) create mode 100644 AsyncDisplayKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/AsyncDisplayKit.xcodeproj/project.pbxproj b/AsyncDisplayKit.xcodeproj/project.pbxproj index 7cb9587b1..5dbaffe7c 100644 --- a/AsyncDisplayKit.xcodeproj/project.pbxproj +++ b/AsyncDisplayKit.xcodeproj/project.pbxproj @@ -2189,7 +2189,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = AS; - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1140; ORGANIZATIONNAME = Pinterest; TargetAttributes = { 057D02BE1AC0A66700C7AC3C = { @@ -2205,10 +2205,9 @@ }; buildConfigurationList = 058D09A7195D04C000B7D73C /* Build configuration list for PBXProject "AsyncDisplayKit" */; compatibilityVersion = "Xcode 6.3"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); @@ -2624,6 +2623,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -2631,6 +2631,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -2682,6 +2683,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -2689,6 +2691,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -2840,6 +2843,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -2847,6 +2851,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/AsyncDisplayKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/AsyncDisplayKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/AsyncDisplayKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/AsyncDisplayKit.xcodeproj/xcshareddata/xcschemes/AsyncDisplayKit.xcscheme b/AsyncDisplayKit.xcodeproj/xcshareddata/xcschemes/AsyncDisplayKit.xcscheme index 4cfa046b3..717ca42d1 100644 --- a/AsyncDisplayKit.xcodeproj/xcshareddata/xcschemes/AsyncDisplayKit.xcscheme +++ b/AsyncDisplayKit.xcodeproj/xcshareddata/xcschemes/AsyncDisplayKit.xcscheme @@ -1,6 +1,6 @@ _interactionDelegate nodeSelectedStateDidChange:self]; }); } } @@ -153,7 +153,7 @@ - (void)setHighlighted:(BOOL)highlighted if (ASLockedSelfCompareAssign(_highlighted, highlighted)) { if (!_suspendInteractionDelegate) { ASPerformBlockOnMainThread(^{ - [_interactionDelegate nodeHighlightedStateDidChange:self]; + [self->_interactionDelegate nodeHighlightedStateDidChange:self]; }); } } diff --git a/Source/ASCollectionView.mm b/Source/ASCollectionView.mm index 032f68bb3..8b8168519 100644 --- a/Source/ASCollectionView.mm +++ b/Source/ASCollectionView.mm @@ -63,7 +63,7 @@ // ASCellLayoutMode is an NSUInteger-based NS_OPTIONS field. Be careful with BOOL handling on the // 32-bit Objective-C runtime, and pattern after ASInterfaceStateIncludesVisible() & friends. -#define ASCellLayoutModeIncludes(layoutMode) ((_cellLayoutMode & layoutMode) == layoutMode) +#define ASCellLayoutModeIncludes(layoutMode) ((self->_cellLayoutMode & layoutMode) == layoutMode) /// What, if any, invalidation should we perform during the next -layoutSubviews. typedef NS_ENUM(NSUInteger, ASCollectionViewInvalidationStyle) { @@ -1875,14 +1875,14 @@ - (void)_beginBatchFetching if (_asyncDelegateFlags.collectionNodeWillBeginBatchFetch) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ GET_COLLECTIONNODE_OR_RETURN(collectionNode, (void)0); - os_log_debug(ASCollectionLog(), "Beginning batch fetch for %@ with context %@", collectionNode, _batchContext); - [_asyncDelegate collectionNode:collectionNode willBeginBatchFetchWithContext:_batchContext]; + os_log_debug(ASCollectionLog(), "Beginning batch fetch for %@ with context %@", collectionNode, self->_batchContext); + [self->_asyncDelegate collectionNode:collectionNode willBeginBatchFetchWithContext:self->_batchContext]; }); } else if (_asyncDelegateFlags.collectionViewWillBeginBatchFetch) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_asyncDelegate collectionView:self willBeginBatchFetchWithContext:_batchContext]; + [self->_asyncDelegate collectionView:self willBeginBatchFetchWithContext:self->_batchContext]; #pragma clang diagnostic pop }); } @@ -2248,20 +2248,20 @@ - (void)rangeController:(ASRangeController *)rangeController updateWithChangeSet ASPerformBlockWithoutAnimation(!changeSet.animated, ^{ as_activity_scope(as_activity_create("Commit collection update", changeSet.rootActivity, OS_ACTIVITY_FLAG_DEFAULT)); if (changeSet.includesReloadData) { - _superIsPendingDataLoad = YES; + self->_superIsPendingDataLoad = YES; updates(); [self _superReloadData:nil completion:nil]; os_log_debug(ASCollectionLog(), "Did reloadData %@", self.collectionNode); [changeSet executeCompletionHandlerWithFinished:YES]; } else { - [_layoutFacilitator collectionViewWillPerformBatchUpdates]; + [self->_layoutFacilitator collectionViewWillPerformBatchUpdates]; __block NSUInteger numberOfUpdates = 0; const auto completion = ^(BOOL finished) { as_activity_scope(as_activity_create("Handle collection update completion", changeSet.rootActivity, OS_ACTIVITY_FLAG_DEFAULT)); as_log_verbose(ASCollectionLog(), "Update animation finished %{public}@", self.collectionNode); // Flush any range changes that happened as part of the update animations ending. - [_rangeController updateIfNeeded]; + [self->_rangeController updateIfNeeded]; [self _scheduleCheckForBatchFetchingForNumberOfChanges:numberOfUpdates]; [changeSet executeCompletionHandlerWithFinished:finished]; }; @@ -2317,7 +2317,7 @@ - (void)rangeController:(ASRangeController *)rangeController updateWithChangeSet // Flush any range changes that happened as part of submitting the update. as_activity_scope(changeSet.rootActivity); - [_rangeController updateIfNeeded]; + [self->_rangeController updateIfNeeded]; } }); } diff --git a/Source/ASControlNode.mm b/Source/ASControlNode.mm index 39a686e8f..6336d9947 100644 --- a/Source/ASControlNode.mm +++ b/Source/ASControlNode.mm @@ -297,10 +297,10 @@ - (void)addTarget:(id)target action:(SEL)action forControlEvents:(ASControlNodeE dispatch_async(dispatch_get_main_queue(), ^{ // add a highlight overlay node with area of ASControlNode + UIEdgeInsets self.clipsToBounds = NO; - _debugHighlightOverlay = [[ASImageNode alloc] init]; - _debugHighlightOverlay.zPosition = 1000; // ensure we're over the top of any siblings - _debugHighlightOverlay.layerBacked = YES; - [self addSubnode:_debugHighlightOverlay]; + self->_debugHighlightOverlay = [[ASImageNode alloc] init]; + self->_debugHighlightOverlay.zPosition = 1000; // ensure we're over the top of any siblings + self->_debugHighlightOverlay.layerBacked = YES; + [self addSubnode:self->_debugHighlightOverlay]; }); } } @@ -316,7 +316,7 @@ - (void)addTarget:(id)target action:(SEL)action forControlEvents:(ASControlNodeE { // Do we already have an event table for this control event? id eventKey = _ASControlNodeEventKeyForControlEvent(controlEvent); - NSMutableArray *eventTargetActionArray = _controlEventDispatchTable[eventKey]; + NSMutableArray *eventTargetActionArray = self->_controlEventDispatchTable[eventKey]; if (!eventTargetActionArray) { eventTargetActionArray = [[NSMutableArray alloc] init]; @@ -329,7 +329,7 @@ - (void)addTarget:(id)target action:(SEL)action forControlEvents:(ASControlNodeE [eventTargetActionArray addObject:targetAction]; if (eventKey) { - [_controlEventDispatchTable setObject:eventTargetActionArray forKey:eventKey]; + [self->_controlEventDispatchTable setObject:eventTargetActionArray forKey:eventKey]; } }); @@ -390,7 +390,7 @@ - (void)removeTarget:(id)target action:(SEL)action forControlEvents:(ASControlNo { // Grab the dispatch table for this event (if we have it). id eventKey = _ASControlNodeEventKeyForControlEvent(controlEvent); - NSMutableArray *eventTargetActionArray = _controlEventDispatchTable[eventKey]; + NSMutableArray *eventTargetActionArray = self->_controlEventDispatchTable[eventKey]; if (!eventTargetActionArray) { return; } @@ -410,7 +410,7 @@ - (void)removeTarget:(id)target action:(SEL)action forControlEvents:(ASControlNo if (eventTargetActionArray.count == 0) { // If there are no targets for this event anymore, remove it. - [_controlEventDispatchTable removeObjectForKey:eventKey]; + [self->_controlEventDispatchTable removeObjectForKey:eventKey]; } }); } @@ -432,7 +432,7 @@ - (void)sendActionsForControlEvents:(ASControlNodeEvent)controlEvents withEvent: (ASControlNodeEvent controlEvent) { // Iterate on each target action pair - for (ASControlTargetAction *targetAction in _controlEventDispatchTable[_ASControlNodeEventKeyForControlEvent(controlEvent)]) { + for (ASControlTargetAction *targetAction in self->_controlEventDispatchTable[_ASControlNodeEventKeyForControlEvent(controlEvent)]) { ASControlTargetAction *resolvedTargetAction = [[ASControlTargetAction alloc] init]; resolvedTargetAction.action = targetAction.action; resolvedTargetAction.target = targetAction.target; diff --git a/Source/ASDisplayNode+Layout.mm b/Source/ASDisplayNode+Layout.mm index 2a46df8e3..79b485897 100644 --- a/Source/ASDisplayNode+Layout.mm +++ b/Source/ASDisplayNode+Layout.mm @@ -656,7 +656,7 @@ - (void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize as_log_verbose(ASLayoutLog(), "Transition ID is %d", transitionID); // NOTE: This block captures self. It's cheaper than hitting the weak table. asdisplaynode_iscancelled_block_t isCancelled = ^{ - BOOL result = (_transitionID != transitionID); + BOOL result = (self->_transitionID != transitionID); if (result) { as_log_verbose(ASLayoutLog(), "Transition %d canceled, superseded by %d", transitionID, _transitionID.load()); } @@ -677,7 +677,7 @@ - (void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize } // Perform a full layout creation pass with passed in constrained size to create the new layout for the transition - NSUInteger newLayoutVersion = _layoutVersion; + NSUInteger newLayoutVersion = self->_layoutVersion; ASLayout *newLayout; { ASScopedLockSelfOrToRoot(); @@ -712,10 +712,10 @@ - (void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize { // Grab __instanceLock__ here to make sure this transition isn't invalidated // right after it passed the validation test and before it proceeds - MutexLocker l(__instanceLock__); + MutexLocker l(self->__instanceLock__); // Update calculated layout - const auto previousLayout = _calculatedDisplayNodeLayout; + const auto previousLayout = self->_calculatedDisplayNodeLayout; const auto pendingLayout = ASDisplayNodeLayout(newLayout, constrainedSize, constrainedSize.max, @@ -723,12 +723,12 @@ - (void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize [self _locked_setCalculatedDisplayNodeLayout:pendingLayout]; // Setup pending layout transition for animation - _pendingLayoutTransition = pendingLayoutTransition = [[ASLayoutTransition alloc] initWithNode:self + self->_pendingLayoutTransition = pendingLayoutTransition = [[ASLayoutTransition alloc] initWithNode:self pendingLayout:pendingLayout previousLayout:previousLayout]; // Setup context for pending layout transition. we need to hold a strong reference to the context - _pendingLayoutTransitionContext = pendingLayoutTransitionContext = [[_ASTransitionContext alloc] initWithAnimation:animated - layoutDelegate:_pendingLayoutTransition + self->_pendingLayoutTransitionContext = pendingLayoutTransitionContext = [[_ASTransitionContext alloc] initWithAnimation:animated + layoutDelegate:self->_pendingLayoutTransition completionDelegate:self]; } @@ -1043,7 +1043,7 @@ - (void)_pendingLayoutTransitionDidComplete if (self.isNodeLoaded) { ASPerformBlockOnMainThread(^{ if (self.contents == nil) { - _placeholderImage = [self placeholderImage]; + self->_placeholderImage = [self placeholderImage]; } }); } else { diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index c9495389f..462ce39b9 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -449,20 +449,20 @@ - (void)asyncTraitCollectionDidChangeWithPreviousTraitCollection:(ASPrimitiveTra // we need to run that on main thread, cause accessing CALayer properties. // It seems than in iOS 13 sometimes it causes deadlock. ASPerformBlockOnMainThread(^{ - __instanceLock__.lock(); - CGFloat cornerRadius = _cornerRadius; - ASCornerRoundingType cornerRoundingType = _cornerRoundingType; - UIColor *backgroundColor = _backgroundColor; - __instanceLock__.unlock(); + self->__instanceLock__.lock(); + CGFloat cornerRadius = self->_cornerRadius; + ASCornerRoundingType cornerRoundingType = self->_cornerRoundingType; + UIColor *backgroundColor = self->_backgroundColor; + self->__instanceLock__.unlock(); // TODO: we should resolve color using node's trait collection // but Texture changes it from many places, so we may receive the wrong one. CGColorRef cgBackgroundColor = backgroundColor.CGColor; - if (!CGColorEqualToColor(_layer.backgroundColor, cgBackgroundColor)) { + if (!CGColorEqualToColor(self->_layer.backgroundColor, cgBackgroundColor)) { // Background colors do not dynamically update for layer backed nodes since they utilize CGColorRef // instead of UIColor. Non layer backed node also receive color to the layer (see [_ASPendingState -applyToView:withSpecialPropertiesHandling:]). // We utilize the _backgroundColor instance variable to track the full dynamic color // and apply any changes here when trait collection updates occur. - _layer.backgroundColor = cgBackgroundColor; + self->_layer.backgroundColor = cgBackgroundColor; } // If we have clipping corners, re-render the clipping corner layer upon user interface style change @@ -1349,7 +1349,7 @@ - (void)_pendingNodeDidDisplay:(ASDisplayNode *)node __instanceLock__.lock(); if (_placeholderLayer.superlayer && !placeholderShouldPersist) { void (^cleanupBlock)() = ^{ - [_placeholderLayer removeFromSuperlayer]; + [self->_placeholderLayer removeFromSuperlayer]; }; if (_placeholderFadeDuration > 0.0 && ASInterfaceStateIncludesVisible(self.interfaceState)) { @@ -1495,7 +1495,7 @@ - (void)_updateClipCornerLayerContentsWithRadius:(CGFloat)radius backgroundColor ASPerformBlockOnMainThread(^{ for (int idx = 0; idx < NUM_CLIP_CORNER_LAYERS; idx++) { // Skip corners that aren't clipped (we have already set up & torn down layers based on maskedCorners.) - if (_clipCornerLayers[idx] == nil) { + if (self->_clipCornerLayers[idx] == nil) { continue; } @@ -1521,7 +1521,7 @@ - (void)_updateClipCornerLayerContentsWithRadius:(CGFloat)radius backgroundColor }); // No lock needed, as _clipCornerLayers is only modified on the main thread. - unowned CALayer *clipCornerLayer = _clipCornerLayers[idx]; + unowned CALayer *clipCornerLayer = self->_clipCornerLayers[idx]; clipCornerLayer.contents = (id)(newContents.CGImage); clipCornerLayer.bounds = CGRectMake(0.0, 0.0, size.width, size.height); clipCornerLayer.anchorPoint = CGPointMake(isRight ? 1.0 : 0.0, isTop ? 0.0 : 1.0); @@ -1536,7 +1536,7 @@ - (void)_setClipCornerLayersVisible:(CACornerMask)visibleCornerLayers ASDisplayNodeAssertMainThread(); for (int idx = 0; idx < NUM_CLIP_CORNER_LAYERS; idx++) { BOOL visible = (0 != (visibleCornerLayers & (1 << idx))); - if (visible == (_clipCornerLayers[idx] != nil)) { + if (visible == (self->_clipCornerLayers[idx] != nil)) { continue; } else if (visible) { static ASDisplayNodeCornerLayerDelegate *clipCornerLayers; @@ -1544,15 +1544,15 @@ - (void)_setClipCornerLayersVisible:(CACornerMask)visibleCornerLayers dispatch_once(&onceToken, ^{ clipCornerLayers = [[ASDisplayNodeCornerLayerDelegate alloc] init]; }); - _clipCornerLayers[idx] = [[CALayer alloc] init]; - _clipCornerLayers[idx].zPosition = 99999; - _clipCornerLayers[idx].delegate = clipCornerLayers; + self->_clipCornerLayers[idx] = [[CALayer alloc] init]; + self->_clipCornerLayers[idx].zPosition = 99999; + self->_clipCornerLayers[idx].delegate = clipCornerLayers; } else { - [_clipCornerLayers[idx] removeFromSuperlayer]; - _clipCornerLayers[idx] = nil; + [self->_clipCornerLayers[idx] removeFromSuperlayer]; + self->_clipCornerLayers[idx] = nil; } } - [self _updateClipCornerLayerContentsWithRadius:_cornerRadius backgroundColor:self.backgroundColor]; + [self _updateClipCornerLayerContentsWithRadius:self->_cornerRadius backgroundColor:self.backgroundColor]; }); } @@ -2809,13 +2809,13 @@ - (void)didExitHierarchy if (ASInterfaceStateIncludesVisible(self.pendingInterfaceState)) { void(^exitVisibleInterfaceState)(void) = ^{ // This block intentionally retains self. - __instanceLock__.lock(); - unsigned isStillInHierarchy = _flags.isInHierarchy; - BOOL isVisible = ASInterfaceStateIncludesVisible(_pendingInterfaceState); - ASInterfaceState newState = (_pendingInterfaceState & ~ASInterfaceStateVisible); + self->__instanceLock__.lock(); + unsigned isStillInHierarchy = self->_flags.isInHierarchy; + BOOL isVisible = ASInterfaceStateIncludesVisible(self->_pendingInterfaceState); + ASInterfaceState newState = (self->_pendingInterfaceState & ~ASInterfaceStateVisible); // layer may be thrashed, we need to remember the state so we can reset if it enters in same runloop later. - _preExitingInterfaceState = _pendingInterfaceState; - __instanceLock__.unlock(); + self->_preExitingInterfaceState = self->_pendingInterfaceState; + self->__instanceLock__.unlock(); if (!isStillInHierarchy && isVisible) { #if ENABLE_NEW_EXIT_HIERARCHY_BEHAVIOR if (![self supportsRangeManagedInterfaceState]) { @@ -2974,9 +2974,9 @@ - (void)applyPendingInterfaceState:(ASInterfaceState)newPendingState [self setDisplaySuspended:YES]; //schedule clear contents on next runloop dispatch_async(dispatch_get_main_queue(), ^{ - __instanceLock__.lock(); - ASInterfaceState interfaceState = _interfaceState; - __instanceLock__.unlock(); + self->__instanceLock__.lock(); + ASInterfaceState interfaceState = self->_interfaceState; + self->__instanceLock__.unlock(); if (ASInterfaceStateIncludesDisplay(interfaceState) == NO) { [self clearContents]; } @@ -2994,9 +2994,9 @@ - (void)applyPendingInterfaceState:(ASInterfaceState)newPendingState [[self asyncLayer] cancelAsyncDisplay]; //schedule clear contents on next runloop dispatch_async(dispatch_get_main_queue(), ^{ - __instanceLock__.lock(); - ASInterfaceState interfaceState = _interfaceState; - __instanceLock__.unlock(); + self->__instanceLock__.lock(); + ASInterfaceState interfaceState = self->_interfaceState; + self->__instanceLock__.unlock(); if (ASInterfaceStateIncludesDisplay(interfaceState) == NO) { [self clearContents]; } diff --git a/Source/ASEditableTextNode.mm b/Source/ASEditableTextNode.mm index 0c9cd4136..60be21f98 100644 --- a/Source/ASEditableTextNode.mm +++ b/Source/ASEditableTextNode.mm @@ -176,11 +176,11 @@ - (void)didLoad [super didLoad]; void (^configureTextView)(UITextView *) = ^(UITextView *textView) { - if (!_displayingPlaceholder || textView != _textKitComponents.textView) { + if (!self->_displayingPlaceholder || textView != self->_textKitComponents.textView) { // If showing the placeholder, don't propagate backgroundColor/opaque to the editable textView. It is positioned over the placeholder to accept taps to begin editing, and if it's opaque/colored then it'll obscure the placeholder. textView.backgroundColor = self.backgroundColor; textView.opaque = self.opaque; - } else if (_displayingPlaceholder && textView == _textKitComponents.textView) { + } else if (self->_displayingPlaceholder && textView == self->_textKitComponents.textView) { // The default backgroundColor for a textView is white. Due to the reason described above, make sure the editable textView starts out transparent. textView.backgroundColor = nil; textView.opaque = NO; @@ -189,16 +189,16 @@ - (void)didLoad // Configure textView with UITextInputTraits { - AS::MutexLocker l(_textInputTraitsLock); - if (_textInputTraits) { - textView.autocapitalizationType = _textInputTraits.autocapitalizationType; - textView.autocorrectionType = _textInputTraits.autocorrectionType; - textView.spellCheckingType = _textInputTraits.spellCheckingType; - textView.keyboardType = _textInputTraits.keyboardType; - textView.keyboardAppearance = _textInputTraits.keyboardAppearance; - textView.returnKeyType = _textInputTraits.returnKeyType; - textView.enablesReturnKeyAutomatically = _textInputTraits.enablesReturnKeyAutomatically; - textView.secureTextEntry = _textInputTraits.isSecureTextEntry; + AS::MutexLocker l(self->_textInputTraitsLock); + if (self->_textInputTraits) { + textView.autocapitalizationType = self->_textInputTraits.autocapitalizationType; + textView.autocorrectionType = self->_textInputTraits.autocorrectionType; + textView.spellCheckingType = self->_textInputTraits.spellCheckingType; + textView.keyboardType = self->_textInputTraits.keyboardType; + textView.keyboardAppearance = self->_textInputTraits.keyboardAppearance; + textView.returnKeyType = self->_textInputTraits.returnKeyType; + textView.enablesReturnKeyAutomatically = self->_textInputTraits.enablesReturnKeyAutomatically; + textView.secureTextEntry = self->_textInputTraits.isSecureTextEntry; } } @@ -815,8 +815,8 @@ - (void)_delegateDidChangeSelectionFromSelectedRange:(NSRange)fromSelectedRange // 2. This delegate method (-textViewDidChangeSelection:) is called both before -textViewDidChange: and before the layout manager/etc. has necessarily generated+laid out its glyphs. Because of the former, we need to wait until -textViewDidChange: has had an opportunity to be called so can accurately determine whether this selection change is due to editing (_selectionChangedForEditedText). // Thus, to avoid calling out to client code in the middle of UITextView's processing, we call the delegate on the next run of the runloop, when all such internal processing is surely done. dispatch_async(dispatch_get_main_queue(), ^{ - if ([_delegate respondsToSelector:@selector(editableTextNodeDidChangeSelection:fromSelectedRange:toSelectedRange:dueToEditing:)]) - [_delegate editableTextNodeDidChangeSelection:self fromSelectedRange:fromSelectedRange toSelectedRange:toSelectedRange dueToEditing:_selectionChangedForEditedText]; + if ([self->_delegate respondsToSelector:@selector(editableTextNodeDidChangeSelection:fromSelectedRange:toSelectedRange:dueToEditing:)]) + [self->_delegate editableTextNodeDidChangeSelection:self fromSelectedRange:fromSelectedRange toSelectedRange:toSelectedRange dueToEditing:self->_selectionChangedForEditedText]; }); } @@ -831,9 +831,9 @@ - (void)_delegateDidUpdateText // UITextView invokes its delegate methods when it's in the middle of text-processing. For example, -textViewDidChange: is invoked before you can truly rely on the changes being propagated throughout the Text Kit hierarchy. // Thus, to avoid calling out to client code in the middle of UITextView's processing, we call the delegate on the next run of the runloop, when all such internal processing is surely done. dispatch_async(dispatch_get_main_queue(), ^{ - _delegateDidUpdateEnqueued = NO; - if ([_delegate respondsToSelector:@selector(editableTextNodeDidUpdateText:)]) - [_delegate editableTextNodeDidUpdateText:self]; + self->_delegateDidUpdateEnqueued = NO; + if ([self->_delegate respondsToSelector:@selector(editableTextNodeDidUpdateText:)]) + [self->_delegate editableTextNodeDidUpdateText:self]; }); } diff --git a/Source/ASImageNode.mm b/Source/ASImageNode.mm index 0650933eb..037e2cb06 100644 --- a/Source/ASImageNode.mm +++ b/Source/ASImageNode.mm @@ -260,9 +260,9 @@ - (void)_locked_setImage:(UIImage *)image // do not use ASPerformBlockOnMainThread here, if it performs the block synchronously it will continue // holding the lock while calling addSubnode. dispatch_async(dispatch_get_main_queue(), ^{ - _debugLabelNode = [[ASTextNode alloc] init]; - _debugLabelNode.layerBacked = YES; - [self addSubnode:_debugLabelNode]; + self->_debugLabelNode = [[ASTextNode alloc] init]; + self->_debugLabelNode.layerBacked = YES; + [self addSubnode:self->_debugLabelNode]; }); } } else { @@ -333,7 +333,7 @@ - (NSObject *)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer // Hack for now to retain the weak entry that was created while this drawing happened drawParameters->_didDrawBlock = ^(ASWeakMapEntry *entry){ ASLockScopeSelf(); - _weakCacheEntry = entry; + self->_weakCacheEntry = entry; }; } diff --git a/Source/ASMultiplexImageNode.mm b/Source/ASMultiplexImageNode.mm index 926480a05..00dcec84a 100644 --- a/Source/ASMultiplexImageNode.mm +++ b/Source/ASMultiplexImageNode.mm @@ -742,7 +742,7 @@ - (void)_loadPHAssetWithRequest:(ASPhotosFrameworkImageRequest *)request identif PHAsset *imageAsset = nil; // Try to get the asset immediately from the data source. - if (_dataSourceFlags.asset) { + if (strongSelf->_dataSourceFlags.asset) { imageAsset = [strongSelf.dataSource multiplexImageNode:strongSelf assetForLocalIdentifier:request.assetIdentifier]; } diff --git a/Source/ASTableView.mm b/Source/ASTableView.mm index 0589dbfb9..3781a8c10 100644 --- a/Source/ASTableView.mm +++ b/Source/ASTableView.mm @@ -1502,13 +1502,13 @@ - (void)_beginBatchFetching if (_asyncDelegateFlags.tableNodeWillBeginBatchFetch) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ GET_TABLENODE_OR_RETURN(tableNode, (void)0); - [_asyncDelegate tableNode:tableNode willBeginBatchFetchWithContext:_batchContext]; + [self->_asyncDelegate tableNode:tableNode willBeginBatchFetchWithContext:self->_batchContext]; }); } else if (_asyncDelegateFlags.tableViewWillBeginBatchFetch) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_asyncDelegate tableView:self willBeginBatchFetchWithContext:_batchContext]; + [self->_asyncDelegate tableView:self willBeginBatchFetchWithContext:self->_batchContext]; #pragma clang diagnostic pop }); } @@ -1566,7 +1566,7 @@ - (void)rangeController:(ASRangeController *)rangeController updateWithChangeSet updates(); [super reloadData]; // Flush any range changes that happened as part of submitting the reload. - [_rangeController updateIfNeeded]; + [self->_rangeController updateIfNeeded]; [self _scheduleCheckForBatchFetchingForNumberOfChanges:1]; [changeSet executeCompletionHandlerWithFinished:YES]; }); @@ -1684,7 +1684,7 @@ - (void)rangeController:(ASRangeController *)rangeController updateWithChangeSet LOG(@"--- UITableView endUpdates"); ASPerformBlockWithoutAnimation(!changeSet.animated, ^{ [super endUpdates]; - [_rangeController updateIfNeeded]; + [self->_rangeController updateIfNeeded]; [self _scheduleCheckForBatchFetchingForNumberOfChanges:numberOfUpdates]; }); if (shouldAdjustContentOffset) { @@ -1789,7 +1789,7 @@ - (ASCellNodeBlock)dataController:(ASDataController *)dataController nodeBlockAt if (node.interactionDelegate == nil) { node.interactionDelegate = strongSelf; } - if (_inverted) { + if (self->_inverted) { node.transform = CATransform3DMakeScale(1, -1, 1) ; } return node; diff --git a/Source/ASVideoNode.mm b/Source/ASVideoNode.mm index 6646c3dbd..141ca2eac 100644 --- a/Source/ASVideoNode.mm +++ b/Source/ASVideoNode.mm @@ -289,7 +289,7 @@ - (void)generatePlaceholderImage - (void)imageAtTime:(CMTime)imageTime completionHandler:(void(^)(UIImage *image))completionHandler { ASPerformBlockOnBackgroundThread(^{ - AVAsset *asset = self.asset; + AVAsset *asset = self->_asset; // Skip the asset image generation if we don't have any tracks available that are capable of supporting it NSArray* visualAssetArray = [asset tracksWithMediaCharacteristic:AVMediaCharacteristicVisual]; @@ -300,7 +300,7 @@ - (void)imageAtTime:(CMTime)imageTime completionHandler:(void(^)(UIImage *image) AVAssetImageGenerator *previewImageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:asset]; previewImageGenerator.appliesPreferredTrackTransform = YES; - previewImageGenerator.videoComposition = _videoComposition; + previewImageGenerator.videoComposition = self->_videoComposition; [previewImageGenerator generateCGImagesAsynchronouslyForTimes:@[[NSValue valueWithCMTime:imageTime]] completionHandler:^(CMTime requestedTime, CGImageRef image, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error) { @@ -415,7 +415,7 @@ - (void)didEnterPreloadState NSArray *requestedKeys = @[@"playable"]; [asset loadValuesAsynchronouslyForKeys:requestedKeys completionHandler:^{ ASPerformBlockOnMainThread(^{ - if (_delegateFlags.delegateVideoNodeDidFinishInitialLoading) { + if (self->_delegateFlags.delegateVideoNodeDidFinishInitialLoading) { [self.delegate videoNodeDidFinishInitialLoading:self]; } [self prepareToPlayAsset:asset withKeys:requestedKeys]; diff --git a/Source/ASVideoPlayerNode.mm b/Source/ASVideoPlayerNode.mm index 696531c75..36b4a3fb5 100644 --- a/Source/ASVideoPlayerNode.mm +++ b/Source/ASVideoPlayerNode.mm @@ -435,19 +435,19 @@ - (void)_locked_createScrubber slider.minimumValue = 0.0; slider.maximumValue = 1.0; - if (_delegateFlags.delegateScrubberMinimumTrackTintColor) { + if (strongSelf->_delegateFlags.delegateScrubberMinimumTrackTintColor) { slider.minimumTrackTintColor = [strongSelf.delegate videoPlayerNodeScrubberMinimumTrackTint:strongSelf]; } - if (_delegateFlags.delegateScrubberMaximumTrackTintColor) { + if (strongSelf->_delegateFlags.delegateScrubberMaximumTrackTintColor) { slider.maximumTrackTintColor = [strongSelf.delegate videoPlayerNodeScrubberMaximumTrackTint:strongSelf]; } - if (_delegateFlags.delegateScrubberThumbTintColor) { + if (strongSelf->_delegateFlags.delegateScrubberThumbTintColor) { slider.thumbTintColor = [strongSelf.delegate videoPlayerNodeScrubberThumbTint:strongSelf]; } - if (_delegateFlags.delegateScrubberThumbImage) { + if (strongSelf->_delegateFlags.delegateScrubberThumbImage) { UIImage *thumbImage = [strongSelf.delegate videoPlayerNodeScrubberThumbImage:strongSelf]; [slider setThumbImage:thumbImage forState:UIControlStateNormal]; } @@ -645,14 +645,14 @@ - (void)showSpinner UIActivityIndicatorView *spinnnerView = [[UIActivityIndicatorView alloc] init]; spinnnerView.backgroundColor = [UIColor clearColor]; - if (_delegateFlags.delegateSpinnerTintColor) { - spinnnerView.color = [_delegate videoPlayerNodeSpinnerTint:strongSelf]; + if (strongSelf->_delegateFlags.delegateSpinnerTintColor) { + spinnnerView.color = [strongSelf->_delegate videoPlayerNodeSpinnerTint:strongSelf]; } else { - spinnnerView.color = _defaultControlsColor; + spinnnerView.color = strongSelf->_defaultControlsColor; } - if (_delegateFlags.delegateSpinnerStyle) { - spinnnerView.activityIndicatorViewStyle = [_delegate videoPlayerNodeSpinnerStyle:strongSelf]; + if (strongSelf->_delegateFlags.delegateSpinnerStyle) { + spinnnerView.activityIndicatorViewStyle = [strongSelf->_delegate videoPlayerNodeSpinnerStyle:strongSelf]; } return spinnnerView; diff --git a/Source/Debug/AsyncDisplayKit+Debug.mm b/Source/Debug/AsyncDisplayKit+Debug.mm index 05fa4a0be..4214e3839 100644 --- a/Source/Debug/AsyncDisplayKit+Debug.mm +++ b/Source/Debug/AsyncDisplayKit+Debug.mm @@ -424,10 +424,10 @@ - (void)addRangeController:(ASRangeController *)rangeController } [UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{ - _animating = YES; + self->_animating = YES; [self layoutToFitAllBarsExcept:0]; } completion:^(BOOL finished) { - _animating = NO; + self->_animating = NO; }]; } @@ -653,15 +653,15 @@ - (void)layoutSubviews BOOL animate = !_firstLayoutOfRects; [UIView animateWithDuration:animate ? 0.3 : 0.0 delay:0.0 options:UIViewAnimationOptionLayoutSubviews animations:^{ - _visibleRect.frame = CGRectMake(HORIZONTAL_INSET + visiblePoint, rect.origin.y, visibleDimension, subCellHeight); - _displayRect.frame = CGRectMake(HORIZONTAL_INSET + displayPoint, rect.origin.y, displayDimension, subCellHeight); - _preloadRect.frame = CGRectMake(HORIZONTAL_INSET + preloadPoint, rect.origin.y, preloadDimension, subCellHeight); + self->_visibleRect.frame = CGRectMake(HORIZONTAL_INSET + visiblePoint, rect.origin.y, visibleDimension, subCellHeight); + self->_displayRect.frame = CGRectMake(HORIZONTAL_INSET + displayPoint, rect.origin.y, displayDimension, subCellHeight); + self->_preloadRect.frame = CGRectMake(HORIZONTAL_INSET + preloadPoint, rect.origin.y, preloadDimension, subCellHeight); } completion:^(BOOL finished) {}]; if (!animate) { _visibleRect.alpha = _displayRect.alpha = _preloadRect.alpha = 0; [UIView animateWithDuration:0.3 animations:^{ - _visibleRect.alpha = _displayRect.alpha = _preloadRect.alpha = 1; + self->_visibleRect.alpha = self->_displayRect.alpha = self->_preloadRect.alpha = 1; }]; } diff --git a/Source/Details/ASBasicImageDownloader.mm b/Source/Details/ASBasicImageDownloader.mm index 927a2d0aa..f577eb1e2 100644 --- a/Source/Details/ASBasicImageDownloader.mm +++ b/Source/Details/ASBasicImageDownloader.mm @@ -290,7 +290,7 @@ - (nullable id)downloadImageWithURL:(NSURL *)URL [context addCallbackData:[[NSDictionary alloc] initWithDictionary:callbackData]]; // Create new task if necessary - NSURLSessionDownloadTask *task = (NSURLSessionDownloadTask *)[context createSessionTaskIfNecessaryWithBlock:^(){return [_session downloadTaskWithURL:URL];}]; + NSURLSessionDownloadTask *task = (NSURLSessionDownloadTask *)[context createSessionTaskIfNecessaryWithBlock:^(){return [self->_session downloadTaskWithURL:URL];}]; if (task) { task.priority = NSURLSessionTaskPriorityWithImageDownloaderPriority(priority); diff --git a/Source/Details/ASDataController.mm b/Source/Details/ASDataController.mm index 2ec2eb699..76e58d8be 100644 --- a/Source/Details/ASDataController.mm +++ b/Source/Details/ASDataController.mm @@ -533,13 +533,13 @@ - (void)updateWithChangeSet:(_ASHierarchyChangeSet *)changeSet _synchronized = NO; [changeSet addCompletionHandler:^(BOOL finished) { - _synchronized = YES; + self->_synchronized = YES; [self onDidFinishProcessingUpdates:^{ - if (_synchronized) { - for (ASDataControllerSynchronizationBlock block in _onDidFinishSynchronizingBlocks) { + if (self->_synchronized) { + for (ASDataControllerSynchronizationBlock block in self->_onDidFinishSynchronizingBlocks) { block(); } - [_onDidFinishSynchronizingBlocks removeAllObjects]; + [self->_onDidFinishSynchronizingBlocks removeAllObjects]; } }]; }]; @@ -646,9 +646,9 @@ - (void)updateWithChangeSet:(_ASHierarchyChangeSet *)changeSet } // Step 4: Inform the delegate on main thread - [_mainSerialQueue performBlockOnMainThread:^{ + [self->_mainSerialQueue performBlockOnMainThread:^{ as_activity_scope_leave(&preparationScope); - [_delegate dataController:self updateWithChangeSet:changeSet updates:^{ + [self->_delegate dataController:self updateWithChangeSet:changeSet updates:^{ // Step 5: Deploy the new data as "completed" // // Note that since the backing collection view might be busy responding to user events (e.g scrolling), @@ -659,7 +659,7 @@ - (void)updateWithChangeSet:(_ASHierarchyChangeSet *)changeSet self.visibleMap = newMap; }]; }]; - --_editingTransactionGroupCount; + --self->_editingTransactionGroupCount; }); // We've now dispatched node allocation and layout to a concurrent background queue. @@ -898,7 +898,7 @@ - (void)_relayoutAllNodes - (void)environmentDidChange { ASPerformBlockOnMainThread(^{ - if (!_initialReloadDataHasBeenCalled) { + if (!self->_initialReloadDataHasBeenCalled) { return; } @@ -906,7 +906,7 @@ - (void)environmentDidChange // i.e there might be some elements that were allocated using the old trait collection but haven't been added to _visibleMap [self _scheduleBlockOnMainSerialQueue:^{ ASPrimitiveTraitCollection newTraitCollection = [self.node primitiveTraitCollection]; - for (ASCollectionElement *element in _visibleMap) { + for (ASCollectionElement *element in self->_visibleMap) { element.traitCollection = newTraitCollection; } }]; diff --git a/Source/Details/ASMainSerialQueue.mm b/Source/Details/ASMainSerialQueue.mm index 472214390..ba2c74347 100644 --- a/Source/Details/ASMainSerialQueue.mm +++ b/Source/Details/ASMainSerialQueue.mm @@ -44,11 +44,11 @@ - (void)runBlocks dispatch_block_t mainThread = ^{ AS::UniqueLock l(self->_serialQueueLock); do { - if (_blocks.empty()) { + if (self->_blocks.empty()) { break; } - dispatch_block_t block = _blocks.front(); - _blocks.pop(); + dispatch_block_t block = self->_blocks.front(); + self->_blocks.pop(); { l.unlock(); block(); diff --git a/Tests/ASCollectionViewFlowLayoutInspectorTests.mm b/Tests/ASCollectionViewFlowLayoutInspectorTests.mm index 555fe2113..df457448d 100644 --- a/Tests/ASCollectionViewFlowLayoutInspectorTests.mm +++ b/Tests/ASCollectionViewFlowLayoutInspectorTests.mm @@ -32,22 +32,22 @@ @interface InspectorTestDataSource : NSObject @implementation InspectorTestDataSource -- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath +- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtIndexPath:(NSIndexPath *)indexPath { return [[ASCellNode alloc] init]; } -- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath +- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath { return ^{ return [[ASCellNode alloc] init]; }; } -- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section +- (NSInteger)collectionNode:(ASCollectionNode *)collectionNode numberOfItemsInSection:(NSInteger)section { return 0; } -- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView +- (NSInteger)numberOfSectionsInCollectionNode:(ASCollectionNode *)collectionNode { return 2; } @@ -63,12 +63,12 @@ @interface InspectorTestDataSourceDelegateWithoutNodeConstrainedSize : NSObject @implementation InspectorTestDataSourceDelegateWithoutNodeConstrainedSize -- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath +- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath { return ^{ return [[ASCellNode alloc] init]; }; } -- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section +- (NSInteger)collectionNode:(ASCollectionNode *)collectionNode numberOfItemsInSection:(NSInteger)section { return 0; } @@ -88,9 +88,9 @@ @interface HeaderReferenceSizeTestDelegate : NSObject _update = [[ASThrashUpdate alloc] initWithData:sections]; ASThrashDataSource *ds = [[ASThrashDataSource alloc] initCollectionViewDataSourceWithData:sections]; - [self applyUpdateUsingBatchUpdates:_update + [self applyUpdateUsingBatchUpdates:self->_update toDataSource:ds animated:NO useXCTestWait:NO]; diff --git a/Tests/ASDisplayNodeAppearanceTests.mm b/Tests/ASDisplayNodeAppearanceTests.mm index 5496bc3a4..b771da353 100644 --- a/Tests/ASDisplayNodeAppearanceTests.mm +++ b/Tests/ASDisplayNodeAppearanceTests.mm @@ -82,11 +82,11 @@ - (void)setUp _didExitHierarchyCounts = [[NSCountedSet alloc] init]; dispatch_block_t cleanupBlock = modifyMethodByAddingPrologueBlockAndReturnCleanupBlock([ASDisplayNode class], @selector(willEnterHierarchy), ^(id blockSelf){ - [_willEnterHierarchyCounts addObject:blockSelf]; + [self->_willEnterHierarchyCounts addObject:blockSelf]; }); [_swizzleCleanupBlocks addObject:cleanupBlock]; cleanupBlock = modifyMethodByAddingPrologueBlockAndReturnCleanupBlock([ASDisplayNode class], @selector(didExitHierarchy), ^(id blockSelf){ - [_didExitHierarchyCounts addObject:blockSelf]; + [self->_didExitHierarchyCounts addObject:blockSelf]; }); [_swizzleCleanupBlocks addObject:cleanupBlock]; } diff --git a/Tests/ASLayoutEngineTests.mm b/Tests/ASLayoutEngineTests.mm index 3222f78b5..7a0b87599 100644 --- a/Tests/ASLayoutEngineTests.mm +++ b/Tests/ASLayoutEngineTests.mm @@ -63,7 +63,7 @@ - (void)setUp allNodes = @[ nodeA, nodeB, nodeC, nodeD, nodeE ]; ASSetDebugNames(nodeA, nodeB, nodeC, nodeD, nodeE); ASLayoutSpecBlock b = ^ASLayoutSpec * _Nonnull(__kindof ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) { - return [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal spacing:0 justifyContent:ASStackLayoutJustifyContentSpaceBetween alignItems:ASStackLayoutAlignItemsStart children:@[ nodeB, nodeC, nodeD ]]; + return [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal spacing:0 justifyContent:ASStackLayoutJustifyContentSpaceBetween alignItems:ASStackLayoutAlignItemsStart children:@[ self->nodeB, self->nodeC, self->nodeD ]]; }; fixture1and3and5NodeALayoutSpecBlock = b; fixture1 = [self createFixture1]; @@ -162,10 +162,10 @@ - (void)testLayoutTransitionWithAsyncMeasurement injectedMainThreadWork = ^{ injectedMainThreadWorkDone = YES; - [window layoutIfNeeded]; + [self->window layoutIfNeeded]; // Ensure we're still on the old layout. We should stay on this until the transition completes. - [self verifyFixture:fixture1]; + [self verifyFixture:self->fixture1]; }; measurementCompletionBlock = ^{ @@ -286,7 +286,7 @@ - (void)DISABLE_testASetNeedsLayoutInterferingWithTheCurrentTransition as_log_verbose(OS_LOG_DEFAULT, "Begin injectedMainThreadWork"); injectedMainThreadWorkDone = YES; - [fixture4 apply]; + [self->fixture4 apply]; as_log_verbose(OS_LOG_DEFAULT, "Did apply new fixture"); if (enforceCorrectBehavior) { @@ -294,10 +294,10 @@ - (void)DISABLE_testASetNeedsLayoutInterferingWithTheCurrentTransition // are common to both fixture2 and fixture4 are available from the cache. } else { // Incorrect behavior: nodeC will get measured against its new bounds on main. - const auto cPendingSize = [fixture2 layoutForNode:nodeC].size; - OCMExpect([nodeC.mock calculateLayoutThatFits:ASSizeRangeMake(cPendingSize)]).onMainThread(); + const auto cPendingSize = [self->fixture2 layoutForNode:self->nodeC].size; + OCMExpect([self->nodeC.mock calculateLayoutThatFits:ASSizeRangeMake(cPendingSize)]).onMainThread(); } - [window layoutIfNeeded]; + [self->window layoutIfNeeded]; as_log_verbose(OS_LOG_DEFAULT, "End injectedMainThreadWork"); }; @@ -342,7 +342,7 @@ - (void)testCallingSetNeedsLayoutOnANodeThatWasSubjectToMultipassLayout OCMExpect([nodeB.mock calculateLayoutThatFits:[fixture3 firstSizeRangeForNode:nodeB]]); [fixture1 withSizeRangesForNode:nodeA block:^(ASSizeRange sizeRange) { - OCMExpect([nodeA.mock calculateLayoutThatFits:sizeRange]); + OCMExpect([self->nodeA.mock calculateLayoutThatFits:sizeRange]); }]; [window layoutIfNeeded]; @@ -456,7 +456,7 @@ - (ASTLayoutFixture *)createFixture2 fixture.layout = layoutA; ASLayoutSpecBlock specBlockA = ^ASLayoutSpec * _Nonnull(__kindof ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) { - return [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal spacing:0 justifyContent:ASStackLayoutJustifyContentSpaceBetween alignItems:ASStackLayoutAlignItemsStart children:@[ nodeB, nodeC, nodeE ]]; + return [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal spacing:0 justifyContent:ASStackLayoutJustifyContentSpaceBetween alignItems:ASStackLayoutAlignItemsStart children:@[ self->nodeB, self->nodeC, self->nodeE ]]; }; [fixture.layoutSpecBlocks setObject:specBlockA forKey:nodeA]; return fixture; @@ -535,7 +535,7 @@ - (ASTLayoutFixture *)createFixture4 fixture.layout = layoutA; ASLayoutSpecBlock specBlockA = ^ASLayoutSpec * _Nonnull(__kindof ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) { - return [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal spacing:0 justifyContent:ASStackLayoutJustifyContentSpaceBetween alignItems:ASStackLayoutAlignItemsStart children:@[ nodeB, nodeD, nodeE ]]; + return [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal spacing:0 justifyContent:ASStackLayoutJustifyContentSpaceBetween alignItems:ASStackLayoutAlignItemsStart children:@[ self->nodeB, self->nodeD, self->nodeE ]]; }; [fixture.layoutSpecBlocks setObject:specBlockA forKey:nodeA]; return fixture; @@ -576,7 +576,7 @@ - (void)runFirstLayoutPassWithFixture:(ASTLayoutFixture *)fixture [fixture withSizeRangesForAllNodesUsingBlock:^(ASLayoutTestNode * _Nonnull node, ASSizeRange sizeRange) { OCMExpect([node.mock calculateLayoutThatFits:sizeRange]).onMainThread(); - if (!stubbedCalculatedLayoutDidChange) { + if (!self->stubbedCalculatedLayoutDidChange) { OCMExpect([node.mock calculatedLayoutDidChange]).onMainThread(); } }]; diff --git a/Tests/ASRecursiveUnfairLockTests.mm b/Tests/ASRecursiveUnfairLockTests.mm index 3916b319e..c76adb65b 100644 --- a/Tests/ASRecursiveUnfairLockTests.mm +++ b/Tests/ASRecursiveUnfairLockTests.mm @@ -62,7 +62,7 @@ - (void)testThatUnlockingWithoutHoldingMakesAssertion ASRecursiveUnfairLockLock(&lock); XCTestExpectation *e1 = [self expectationWithDescription:@"Other thread tried lock."]; [NSThread detachNewThreadWithBlock:^{ - XCTAssertThrows(ASRecursiveUnfairLockUnlock(&lock)); + XCTAssertThrows(ASRecursiveUnfairLockUnlock(&self->lock)); [e1 fulfill]; }]; [self waitForExpectationsWithTimeout:10 handler:nil]; @@ -93,7 +93,7 @@ - (void)testRecursiveUnfairLockContested { __block int value = 0; [self measureBlock:^{ - CHAOS_TEST_BODY(YES, ASRecursiveUnfairLockLock(&lock), {}, ASRecursiveUnfairLockUnlock(&lock)); + CHAOS_TEST_BODY(YES, ASRecursiveUnfairLockLock(&self->lock), {}, ASRecursiveUnfairLockUnlock(&self->lock)); }]; XCTAssertEqual(value, 0); } @@ -102,7 +102,7 @@ - (void)testRecursiveUnfairLockUncontested { __block int value = 0; [self measureBlock:^{ - CHAOS_TEST_BODY(NO, ASRecursiveUnfairLockLock(&lock), {}, ASRecursiveUnfairLockUnlock(&lock)); + CHAOS_TEST_BODY(NO, ASRecursiveUnfairLockLock(&self->lock), {}, ASRecursiveUnfairLockUnlock(&self->lock)); }]; XCTAssertEqual(value, 0); } diff --git a/Tests/ASTableViewTests.mm b/Tests/ASTableViewTests.mm index 846f69e45..72b179994 100644 --- a/Tests/ASTableViewTests.mm +++ b/Tests/ASTableViewTests.mm @@ -72,17 +72,17 @@ @interface ASTableViewTestDelegate : NSObject @implementation ASTableViewFilledDelegate -- (ASSizeRange)tableView:(ASTableView *)tableView constrainedSizeForRowAtIndexPath:(NSIndexPath *)indexPath +- (ASSizeRange)tableNode:(ASTableNode *)tableNode constrainedSizeForRowAtIndexPath:(NSIndexPath *)indexPath { return ASSizeRangeMake(CGSizeMake(10, 42)); } diff --git a/Tests/ASThrashUtility.m b/Tests/ASThrashUtility.m index c555d3f77..0a085c7c4 100644 --- a/Tests/ASThrashUtility.m +++ b/Tests/ASThrashUtility.m @@ -236,13 +236,13 @@ - (void)setData:(NSArray *)data _data = data; } -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +- (NSInteger)tableNode:(ASTableNode *)tableNode numberOfRowsInSection:(NSInteger)section { return self.data[section].items.count; } -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +- (NSInteger)numberOfSectionsInTableNode:(ASTableNode *)tableNode { return self.data.count; } @@ -297,7 +297,7 @@ - (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtI return node; } -- (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath +- (ASCellNode *)tableNode:(ASTableNode *)tableNode nodeForRowAtIndexPath:(NSIndexPath *)indexPath { ASThrashTestNode *node = [[ASThrashTestNode alloc] init]; node.item = self.data[indexPath.section].items[indexPath.item]; From 58b086a7c316ee77acf0f3e4f12f1c811b09c2ca Mon Sep 17 00:00:00 2001 From: Greg Bolsinga Date: Tue, 26 May 2020 10:47:39 -0700 Subject: [PATCH 2/2] Some tests require testing deprecated functionality --- Tests/ASTableViewTests.mm | 40 +++++++++++++++++++++++++++++++-------- Tests/ASThrashUtility.m | 16 ++++++++++++---- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/Tests/ASTableViewTests.mm b/Tests/ASTableViewTests.mm index 72b179994..29bb72c81 100644 --- a/Tests/ASTableViewTests.mm +++ b/Tests/ASTableViewTests.mm @@ -72,20 +72,29 @@ @interface ASTableViewTestDelegate : NSObject *)sectionIndexTitlesForTableView:(UITableView *)tableView { @@ -201,10 +222,13 @@ @interface ASTableViewFilledDelegate : NSObject @implementation ASTableViewFilledDelegate -- (ASSizeRange)tableNode:(ASTableNode *)tableNode constrainedSizeForRowAtIndexPath:(NSIndexPath *)indexPath +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +- (ASSizeRange)tableView:(ASTableView *)tableView constrainedSizeForRowAtIndexPath:(NSIndexPath *)indexPath { return ASSizeRangeMake(CGSizeMake(10, 42)); } +#pragma clang diagnostic pop @end diff --git a/Tests/ASThrashUtility.m b/Tests/ASThrashUtility.m index 0a085c7c4..ac2da5315 100644 --- a/Tests/ASThrashUtility.m +++ b/Tests/ASThrashUtility.m @@ -236,16 +236,21 @@ - (void)setData:(NSArray *)data _data = data; } -- (NSInteger)tableNode:(ASTableNode *)tableNode numberOfRowsInSection:(NSInteger)section +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.data[section].items.count; } +#pragma clang diagnostic pop - -- (NSInteger)numberOfSectionsInTableNode:(ASTableNode *)tableNode +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.data.count; } +#pragma clang diagnostic pop - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { @@ -297,13 +302,16 @@ - (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtI return node; } -- (ASCellNode *)tableNode:(ASTableNode *)tableNode nodeForRowAtIndexPath:(NSIndexPath *)indexPath +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +- (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath { ASThrashTestNode *node = [[ASThrashTestNode alloc] init]; node.item = self.data[indexPath.section].items[indexPath.item]; [self.allNodes addObject:node]; return node; } +#pragma clang diagnostic pop #endif