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

[Cleanup] Small fixes to improve conformance for strict compiler settings #trivial #320

Merged
merged 1 commit into from
May 30, 2017
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
8 changes: 5 additions & 3 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1125,12 +1125,14 @@ - (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(
cell.layoutAttributes = nil;
}

- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(_ASCollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
{
// This is a safeguard similar to the behavior for cells in -[ASCollectionView collectionView:willDisplayCell:forItemAtIndexPath:]
// It ensures _ASCollectionReusableView receives layoutAttributes and calls applyLayoutAttributes.
if (view.layoutAttributes == nil) {
view.layoutAttributes = [collectionView layoutAttributesForSupplementaryElementOfKind:elementKind atIndexPath:indexPath];
if (_ASCollectionReusableView *reusableView = ASDynamicCast(view, _ASCollectionReusableView)) {
if (reusableView.layoutAttributes == nil) {
reusableView.layoutAttributes = [collectionView layoutAttributesForSupplementaryElementOfKind:elementKind atIndexPath:indexPath];
}
}

if (_asyncDelegateFlags.collectionNodeWillDisplaySupplementaryElement) {
Expand Down
2 changes: 1 addition & 1 deletion Source/Private/ASTwoDimensionalArrayUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
return newArray;
}

void ASDeleteElementsInTwoDimensionalArrayAtIndexPaths(NSMutableArray *mutableArray, NSArray *indexPaths)
void ASDeleteElementsInTwoDimensionalArrayAtIndexPaths(NSMutableArray *mutableArray, NSArray<NSIndexPath *> *indexPaths)
{
if (indexPaths.count == 0) {
return;
Expand Down
4 changes: 2 additions & 2 deletions Source/Private/TextExperiment/Component/ASTextInput.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// LICENSE file in the root directory of this source tree.
//

#import "ASTextInput.h"
#import "ASTextUtilities.h"
#import <AsyncDisplayKit/ASTextInput.h>
#import <AsyncDisplayKit/ASTextUtilities.h>


@implementation ASTextPosition
Expand Down
103 changes: 51 additions & 52 deletions Source/Private/TextExperiment/Component/ASTextLayout.m

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Private/TextExperiment/Component/ASTextLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>
#import "ASTextAttribute.h"
#import <AsyncDisplayKit/ASTextAttribute.h>

@class ASTextRunGlyphRange;

Expand Down
9 changes: 4 additions & 5 deletions Source/Private/TextExperiment/Component/ASTextLine.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
// LICENSE file in the root directory of this source tree.
//

#import "ASTextLine.h"
#import "ASTextUtilities.h"

#import <AsyncDisplayKit/ASTextLine.h>
#import <AsyncDisplayKit/ASTextUtilities.h>

@implementation ASTextLine {
CGFloat _firstGlyphPos; // first glyph position for baseline, typically 0.
Expand Down Expand Up @@ -41,7 +40,7 @@ - (void)setCTLine:(_Nonnull CTLineRef)CTLine {
_range = NSMakeRange(range.location, range.length);
if (CTLineGetGlyphCount(_CTLine) > 0) {
CFArrayRef runs = CTLineGetGlyphRuns(_CTLine);
CTRunRef run = CFArrayGetValueAtIndex(runs, 0);
CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runs, 0);
CGPoint pos;
CTRunGetPositions(run, CFRangeMake(0, 1), &pos);
_firstGlyphPos = pos.x;
Expand Down Expand Up @@ -83,7 +82,7 @@ - (void)reloadBounds {
NSMutableArray *attachmentRanges = [NSMutableArray new];
NSMutableArray *attachmentRects = [NSMutableArray new];
for (NSUInteger r = 0; r < runCount; r++) {
CTRunRef run = CFArrayGetValueAtIndex(runs, r);
CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runs, r);
CFIndex glyphCount = CTRunGetGlyphCount(run);
if (glyphCount == 0) continue;
NSDictionary *attrs = (id)CTRunGetAttributes(run);
Expand Down
14 changes: 7 additions & 7 deletions Source/Private/TextExperiment/String/ASTextAttribute.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
}

- (id)copyWithZone:(NSZone *)zone {
typeof(self) one = [self.class new];
__typeof__(self) one = [self.class new];
one.string = self.string;
return one;
}
Expand All @@ -148,7 +148,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
}

- (id)copyWithZone:(NSZone *)zone {
typeof(self) one = [self.class new];
__typeof__(self) one = [self.class new];
one.deleteConfirm = self.deleteConfirm;
return one;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
}

- (id)copyWithZone:(NSZone *)zone {
typeof(self) one = [self.class new];
__typeof__(self) one = [self.class new];
one.color = self.color;
one.radius = self.radius;
one.offset = self.offset;
Expand Down Expand Up @@ -255,7 +255,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
}

- (id)copyWithZone:(NSZone *)zone {
typeof(self) one = [self.class new];
__typeof__(self) one = [self.class new];
one.style = self.style;
one.width = self.width;
one.color = self.color;
Expand Down Expand Up @@ -314,7 +314,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
}

- (id)copyWithZone:(NSZone *)zone {
typeof(self) one = [self.class new];
__typeof__(self) one = [self.class new];
one.lineStyle = self.lineStyle;
one.strokeWidth = self.strokeWidth;
one.strokeColor = self.strokeColor;
Expand Down Expand Up @@ -352,7 +352,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
}

- (id)copyWithZone:(NSZone *)zone {
typeof(self) one = [self.class new];
__typeof__(self) one = [self.class new];
if ([self.content respondsToSelector:@selector(copy)]) {
one.content = [self.content copy];
} else {
Expand Down Expand Up @@ -390,7 +390,7 @@ - (void)setAttributes:(NSDictionary *)attributes {
}

- (id)copyWithZone:(NSZone *)zone {
typeof(self) one = [self.class new];
__typeof__(self) one = [self.class new];
one.attributes = self.attributes.mutableCopy;
return one;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Private/TextExperiment/String/ASTextRunDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// LICENSE file in the root directory of this source tree.
//

#import "ASTextRunDelegate.h"
#import <AsyncDisplayKit/ASTextRunDelegate.h>

static void DeallocCallback(void *ref) {
ASTextRunDelegate *self = (__bridge_transfer ASTextRunDelegate *)(ref);
Expand Down Expand Up @@ -60,7 +60,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
}

- (id)copyWithZone:(NSZone *)zone {
typeof(self) one = [self.class new];
__typeof__(self) one = [self.class new];
one.ascent = self.ascent;
one.descent = self.descent;
one.width = self.width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>

#import "ASTextAttribute.h"
#import <AsyncDisplayKit/ASTextAttribute.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
// LICENSE file in the root directory of this source tree.
//

#import "NSAttributedString+ASText.h"
#import "NSParagraphStyle+ASText.h"
#import "ASTextRunDelegate.h"
#import "ASTextUtilities.h"
#import <AsyncDisplayKit/NSAttributedString+ASText.h>
#import <AsyncDisplayKit/NSParagraphStyle+ASText.h>
#import <AsyncDisplayKit/ASTextRunDelegate.h>
#import <AsyncDisplayKit/ASTextUtilities.h>
#import <CoreFoundation/CoreFoundation.h>


Expand Down Expand Up @@ -119,7 +119,7 @@ - (NSUnderlineStyle)as_strikethroughStyle {

- (NSUnderlineStyle)as_strikethroughStyleAtIndex:(NSUInteger)index {
NSNumber *style = [self as_attribute:NSStrikethroughStyleAttributeName atIndex:index];
return style.integerValue;
return (NSUnderlineStyle)style.integerValue;
}

- (UIColor *)as_strikethroughColor {
Expand All @@ -136,7 +136,7 @@ - (NSUnderlineStyle)as_underlineStyle {

- (NSUnderlineStyle)as_underlineStyleAtIndex:(NSUInteger)index {
NSNumber *style = [self as_attribute:NSUnderlineStyleAttributeName atIndex:index];
return style.integerValue;
return (NSUnderlineStyle)style.integerValue;
}

- (UIColor *)as_underlineColor {
Expand Down Expand Up @@ -1188,9 +1188,9 @@ - (void)as_setClearColorToJoinedEmoji {
CFStringRef cfStr = (__bridge CFStringRef)str;
BOOL needFree = NO;
UniChar *chars = NULL;
chars = (void *)CFStringGetCharactersPtr(cfStr);
chars = (UniChar *)CFStringGetCharactersPtr(cfStr);
if (!chars) {
chars = malloc(str.length * sizeof(UniChar));
chars = (UniChar *)malloc(str.length * sizeof(UniChar));
if (chars) {
needFree = YES;
CFStringGetCharacters(cfStr, CFRangeMake(0, str.length), chars);
Expand Down
10 changes: 5 additions & 5 deletions Source/Private/TextExperiment/Utility/NSParagraphStyle+ASText.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// LICENSE file in the root directory of this source tree.
//

#import "NSParagraphStyle+ASText.h"
#import "ASTextAttribute.h"
#import <AsyncDisplayKit/NSParagraphStyle+ASText.h>
#import <AsyncDisplayKit/ASTextAttribute.h>
#import <CoreText/CoreText.h>

// Dummy class for category
Expand Down Expand Up @@ -92,7 +92,7 @@ + (NSParagraphStyle *)as_styleWithCTStyle:(CTParagraphStyleRef)CTStyle {
if (CTParagraphStyleGetValueForSpecifier(CTStyle, kCTParagraphStyleSpecifierTabStops, sizeof(CFArrayRef), &tabStops)) {
NSMutableArray *tabs = [NSMutableArray new];
[((__bridge NSArray *)(tabStops))enumerateObjectsUsingBlock : ^(id obj, NSUInteger idx, BOOL *stop) {
CTTextTabRef ctTab = (__bridge CFTypeRef)obj;
CTTextTabRef ctTab = (__bridge CTTextTabRef)obj;

NSTextTab *tab = [[NSTextTab alloc] initWithTextAlignment:NSTextAlignmentFromCTTextAlignment(CTTextTabGetAlignment(ctTab)) location:CTTextTabGetLocation(ctTab) options:(__bridge id)CTTextTabGetOptions(ctTab)];
[tabs addObject:tab];
Expand All @@ -111,7 +111,7 @@ + (NSParagraphStyle *)as_styleWithCTStyle:(CTParagraphStyleRef)CTStyle {
}

- (CTParagraphStyleRef)as_CTStyle CF_RETURNS_RETAINED {
CTParagraphStyleSetting set[kCTParagraphStyleSpecifierCount] = { 0 };
CTParagraphStyleSetting set[kCTParagraphStyleSpecifierCount] = { };
int count = 0;

#pragma clang diagnostic push
Expand Down Expand Up @@ -193,7 +193,7 @@ - (CTParagraphStyleRef)as_CTStyle CF_RETURNS_RETAINED {
NSInteger numTabs = self.tabStops.count;
if (numTabs) {
[self.tabStops enumerateObjectsUsingBlock: ^(NSTextTab *tab, NSUInteger idx, BOOL *stop) {
CTTextTabRef ctTab = CTTextTabCreate(NSTextAlignmentToCTTextAlignment(tab.alignment), tab.location, (__bridge CFTypeRef)tab.options);
CTTextTabRef ctTab = CTTextTabCreate(NSTextAlignmentToCTTextAlignment(tab.alignment), tab.location, (__bridge CFDictionaryRef)tab.options);
[tabs addObject:(__bridge id)ctTab];
CFRelease(ctTab);
}];
Expand Down