Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address compiler warnings #trivial #1207

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Source/ASNetworkImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,11 @@ - (void)_downloadImageWithCompletion:(void (^)(id <ASImageContainerProtocol> ima
// it and try again.
{
ASLockScopeSelf();
url = _URL;
url = self->_URL;
}


downloadIdentifier = [_downloader downloadImageWithURL:url
downloadIdentifier = [self->_downloader downloadImageWithURL:url
callbackQueue:[self callbackQueue]
downloadProgress:NULL
completion:^(id <ASImageContainerProtocol> _Nullable imageContainer, NSError * _Nullable error, id _Nullable downloadIdentifier, id _Nullable userInfo) {
Expand All @@ -586,9 +586,9 @@ - (void)_downloadImageWithCompletion:(void (^)(id <ASImageContainerProtocol> ima

{
ASLockScopeSelf();
if (ASObjectIsEqual(_URL, url)) {
if (ASObjectIsEqual(self->_URL, url)) {
// The download we kicked off is correct, no need to do any more work.
_downloadIdentifier = downloadIdentifier;
self->_downloadIdentifier = downloadIdentifier;
} else {
// The URL changed since we kicked off our download task. This shouldn't happen often so we'll pay the cost and
// cancel that request and kick off a new one.
Expand All @@ -599,7 +599,7 @@ - (void)_downloadImageWithCompletion:(void (^)(id <ASImageContainerProtocol> ima
if (cancelAndReattempt) {
if (downloadIdentifier != nil) {
as_log_verbose(ASImageLoadingLog(), "Canceling image download no resume for %@ id: %@", self, downloadIdentifier);
[_downloader cancelImageDownloadForIdentifier:downloadIdentifier];
[self->_downloader cancelImageDownloadForIdentifier:downloadIdentifier];
}
[self _downloadImageWithCompletion:finished];
return;
Expand Down Expand Up @@ -631,11 +631,11 @@ - (void)_lazilyLoadImageIfNecessary
ASLockScopeSelf();

// Bail out if not the same URL anymore
if (!ASObjectIsEqual(URL, _URL)) {
if (!ASObjectIsEqual(URL, self->_URL)) {
return;
}

if (_shouldCacheImage) {
if (self->_shouldCacheImage) {
[self _locked__setImage:[UIImage imageNamed:URL.path.lastPathComponent]];
} else {
// First try to load the path directly, for efficiency assuming a developer who
Expand All @@ -652,10 +652,10 @@ - (void)_lazilyLoadImageIfNecessary

// If the file may be an animated gif and then created an animated image.
id<ASAnimatedImageProtocol> animatedImage = nil;
if (_downloaderFlags.downloaderImplementsAnimatedImage) {
if (self->_downloaderFlags.downloaderImplementsAnimatedImage) {
let data = [[NSData alloc] initWithContentsOfURL:URL];
if (data != nil) {
animatedImage = [_downloader animatedImageWithData:data];
animatedImage = [self->_downloader animatedImageWithData:data];

if ([animatedImage respondsToSelector:@selector(isDataSupported:)] && [animatedImage isDataSupported:data] == NO) {
animatedImage = nil;
Expand All @@ -670,15 +670,15 @@ - (void)_lazilyLoadImageIfNecessary
}
}

_imageLoaded = YES;
self->_imageLoaded = YES;

[self _setCurrentImageQuality:1.0];

if (_delegateFlags.delegateDidLoadImageWithInfo) {
if (self->_delegateFlags.delegateDidLoadImageWithInfo) {
ASUnlockScope(self);
let info = [[ASNetworkImageLoadInfo alloc] initWithURL:URL sourceType:ASNetworkImageSourceFileURL downloadIdentifier:nil userInfo:nil];
[delegate imageNode:self didLoadImage:self.image info:info];
} else if (_delegateFlags.delegateDidLoadImage) {
} else if (self->_delegateFlags.delegateDidLoadImage) {
ASUnlockScope(self);
[delegate imageNode:self didLoadImage:self.image];
}
Expand Down Expand Up @@ -729,17 +729,17 @@ - (void)_lazilyLoadImageIfNecessary
void (^calloutBlock)(ASNetworkImageNode *inst);

if (newImage) {
if (_delegateFlags.delegateDidLoadImageWithInfo) {
if (self->_delegateFlags.delegateDidLoadImageWithInfo) {
calloutBlock = ^(ASNetworkImageNode *strongSelf) {
let info = [[ASNetworkImageLoadInfo alloc] initWithURL:URL sourceType:imageSource downloadIdentifier:downloadIdentifier userInfo:userInfo];
[delegate imageNode:strongSelf didLoadImage:newImage info:info];
};
} else if (_delegateFlags.delegateDidLoadImage) {
} else if (self->_delegateFlags.delegateDidLoadImage) {
calloutBlock = ^(ASNetworkImageNode *strongSelf) {
[delegate imageNode:strongSelf didLoadImage:newImage];
};
}
} else if (error && _delegateFlags.delegateDidFailWithError) {
} else if (error && self->_delegateFlags.delegateDidFailWithError) {
calloutBlock = ^(ASNetworkImageNode *strongSelf) {
[delegate imageNode:strongSelf didFailWithError:error];
};
Expand Down Expand Up @@ -768,11 +768,11 @@ - (void)_lazilyLoadImageIfNecessary

ASImageCacherCompletion completion = ^(id <ASImageContainerProtocol> imageContainer) {
// If the cache sentinel changed, that means this request was cancelled.
if (ASLockedSelf(_cacheSentinel != cacheSentinel)) {
if (ASLockedSelf(self->_cacheSentinel != cacheSentinel)) {
return;
}

if ([imageContainer asdk_image] == nil && _downloader != nil) {
if ([imageContainer asdk_image] == nil && self->_downloader != nil) {
[self _downloadImageWithCompletion:^(id<ASImageContainerProtocol> imageContainer, NSError *error, id downloadIdentifier, id userInfo) {
finished(imageContainer, error, downloadIdentifier, ASNetworkImageSourceDownload, userInfo);
}];
Expand Down
6 changes: 3 additions & 3 deletions Source/ASTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ - (id)_linkAttributeValueAtPoint:(CGPoint)point
return;
}

for (NSString *attributeName in _linkAttributeNames) {
for (NSString *attributeName in self->_linkAttributeNames) {
NSRange range;
id value = [attributedString attribute:attributeName atIndex:characterIndex longestEffectiveRange:&range inRange:clampedRange];
NSString *name = attributeName;
Expand All @@ -619,8 +619,8 @@ - (id)_linkAttributeValueAtPoint:(CGPoint)point

// If highlighting, check with delegate first. If not implemented, assume YES.
if (highlighting
&& [_delegate respondsToSelector:@selector(textNode:shouldHighlightLinkAttribute:value:atPoint:)]
&& ![_delegate textNode:self shouldHighlightLinkAttribute:name value:value atPoint:point]) {
&& [self->_delegate respondsToSelector:@selector(textNode:shouldHighlightLinkAttribute:value:atPoint:)]
&& ![self->_delegate textNode:self shouldHighlightLinkAttribute:name value:value atPoint:point]) {
value = nil;
name = nil;
}
Expand Down
8 changes: 4 additions & 4 deletions Source/Details/ASMainSerialQueue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ - (void)runBlocks
{
dispatch_block_t mainThread = ^{
do {
ASDN::MutexLocker l(_serialQueueLock);
ASDN::MutexLocker l(self->_serialQueueLock);
dispatch_block_t block;
if (_blocks.count > 0) {
if (self->_blocks.count > 0) {
block = _blocks[0];
[_blocks removeObjectAtIndex:0];
[self->_blocks removeObjectAtIndex:0];
} else {
break;
}
{
ASDN::MutexUnlocker u(_serialQueueLock);
ASDN::MutexUnlocker u(self->_serialQueueLock);
block();
}
} while (true);
Expand Down
2 changes: 1 addition & 1 deletion Source/Details/ASRecursiveUnfairLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN

OS_UNFAIR_LOCK_AVAILABILITY
typedef struct {
os_unfair_lock _lock;
os_unfair_lock _lock OS_UNFAIR_LOCK_AVAILABILITY;
_Atomic(pthread_t) _thread; // Write-protected by lock
int _count; // Protected by lock
} ASRecursiveUnfairLock;
Expand Down
8 changes: 4 additions & 4 deletions Source/Details/ASTraitCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ typedef struct ASPrimitiveTraitCollection {
UIUserInterfaceSizeClass verticalSizeClass;

CGFloat displayScale;
UIDisplayGamut displayGamut;
UIDisplayGamut displayGamut API_AVAILABLE(ios(10.0));

UIUserInterfaceIdiom userInterfaceIdiom;
UIForceTouchCapability forceTouchCapability;
UITraitEnvironmentLayoutDirection layoutDirection;
UITraitEnvironmentLayoutDirection layoutDirection API_AVAILABLE(ios(10.0));
#if TARGET_OS_TV
UIUserInterfaceStyle userInterfaceStyle;
#endif
Expand Down Expand Up @@ -168,11 +168,11 @@ AS_SUBCLASSING_RESTRICTED
@property (nonatomic, readonly) UIUserInterfaceSizeClass verticalSizeClass;

@property (nonatomic, readonly) CGFloat displayScale;
@property (nonatomic, readonly) UIDisplayGamut displayGamut;
@property (nonatomic, readonly) UIDisplayGamut displayGamut API_AVAILABLE(ios(10.0));

@property (nonatomic, readonly) UIUserInterfaceIdiom userInterfaceIdiom;
@property (nonatomic, readonly) UIForceTouchCapability forceTouchCapability;
@property (nonatomic, readonly) UITraitEnvironmentLayoutDirection layoutDirection;
@property (nonatomic, readonly) UITraitEnvironmentLayoutDirection layoutDirection API_AVAILABLE(ios(10.0));
#if TARGET_OS_TV
@property (nonatomic, readonly) UIUserInterfaceStyle userInterfaceStyle;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/Private/TextExperiment/Component/ASTextLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ + (ASTextLayout *)layoutWithContainer:(ASTextContainer *)container text:(NSAttri
}
int i = 0;
if (type != kCTLineTruncationStart) { // Middle or End/Tail wants text preceding truncated content.
i = removedLines.count - 1;
i = (int)removedLines.count - 1;
while (atLeastOneLine < truncatedWidth && i >= 0) {
if (lastLineText.length > 0 && [lastLineText.string characterAtIndex:lastLineText.string.length - 1] == '\n') { // Explicit newlines are always "long enough".
[lastLineText deleteCharactersInRange:NSMakeRange(lastLineText.string.length - 1, 1)];
Expand Down
10 changes: 5 additions & 5 deletions Source/TextKit/ASTextKitFontSizeAdjuster.mm
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ - (CGFloat)scaleFactor

// check to see if we may need to shrink for any of these things
BOOL longestWordFits = [longestWordNeedingResize length] ? NO : YES;
BOOL maxLinesFits = _attributes.maximumNumberOfLines > 0 ? NO : YES;
BOOL heightFits = isinf(_constrainedSize.height) ? YES : NO;
BOOL maxLinesFits = self->_attributes.maximumNumberOfLines > 0 ? NO : YES;
BOOL heightFits = isinf(self->_constrainedSize.height) ? YES : NO;

CGSize longestWordSize = CGSizeZero;
if (longestWordFits == NO) {
Expand All @@ -204,7 +204,7 @@ - (CGFloat)scaleFactor

if (longestWordFits == NO) {
// we need to check the longest word to make sure it fits
longestWordFits = std::ceil((longestWordSize.width * adjustedScale) <= _constrainedSize.width);
longestWordFits = std::ceil((longestWordSize.width * adjustedScale) <= self->_constrainedSize.width);
}

// if the longest word fits, go ahead and check max line and height. If it didn't fit continue to the next scale factor
Expand All @@ -216,14 +216,14 @@ - (CGFloat)scaleFactor

// check to see if this scaled string fit in the max lines
if (maxLinesFits == NO) {
maxLinesFits = ([self lineCountForString:scaledString] <= _attributes.maximumNumberOfLines);
maxLinesFits = ([self lineCountForString:scaledString] <= self->_attributes.maximumNumberOfLines);
}

// if max lines still doesn't fit, continue without checking that we fit in the constrained height
if (maxLinesFits == YES && heightFits == NO) {
// max lines fit so make sure that we fit in the constrained height.
CGSize stringSize = [self boundingBoxForString:scaledString];
heightFits = (stringSize.height <= _constrainedSize.height);
heightFits = (stringSize.height <= self->_constrainedSize.height);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/TextKit/ASTextKitRenderer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ - (void)_calculateSize
// apply the string scale before truncating or else we may truncate the string after we've done the work to shrink it.
[[self context] performBlockWithLockedTextKitComponents:^(NSLayoutManager *layoutManager, NSTextStorage *textStorage, NSTextContainer *textContainer) {
NSMutableAttributedString *scaledString = [[NSMutableAttributedString alloc] initWithAttributedString:textStorage];
[ASTextKitFontSizeAdjuster adjustFontSizeForAttributeString:scaledString withScaleFactor:_currentScaleFactor];
[ASTextKitFontSizeAdjuster adjustFontSizeForAttributeString:scaledString withScaleFactor:self->_currentScaleFactor];
scaledTextStorage = [[NSTextStorage alloc] initWithAttributedString:scaledString];

[textStorage removeLayoutManager:layoutManager];
Expand Down Expand Up @@ -217,7 +217,7 @@ - (void)drawInContext:(CGContextRef)context bounds:(CGRect)bounds;
if (isScaled) {
// if we are going to scale the text, swap out the non-scaled text for the scaled version.
NSMutableAttributedString *scaledString = [[NSMutableAttributedString alloc] initWithAttributedString:textStorage];
[ASTextKitFontSizeAdjuster adjustFontSizeForAttributeString:scaledString withScaleFactor:_currentScaleFactor];
[ASTextKitFontSizeAdjuster adjustFontSizeForAttributeString:scaledString withScaleFactor:self->_currentScaleFactor];
scaledTextStorage = [[NSTextStorage alloc] initWithAttributedString:scaledString];

[textStorage removeLayoutManager:layoutManager];
Expand Down
6 changes: 3 additions & 3 deletions Source/TextKit/ASTextKitTailTruncater.mm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ - (void)truncate
actualGlyphRange:NULL];

// Check if text is truncated, and if so apply our truncation string
if (visibleCharacterRange.length < originalStringLength && _truncationAttributedString.length > 0) {
if (visibleCharacterRange.length < originalStringLength && self->_truncationAttributedString.length > 0) {
NSInteger firstCharacterIndexToReplace = [self _calculateCharacterIndexBeforeTruncationMessage:layoutManager
textStorage:textStorage
textContainer:textContainer];
Expand All @@ -171,10 +171,10 @@ - (void)truncate
textStorage.length - firstCharacterIndexToReplace);
// Replace the end of the visible message with the truncation string
[textStorage replaceCharactersInRange:truncationReplacementRange
withAttributedString:_truncationAttributedString];
withAttributedString:self->_truncationAttributedString];
}

_visibleRanges = { visibleCharacterRange };
self->_visibleRanges = { visibleCharacterRange };
}];
}

Expand Down