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

[ASTextNode2] Provide compiler flag to enable ASTextNode2 for all usages. #410

Merged
merged 5 commits into from
Jul 3, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 8 additions & 8 deletions AsyncDisplayKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
9019FBBE1ED8061D00C45F72 /* ASYogaLayoutSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9019FBBA1ED8061D00C45F72 /* ASYogaLayoutSpec.mm */; };
9019FBBF1ED8061D00C45F72 /* ASYogaUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 9019FBBB1ED8061D00C45F72 /* ASYogaUtilities.h */; };
9019FBC01ED8061D00C45F72 /* ASYogaUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9019FBBC1ED8061D00C45F72 /* ASYogaUtilities.mm */; };
909C4C751F09C98B00D6B76F /* ASTextNode2.h in Headers */ = {isa = PBXBuildFile; fileRef = 909C4C731F09C98B00D6B76F /* ASTextNode2.h */; settings = {ATTRIBUTES = (Public, ); }; };
909C4C761F09C98B00D6B76F /* ASTextNode2.mm in Sources */ = {isa = PBXBuildFile; fileRef = 909C4C741F09C98B00D6B76F /* ASTextNode2.mm */; };
90FC784F1E4BFE1B00383C5A /* ASDisplayNode+Yoga.mm in Sources */ = {isa = PBXBuildFile; fileRef = 90FC784E1E4BFE1B00383C5A /* ASDisplayNode+Yoga.mm */; };
92DD2FE61BF4D05E0074C9DD /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 92DD2FE51BF4D05E0074C9DD /* MapKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
92DD2FE71BF4D0850074C9DD /* ASMapNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 92DD2FE21BF4B97E0074C9DD /* ASMapNode.mm */; };
Expand Down Expand Up @@ -394,8 +396,6 @@
CCCCCCE41EC3EF060087FE10 /* NSParagraphStyle+ASText.m in Sources */ = {isa = PBXBuildFile; fileRef = CCCCCCD41EC3EF060087FE10 /* NSParagraphStyle+ASText.m */; };
CCCCCCE71EC3F0FC0087FE10 /* NSAttributedString+ASText.h in Headers */ = {isa = PBXBuildFile; fileRef = CCCCCCE51EC3F0FC0087FE10 /* NSAttributedString+ASText.h */; };
CCCCCCE81EC3F0FC0087FE10 /* NSAttributedString+ASText.m in Sources */ = {isa = PBXBuildFile; fileRef = CCCCCCE61EC3F0FC0087FE10 /* NSAttributedString+ASText.m */; };
CCD523111EBD658C001F2191 /* ASTextNode2.h in Headers */ = {isa = PBXBuildFile; fileRef = CCD5230F1EBD658C001F2191 /* ASTextNode2.h */; };
CCD523121EBD658C001F2191 /* ASTextNode2.mm in Sources */ = {isa = PBXBuildFile; fileRef = CCD523101EBD658C001F2191 /* ASTextNode2.mm */; };
CCDD148B1EEDCD9D0020834E /* ASCollectionModernDataSourceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CCDD148A1EEDCD9D0020834E /* ASCollectionModernDataSourceTests.m */; };
CCF18FF41D2575E300DF5895 /* NSIndexSet+ASHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = CC4981BA1D1C7F65004E13CC /* NSIndexSet+ASHelpers.h */; settings = {ATTRIBUTES = (Private, ); }; };
DB55C2671C641AE4004EDCF5 /* ASContextTransitioning.h in Headers */ = {isa = PBXBuildFile; fileRef = DB55C2651C641AE4004EDCF5 /* ASContextTransitioning.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -690,6 +690,8 @@
9019FBBA1ED8061D00C45F72 /* ASYogaLayoutSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASYogaLayoutSpec.mm; sourceTree = "<group>"; };
9019FBBB1ED8061D00C45F72 /* ASYogaUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASYogaUtilities.h; sourceTree = "<group>"; };
9019FBBC1ED8061D00C45F72 /* ASYogaUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASYogaUtilities.mm; sourceTree = "<group>"; };
909C4C731F09C98B00D6B76F /* ASTextNode2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASTextNode2.h; sourceTree = "<group>"; };
909C4C741F09C98B00D6B76F /* ASTextNode2.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASTextNode2.mm; sourceTree = "<group>"; };
90FC784E1E4BFE1B00383C5A /* ASDisplayNode+Yoga.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "ASDisplayNode+Yoga.mm"; sourceTree = "<group>"; };
92DD2FE11BF4B97E0074C9DD /* ASMapNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASMapNode.h; sourceTree = "<group>"; };
92DD2FE21BF4B97E0074C9DD /* ASMapNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASMapNode.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -862,8 +864,6 @@
CCCCCCD41EC3EF060087FE10 /* NSParagraphStyle+ASText.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSParagraphStyle+ASText.m"; sourceTree = "<group>"; };
CCCCCCE51EC3F0FC0087FE10 /* NSAttributedString+ASText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSAttributedString+ASText.h"; sourceTree = "<group>"; };
CCCCCCE61EC3F0FC0087FE10 /* NSAttributedString+ASText.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSAttributedString+ASText.m"; sourceTree = "<group>"; };
CCD5230F1EBD658C001F2191 /* ASTextNode2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASTextNode2.h; sourceTree = "<group>"; };
CCD523101EBD658C001F2191 /* ASTextNode2.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASTextNode2.mm; sourceTree = "<group>"; };
CCDD148A1EEDCD9D0020834E /* ASCollectionModernDataSourceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASCollectionModernDataSourceTests.m; sourceTree = "<group>"; };
CCE04B1E1E313EA7006AEBBB /* ASSectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASSectionController.h; sourceTree = "<group>"; };
CCE04B201E313EB9006AEBBB /* IGListAdapter+AsyncDisplayKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IGListAdapter+AsyncDisplayKit.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1089,6 +1089,8 @@
058D09DF195D050800B7D73C /* ASTextNode.h */,
A373200E1C571B050011FC94 /* ASTextNode+Beta.h */,
058D09E0195D050800B7D73C /* ASTextNode.mm */,
909C4C731F09C98B00D6B76F /* ASTextNode2.h */,
909C4C741F09C98B00D6B76F /* ASTextNode2.mm */,
ACC945A81BA9E7A0005E1FB8 /* ASViewController.h */,
9CFFC6BF1CCAC73C006A6476 /* ASViewController.mm */,
6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */,
Expand Down Expand Up @@ -1297,8 +1299,6 @@
058D0A01195D050800B7D73C /* Private */ = {
isa = PBXGroup;
children = (
CCD5230F1EBD658C001F2191 /* ASTextNode2.h */,
CCD523101EBD658C001F2191 /* ASTextNode2.mm */,
CCA282CE1E9EBF6C0037E8B7 /* ASTipsWindow.h */,
CCA282CF1E9EBF6C0037E8B7 /* ASTipsWindow.m */,
CCA282C61E9EB64B0037E8B7 /* ASDisplayNodeTipState.h */,
Expand Down Expand Up @@ -1680,7 +1680,6 @@
B13CA1011C52004900E031AB /* ASCollectionNode+Beta.h in Headers */,
68C215581DE10D330019C4BC /* ASCollectionViewLayoutInspector.h in Headers */,
B35062411B010EFD0018CF92 /* _ASAsyncTransactionGroup.h in Headers */,
CCD523111EBD658C001F2191 /* ASTextNode2.h in Headers */,
B350620F1B010EFD0018CF92 /* _ASDisplayLayer.h in Headers */,
CCCCCCD71EC3EF060087FE10 /* ASTextInput.h in Headers */,
B35062111B010EFD0018CF92 /* _ASDisplayView.h in Headers */,
Expand Down Expand Up @@ -1818,6 +1817,7 @@
DECBD6E81BE56E1900CF4905 /* ASButtonNode.h in Headers */,
B35062241B010EFD0018CF92 /* ASMutableAttributedStringBuilder.h in Headers */,
B13CA0F81C519EBA00E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h in Headers */,
909C4C751F09C98B00D6B76F /* ASTextNode2.h in Headers */,
B35062061B010EFD0018CF92 /* ASNetworkImageNode.h in Headers */,
CCA282C81E9EB64B0037E8B7 /* ASDisplayNodeTipState.h in Headers */,
34EFC76C1B701CED00AD841F /* ASOverlayLayoutSpec.h in Headers */,
Expand Down Expand Up @@ -2186,7 +2186,6 @@
B350624E1B010EFD0018CF92 /* ASDisplayNode+AsyncDisplay.mm in Sources */,
25E327591C16819500A2170C /* ASPagerNode.m in Sources */,
636EA1A41C7FF4EC00EE152F /* NSArray+Diffing.m in Sources */,
CCD523121EBD658C001F2191 /* ASTextNode2.mm in Sources */,
B35062501B010EFD0018CF92 /* ASDisplayNode+DebugTiming.mm in Sources */,
DEC146B91C37A16A004A0EE7 /* ASCollectionInternal.m in Sources */,
254C6B891BF94F8A003EC431 /* ASTextKitRenderer+Positioning.mm in Sources */,
Expand Down Expand Up @@ -2258,6 +2257,7 @@
34EFC7741B701D0A00AD841F /* ASAbsoluteLayoutSpec.mm in Sources */,
CCCCCCE81EC3F0FC0087FE10 /* NSAttributedString+ASText.m in Sources */,
690C35621E055C5D00069B91 /* ASDimensionInternal.mm in Sources */,
909C4C761F09C98B00D6B76F /* ASTextNode2.mm in Sources */,
68C2155A1DE10D330019C4BC /* ASCollectionViewLayoutInspector.m in Sources */,
DB78412E1C6BCE1600A9E2B4 /* _ASTransitionContext.m in Sources */,
B350620B1B010EFD0018CF92 /* ASTableView.mm in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions Source/ASTextNode+Beta.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

NS_ASSUME_NONNULL_BEGIN

// When enabled, use ASTextNode2 for subclasses, random instances, or all instances of ASTextNode.
// See ASAvailability.h declaration of ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE for a compile-time option.
typedef NS_OPTIONS(NSUInteger, ASTextNodeExperimentOptions) {
// All subclass instances use the experimental implementation.
ASTextNodeExperimentSubclasses = 1 << 0,
Expand Down
19 changes: 17 additions & 2 deletions Source/ASTextNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@
// http://www.apache.org/licenses/LICENSE-2.0
//

#import <AsyncDisplayKit/ASAvailability.h>
#import <AsyncDisplayKit/ASControlNode.h>
#if ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE
#import <AsyncDisplayKit/ASTextNode2.h>
#endif

NS_ASSUME_NONNULL_BEGIN

@protocol ASTextNodeDelegate;

#if !ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE

/**
* Highlight styles.
*/
Expand Down Expand Up @@ -232,6 +238,13 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {

@end

#else

@interface ASTextNode : ASTextNode2
@end

#endif

/**
* @abstract Text node delegate.
*/
Expand Down Expand Up @@ -287,6 +300,8 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {

@end

#if !ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE

@interface ASTextNode (Unavailable)

- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable;
Expand Down Expand Up @@ -319,6 +334,6 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {

@end

NS_ASSUME_NONNULL_END

#endif

NS_ASSUME_NONNULL_END
9 changes: 9 additions & 0 deletions Source/ASTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#import <AsyncDisplayKit/ASTextNode.h>
#import <AsyncDisplayKit/ASTextNode2.h>

#if !ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE
#import <AsyncDisplayKit/ASTextNode+Beta.h>

#include <mutex>
Expand Down Expand Up @@ -1471,3 +1473,10 @@ - (NSAttributedString *)truncationAttributedString
}

@end

#else

@implementation ASTextNode
@end

#endif
19 changes: 19 additions & 0 deletions Source/Private/ASTextNode2.h → Source/ASTextNode2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,27 @@

#import <AsyncDisplayKit/ASControlNode.h>

#if !ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE
// Import this to get ASTextNodeHighlightStyle
#import <AsyncDisplayKit/ASTextNode.h>
#else
@protocol ASTextNodeDelegate;

/**
* Highlight styles.
*/
typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {
/**
* Highlight style for text on a light background.
*/
ASTextNodeHighlightStyleLight,

/**
* Highlight style for text on a dark background.
*/
ASTextNodeHighlightStyleDark
};
#endif

NS_ASSUME_NONNULL_BEGIN

Expand Down
1 change: 1 addition & 0 deletions Source/Private/ASTextNode2.mm → Source/ASTextNode2.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//

#import <AsyncDisplayKit/ASTextNode2.h>
#import <AsyncDisplayKit/ASTextNode.h> // Definition of ASTextNodeDelegate

#import <tgmath.h>
#import <deque>
Expand Down
1 change: 1 addition & 0 deletions Source/AsyncDisplayKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#import <AsyncDisplayKit/ASControlNode.h>
#import <AsyncDisplayKit/ASImageNode.h>
#import <AsyncDisplayKit/ASTextNode.h>
#import <AsyncDisplayKit/ASTextNode2.h>
#import <AsyncDisplayKit/ASButtonNode.h>
#import <AsyncDisplayKit/ASMapNode.h>
#import <AsyncDisplayKit/ASVideoNode.h>
Expand Down
7 changes: 7 additions & 0 deletions Source/Base/ASAvailability.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
#define YOGA __has_include(YOGA_HEADER_PATH)
#endif

// When enabled, use ASTextNode2 for ALL instances of ASTextNode.
// This includes what ASButtonNode uses internally, as well as all app references to ASTextNode.
// See ASTextNode+Beta.h declaration of ASTextNodeExperimentOptions for more details.
#ifndef ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE
#define ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE 0
#endif

#define AS_PIN_REMOTE_IMAGE __has_include(<PINRemoteImage/PINRemoteImage.h>)
#define AS_IG_LIST_KIT __has_include(<IGListKit/IGListKit.h>)

Expand Down