Unify boolean flag naming confention, getter spacing, and property attribute naming

Summary:
* Fixes #3
* Ordering: atomicity, then [optional] readonly, then value semantics (retain/copy/assign)
* Removed redundant `readwrite`
* No spaces between "getter = name" ("getter=name" instead)
* Property method overrides renamed as well
* self.isBlah, while technically not entirely correct, still resolves to [self blah], so left alone (@kimon had advice on this sort of naming issue last summer), and largely inconsequential

Test Plan:
* Compile and run
This commit is contained in:
Andrew Toulouse 2014-07-16 15:57:18 -07:00
parent f504ab4d15
commit a35c109a08
16 changed files with 44 additions and 44 deletions

View File

@ -38,7 +38,7 @@ typedef NSUInteger ASControlNodeEvent;
@abstract Indicates whether or not the receiver is enabled. @abstract Indicates whether or not the receiver is enabled.
@discussion Specify YES to make the control enabled; otherwise, specify NO to make it disabled. The default value is YES. If the enabled state is NO, the control ignores touch events and subclasses may draw differently. @discussion Specify YES to make the control enabled; otherwise, specify NO to make it disabled. The default value is YES. If the enabled state is NO, the control ignores touch events and subclasses may draw differently.
*/ */
@property (nonatomic, readwrite, assign, getter=isEnabled) BOOL enabled; @property (nonatomic, assign, getter=isEnabled) BOOL enabled;
/** /**
@abstract Indicates whether or not the receiver is highlighted. @abstract Indicates whether or not the receiver is highlighted.

View File

@ -29,16 +29,16 @@
- (id)initWithLayerClass:(Class)layerClass; - (id)initWithLayerClass:(Class)layerClass;
// If this view is strictly synchronous (ie wraps a non _ASDisplayView view) // If this view is strictly synchronous (ie wraps a non _ASDisplayView view)
@property (nonatomic, readonly) BOOL isSynchronous; @property (nonatomic, readonly, assign, getter=isSynchronous) BOOL synchronous;
// The view property is lazily initialized, similar to UIViewController. // The view property is lazily initialized, similar to UIViewController.
// The first access to it must be on the main thread, and should only be used on the main thread thereafter as well. // The first access to it must be on the main thread, and should only be used on the main thread thereafter as well.
// To go the other direction, use ASViewToDisplayNode() in ASDisplayNodeExtras.h // To go the other direction, use ASViewToDisplayNode() in ASDisplayNodeExtras.h
@property (nonatomic, readonly, retain) UIView *view; @property (nonatomic, readonly, retain) UIView *view;
@property (atomic, readonly, assign) BOOL isViewLoaded; // Also YES if isLayerBacked == YES && self.layer != nil. Rename to isBackingLoaded? @property (atomic, readonly, assign, getter=isViewLoaded) BOOL viewLoaded; // Also YES if isLayerBacked == YES && self.layer != nil. Rename to isBackingLoaded?
// If this node does not have an associated view, instead relying directly upon a layer // If this node does not have an associated view, instead relying directly upon a layer
@property (nonatomic, assign) BOOL isLayerBacked; @property (nonatomic, assign, getter=isLayerBacked) BOOL layerBacked;
// The same restrictions apply as documented above about the view property. To go the other direction, use ASLayerToDisplayNode() in ASDisplayNodeExtras.h // The same restrictions apply as documented above about the view property. To go the other direction, use ASLayerToDisplayNode() in ASDisplayNodeExtras.h
@property (nonatomic, readonly, retain) CALayer *layer; @property (nonatomic, readonly, retain) CALayer *layer;
@ -131,7 +131,7 @@
Note: this has nothing to do with CALayer@drawsAsynchronously Note: this has nothing to do with CALayer@drawsAsynchronously
*/ */
@property (nonatomic) BOOL displaysAsynchronously; @property (nonatomic, assign) BOOL displaysAsynchronously;
/** /**
@abstract @abstract

View File

@ -302,12 +302,12 @@ _OBJC_SUPPORTED_INLINE_REFCNT_WITH_DEALLOC2MAIN(_retainCount);
return _flags.isSynchronous; return _flags.isSynchronous;
} }
- (void)setIsSynchronous:(BOOL)flag - (void)setSynchronous:(BOOL)flag
{ {
_flags.isSynchronous = flag; _flags.isSynchronous = flag;
} }
- (void)setIsLayerBacked:(BOOL)isLayerBacked - (void)setLayerBacked:(BOOL)isLayerBacked
{ {
if (![self.class layerBackedNodesEnabled]) return; if (![self.class layerBackedNodesEnabled]) return;

View File

@ -23,7 +23,7 @@ typedef NS_ENUM(NSUInteger, ASImageNodeTint) {
#pragma mark - Cropping #pragma mark - Cropping
//! @abstract Indicates whether efficient cropping of the receiver is enabled. Defaults to YES. See -setCropEnabled:recropImmediately:inBounds: for more information. //! @abstract Indicates whether efficient cropping of the receiver is enabled. Defaults to YES. See -setCropEnabled:recropImmediately:inBounds: for more information.
@property (nonatomic, assign) BOOL cropEnabled; @property (nonatomic, assign, getter=isCropEnabled) BOOL cropEnabled;
/** /**
@abstract Enables or disables efficient cropping. @abstract Enables or disables efficient cropping.

View File

@ -302,7 +302,7 @@
} }
#pragma mark - Cropping #pragma mark - Cropping
- (BOOL)cropEnabled - (BOOL)isCropEnabled
{ {
ASDisplayNodeAssertThreadAffinity(self); ASDisplayNodeAssertThreadAffinity(self);
return _cropEnabled; return _cropEnabled;

View File

@ -52,12 +52,12 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {
/** /**
@abstract If the text node is truncated. Text must have been sized first. @abstract If the text node is truncated. Text must have been sized first.
*/ */
@property (nonatomic, assign, readonly, getter = isTruncated) BOOL truncated; @property (nonatomic, readonly, assign, getter=isTruncated) BOOL truncated;
/** /**
@abstract The number of lines in the text. Text must have been sized first. @abstract The number of lines in the text. Text must have been sized first.
*/ */
@property (nonatomic, assign, readonly) NSUInteger lineCount; @property (nonatomic, readonly, assign) NSUInteger lineCount;
#pragma mark - Shadow #pragma mark - Shadow

View File

@ -37,16 +37,16 @@ static inline UIEdgeInsets ASDNEdgeInsetsInvert(UIEdgeInsets insets)
* @discussion A positive width will move the shadow to the right. * @discussion A positive width will move the shadow to the right.
* A positive height will move the shadow downwards. * A positive height will move the shadow downwards.
*/ */
@property (nonatomic, assign, readonly) CGSize shadowOffset; @property (nonatomic, readonly, assign) CGSize shadowOffset;
//! CGColor in which the shadow is drawn //! CGColor in which the shadow is drawn
@property (nonatomic, assign, readonly) CGColorRef shadowColor; @property (nonatomic, readonly, assign) CGColorRef shadowColor;
//! Alpha of the shadow //! Alpha of the shadow
@property (nonatomic, assign, readonly) CGFloat shadowOpacity; @property (nonatomic, readonly, assign) CGFloat shadowOpacity;
//! Radius, in pixels //! Radius, in pixels
@property (nonatomic, assign, readonly) CGFloat shadowRadius; @property (nonatomic, readonly, assign) CGFloat shadowRadius;
/** /**
* @abstract The edge insets which represent shadow padding * @abstract The edge insets which represent shadow padding

View File

@ -56,18 +56,18 @@ typedef NS_ENUM(NSUInteger, ASAsyncTransactionState) {
/** /**
The dispatch queue that the completion blocks will be called on. The dispatch queue that the completion blocks will be called on.
*/ */
@property (nonatomic, retain, readonly) dispatch_queue_t callbackQueue; @property (nonatomic, readonly, retain) dispatch_queue_t callbackQueue;
/** /**
A block that is called when the transaction is completed. A block that is called when the transaction is completed.
*/ */
@property (nonatomic, copy, readonly) asyncdisplaykit_async_transaction_completion_block_t completionBlock; @property (nonatomic, readonly, copy) asyncdisplaykit_async_transaction_completion_block_t completionBlock;
/** /**
The state of the transaction. The state of the transaction.
@see ASAsyncTransactionState @see ASAsyncTransactionState
*/ */
@property (nonatomic, readonly) ASAsyncTransactionState state; @property (nonatomic, readonly, assign) ASAsyncTransactionState state;
/** /**
@summary Adds a synchronous operation to the transaction. The execution block will be executed immediately. @summary Adds a synchronous operation to the transaction. The execution block will be executed immediately.

View File

@ -37,7 +37,7 @@ typedef NS_ENUM(NSUInteger, ASAsyncTransactionContainerState) {
/** /**
@summary The current state of the receiver; indicates if it is currently performing asynchronous operations or if all operations have finished/canceled. @summary The current state of the receiver; indicates if it is currently performing asynchronous operations or if all operations have finished/canceled.
*/ */
@property (nonatomic, assign, readonly) ASAsyncTransactionContainerState asyncdisplaykit_asyncTransactionContainerState; @property (nonatomic, readonly, assign) ASAsyncTransactionContainerState asyncdisplaykit_asyncTransactionContainerState;
/** /**
@summary Cancels all async transactions on the receiver. @summary Cancels all async transactions on the receiver.
@ -58,13 +58,13 @@ typedef NS_ENUM(NSUInteger, ASAsyncTransactionContainerState) {
did not already exist. This method will always return an open, uncommitted transaction. did not already exist. This method will always return an open, uncommitted transaction.
@desc asyncdisplaykit_isAsyncTransactionContainer does not need to be YES for this to return a transaction. @desc asyncdisplaykit_isAsyncTransactionContainer does not need to be YES for this to return a transaction.
*/ */
@property (nonatomic, retain, readonly) _ASAsyncTransaction *asyncdisplaykit_asyncTransaction; @property (nonatomic, readonly, retain) _ASAsyncTransaction *asyncdisplaykit_asyncTransaction;
/** /**
@summary Goes up the superlayer chain until it finds the first layer with asyncdisplaykit_isAsyncTransactionContainer=YES (including the receiver) and returns it. @summary Goes up the superlayer chain until it finds the first layer with asyncdisplaykit_isAsyncTransactionContainer=YES (including the receiver) and returns it.
Returns nil if no parent container is found. Returns nil if no parent container is found.
*/ */
@property (nonatomic, retain, readonly) CALayer *asyncdisplaykit_parentTransactionContainer; @property (nonatomic, readonly, retain) CALayer *asyncdisplaykit_parentTransactionContainer;
@end @end
@interface UIView (ASDisplayNodeAsyncTransactionContainer) <ASDisplayNodeAsyncTransactionContainer> @interface UIView (ASDisplayNodeAsyncTransactionContainer) <ASDisplayNodeAsyncTransactionContainer>

View File

@ -132,7 +132,7 @@ static dispatch_block_t modifyMethodByAddingPrologueBlockAndReturnCleanupBlock(C
DeclareNodeNamed(n); DeclareNodeNamed(n);
DeclareViewNamed(superview); DeclareViewNamed(superview);
n.isLayerBacked = isLayerBacked; n.layerBacked = isLayerBacked;
if (isLayerBacked) { if (isLayerBacked) {
[superview.layer addSublayer:n.layer]; [superview.layer addSublayer:n.layer];
@ -179,7 +179,7 @@ static dispatch_block_t modifyMethodByAddingPrologueBlockAndReturnCleanupBlock(C
DeclareNodeNamed(ab); DeclareNodeNamed(ab);
for (ASDisplayNode *n in @[parent, a, b, aa, ab]) { for (ASDisplayNode *n in @[parent, a, b, aa, ab]) {
n.isLayerBacked = isLayerBacked; n.layerBacked = isLayerBacked;
if (isViewLoaded) if (isViewLoaded)
[n layer]; [n layer];
} }
@ -273,7 +273,7 @@ static dispatch_block_t modifyMethodByAddingPrologueBlockAndReturnCleanupBlock(C
DeclareNodeNamed(layerBackedNode); DeclareNodeNamed(layerBackedNode);
DeclareNodeNamed(viewBackedNode); DeclareNodeNamed(viewBackedNode);
layerBackedNode.isLayerBacked = YES; layerBackedNode.layerBacked = YES;
UIWindow *window = [[UIWindow alloc] initWithFrame:CGRectZero]; UIWindow *window = [[UIWindow alloc] initWithFrame:CGRectZero];
[parentSynchronousNode addSubnode:layerBackedNode]; [parentSynchronousNode addSubnode:layerBackedNode];
@ -326,7 +326,7 @@ static dispatch_block_t modifyMethodByAddingPrologueBlockAndReturnCleanupBlock(C
DeclareNodeNamed(childSubnode); DeclareNodeNamed(childSubnode);
for (ASDisplayNode *n in @[parentA, parentB, child, childSubnode]) { for (ASDisplayNode *n in @[parentA, parentB, child, childSubnode]) {
n.isLayerBacked = isLayerBacked; n.layerBacked = isLayerBacked;
} }
[parentA addSubnode:child]; [parentA addSubnode:child];

View File

@ -183,7 +183,7 @@ for (ASDisplayNode *n in @[ nodes ]) {\
ASDisplayNode *node = [[ASDisplayNode alloc] init]; ASDisplayNode *node = [[ASDisplayNode alloc] init];
XCTAssertEqual(NO, node.isLayerBacked, @"default isLayerBacked broken without view"); XCTAssertEqual(NO, node.isLayerBacked, @"default isLayerBacked broken without view");
node.isLayerBacked = isLayerBacked; node.layerBacked = isLayerBacked;
XCTAssertEqual(isLayerBacked, node.isLayerBacked, @"setIsLayerBacked: broken"); XCTAssertEqual(isLayerBacked, node.isLayerBacked, @"setIsLayerBacked: broken");
// Assert that the values can be fetched from the node before the view is realized. // Assert that the values can be fetched from the node before the view is realized.
@ -274,7 +274,7 @@ for (ASDisplayNode *n in @[ nodes ]) {\
[self executeOffThread:^{ [self executeOffThread:^{
node = [[ASDisplayNode alloc] init]; node = [[ASDisplayNode alloc] init];
node.isLayerBacked = isLayerBacked; node.layerBacked = isLayerBacked;
node.contents = (id)[self bogusImage].CGImage; node.contents = (id)[self bogusImage].CGImage;
node.clipsToBounds = YES; node.clipsToBounds = YES;
@ -840,7 +840,7 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point
DeclareNodeNamed(c); DeclareNodeNamed(c);
for (ASDisplayNode *n in @[parent, a, b, c]) { for (ASDisplayNode *n in @[parent, a, b, c]) {
n.isLayerBacked = isLayerBacked; n.layerBacked = isLayerBacked;
} }
[parent addSubnode:a]; [parent addSubnode:a];
@ -1103,7 +1103,7 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point
DeclareNodeNamed(c); DeclareNodeNamed(c);
for (ASDisplayNode *v in @[parent, a, b, c]) { for (ASDisplayNode *v in @[parent, a, b, c]) {
v.isLayerBacked = isLayerBacked; v.layerBacked = isLayerBacked;
} }
// Load parent // Load parent
@ -1113,7 +1113,7 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point
// Add another subnode to test creation after parent is loaded // Add another subnode to test creation after parent is loaded
DeclareNodeNamed(d); DeclareNodeNamed(d);
d.isLayerBacked = isLayerBacked; d.layerBacked = isLayerBacked;
if (loaded) { if (loaded) {
XCTAssertFalse(d.isViewLoaded, @"Should not yet be loaded"); XCTAssertFalse(d.isViewLoaded, @"Should not yet be loaded");
} }
@ -1358,7 +1358,7 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point
DeclareNodeNamed(c); DeclareNodeNamed(c);
for (ASDisplayNode *v in @[parent, a, b, c]) { for (ASDisplayNode *v in @[parent, a, b, c]) {
v.isLayerBacked = isLayerBacked; v.layerBacked = isLayerBacked;
} }
[parent addSubnode:b]; [parent addSubnode:b];
@ -1438,7 +1438,7 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point
DeclareNodeNamed(c); DeclareNodeNamed(c);
for (ASDisplayNode *n in @[parent, a, b, c]) { for (ASDisplayNode *n in @[parent, a, b, c]) {
n.isLayerBacked = isLayerBacked; n.layerBacked = isLayerBacked;
} }
[parent addSubnode:a]; [parent addSubnode:a];
@ -1493,7 +1493,7 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point
- (void)checkBackgroundColorOpaqueRelationshipWithViewLoaded:(BOOL)loaded layerBacked:(BOOL)isLayerBacked - (void)checkBackgroundColorOpaqueRelationshipWithViewLoaded:(BOOL)loaded layerBacked:(BOOL)isLayerBacked
{ {
ASDisplayNode *node = [[ASDisplayNode alloc] init]; ASDisplayNode *node = [[ASDisplayNode alloc] init];
node.isLayerBacked = isLayerBacked; node.layerBacked = isLayerBacked;
if (loaded) { if (loaded) {
// Force load // Force load
@ -1577,9 +1577,9 @@ static bool stringContainsPointer(NSString *description, const void *p) {
ASDisplayNode *parent = [[ASDisplayNode alloc] init]; ASDisplayNode *parent = [[ASDisplayNode alloc] init];
ASDisplayNode *a = [[[ASDisplayNode alloc] init] autorelease]; ASDisplayNode *a = [[[ASDisplayNode alloc] init] autorelease];
a.isLayerBacked = YES; a.layerBacked = YES;
ASDisplayNode *b = [[[ASDisplayNode alloc] init] autorelease]; ASDisplayNode *b = [[[ASDisplayNode alloc] init] autorelease];
b.isLayerBacked = YES; b.layerBacked = YES;
b.frame = CGRectMake(0, 0, 100, 123); b.frame = CGRectMake(0, 0, 100, 123);
ASDisplayNode *c = [[[ASDisplayNode alloc] init] autorelease]; ASDisplayNode *c = [[[ASDisplayNode alloc] init] autorelease];
@ -1611,7 +1611,7 @@ static bool stringContainsPointer(NSString *description, const void *p) {
- (void)checkNameInDescriptionIsLayerBacked:(BOOL)isLayerBacked - (void)checkNameInDescriptionIsLayerBacked:(BOOL)isLayerBacked
{ {
ASDisplayNode *node = [[ASDisplayNode alloc] init]; ASDisplayNode *node = [[ASDisplayNode alloc] init];
node.isLayerBacked = isLayerBacked; node.layerBacked = isLayerBacked;
XCTAssertFalse([node.description rangeOfString:@"name"].location != NSNotFound, @"Shouldn't reference 'name' in description"); XCTAssertFalse([node.description rangeOfString:@"name"].location != NSNotFound, @"Shouldn't reference 'name' in description");
node.name = @"big troll eater name"; node.name = @"big troll eater name";