Skip to content

Commit

Permalink
[ASAvailability] Update AS_AVAILABLE_XXX fallbacks to function more like
Browse files Browse the repository at this point in the history
the built-in solution (more accurately target OS by checking target)
Change AS_AVAILABLE_IOS -> AS_AVAILABLE_IOS_TVOS in places that shoud
allow for both

[ASAvailability] Simplify AS_AVAILABLE_IOS_TVOS
  • Loading branch information
alexhillc committed Dec 28, 2017
1 parent 7759cf7 commit 8dbcc51
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,7 @@ - (ASRangeController *)rangeController
/// The UIKit version of this method is only available on iOS >= 9
- (NSArray<NSIndexPath *> *)asdk_indexPathsForVisibleSupplementaryElementsOfKind:(NSString *)kind
{
if (AS_AVAILABLE_IOS(9)) {
if (AS_AVAILABLE_IOS_TVOS(9, 9)) {
return [self indexPathsForVisibleSupplementaryElementsOfKind:kind];
}

Expand Down
6 changes: 3 additions & 3 deletions Source/Base/ASAvailability.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
#define AS_AVAILABLE_TVOS(ver) __builtin_available(tvOS ver, *)
#define AS_AVAILABLE_IOS_TVOS(ver1, ver2) __builtin_available(iOS ver1, tvOS ver2, *)
#else
#define AS_AVAILABLE_IOS(ver) AS_AT_LEAST_IOS##ver
#define AS_AVAILABLE_TVOS(ver) AS_AT_LEAST_IOS##ver
#define AS_AVAILABLE_IOS_TVOS(ver1, ver2) AS_AT_LEAST_IOS##ver1 || AS_AT_LEAST_IOS##ver2
#define AS_AVAILABLE_IOS(ver) (TARGET_OS_IOS && AS_AT_LEAST_IOS##ver)
#define AS_AVAILABLE_TVOS(ver) (TARGET_OS_TV && AS_AT_LEAST_IOS##ver)
#define AS_AVAILABLE_IOS_TVOS(ver1, ver2) (AS_AVAILABLE_IOS(ver1) || AS_AVAILABLE_TVOS(ver2))
#endif

// If Yoga is available, make it available anywhere we use ASAvailability.
Expand Down
10 changes: 5 additions & 5 deletions Source/Base/ASLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ ASDISPLAYNODE_EXTERN_C_END

#define as_log_create(subsystem, category) ({ \
os_log_t __val; \
if (AS_AVAILABLE_IOS(9)) { \
if (AS_AVAILABLE_IOS_TVOS(9, 9)) { \
__val = os_log_create(subsystem, category); \
} else { \
__val = (os_log_t)0; \
Expand All @@ -141,28 +141,28 @@ __val; \
})

#define as_log_debug(log, format, ...) \
if (AS_AVAILABLE_IOS(9)) { \
if (AS_AVAILABLE_IOS_TVOS(9, 9)) { \
os_log_debug(log, format, ##__VA_ARGS__); \
} else { \
(void)0; \
} \

#define as_log_info(log, format, ...) \
if (AS_AVAILABLE_IOS(9)) { \
if (AS_AVAILABLE_IOS_TVOS(9, 9)) { \
os_log_info(log, format, ##__VA_ARGS__); \
} else { \
(void)0; \
} \

#define as_log_error(log, format, ...) \
if (AS_AVAILABLE_IOS(9)) { \
if (AS_AVAILABLE_IOS_TVOS(9, 9)) { \
os_log_error(log, format, ##__VA_ARGS__); \
} else { \
(void)0; \
} \

#define as_log_fault(log, format, ...) \
if (AS_AVAILABLE_IOS(9)) { \
if (AS_AVAILABLE_IOS_TVOS(9, 9)) { \
os_log_fault(log, format, ##__VA_ARGS__); \
} else { \
(void)0; \
Expand Down
2 changes: 1 addition & 1 deletion Source/Details/ASTraitCollection.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ BOOL ASPrimitiveTraitCollectionIsEqualToASPrimitiveTraitCollection(ASPrimitiveTr

// Named so as not to conflict with a hidden Apple function, in case compiler decides not to inline
ASDISPLAYNODE_INLINE NSString *AS_NSStringFromUIUserInterfaceIdiom(UIUserInterfaceIdiom idiom) {
if (AS_AVAILABLE_IOS(9)) {
if (AS_AVAILABLE_IOS_TVOS(9, 9)) {
switch (idiom) {
case UIUserInterfaceIdiomTV:
return @"TV";
Expand Down
6 changes: 3 additions & 3 deletions Source/Private/_ASPendingState.mm
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ - (instancetype)init
accessibilityActivationPoint = CGPointZero;
accessibilityPath = nil;
edgeAntialiasingMask = (kCALayerLeftEdge | kCALayerRightEdge | kCALayerTopEdge | kCALayerBottomEdge);
if (AS_AVAILABLE_IOS(9)) {
if (AS_AVAILABLE_IOS_TVOS(9, 9)) {
semanticContentAttribute = UISemanticContentAttributeUnspecified;
}

Expand Down Expand Up @@ -1051,7 +1051,7 @@ - (void)applyToView:(UIView *)view withSpecialPropertiesHandling:(BOOL)specialPr
if (flags.setOpaque)
ASDisplayNodeAssert(layer.opaque == opaque, @"Didn't set opaque as desired");

if (AS_AVAILABLE_IOS(9)) {
if (AS_AVAILABLE_IOS_TVOS(9, 9)) {
if (flags.setSemanticContentAttribute) {
view.semanticContentAttribute = semanticContentAttribute;
}
Expand Down Expand Up @@ -1215,7 +1215,7 @@ + (_ASPendingState *)pendingViewStateFromView:(UIView *)view
pendingState.allowsGroupOpacity = layer.allowsGroupOpacity;
pendingState.allowsEdgeAntialiasing = layer.allowsEdgeAntialiasing;
pendingState.edgeAntialiasingMask = layer.edgeAntialiasingMask;
if (AS_AVAILABLE_IOS(9)) {
if (AS_AVAILABLE_IOS_TVOS(9, 9)) {
pendingState.semanticContentAttribute = view.semanticContentAttribute;
}
pendingState.isAccessibilityElement = view.isAccessibilityElement;
Expand Down

0 comments on commit 8dbcc51

Please sign in to comment.