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

Improve subclassing support #3

Merged
merged 6 commits into from
Nov 2, 2013
Merged

Improve subclassing support #3

merged 6 commits into from
Nov 2, 2013

Conversation

0xc010d
Copy link
Contributor

@0xc010d 0xc010d commented Oct 30, 2013

This patch resolves some common cases which you could get with subclassing. The most difficult case is:

Class A (lazy base class):

@interface A : NSObject <BMLazy>
@property (strong) NSString *a;
@end

@implementation A
@dynamic a;
@end

Class B (non-lazy subclass):

@interface B : A
@property (strong) NSString *b;
@end

@implementation B
@dynamic b;
@end

Class C (lazy subclass with lazy super-super):

@interface C : B <BMLazy>
@property (strong) NSString *c;
@end

@implementation
@dynamic c;
@end

In that case, collected lazy properties for C are a and c.

AlexDenisov and others added 6 commits October 30, 2013 02:01
…were added to the subclass.

Lazy superclass's properties were not taken into account when subclass was adding lazy properties.
This commit fixes BMPropertyCollector by recursive adding lazy properties from superclasses to the target subclass.

Note: the fix doesn't take into account <BMLazy> protocol because it's not possible to get 'lazy' protocol name by design.
This might bring a problem when properties are taken from non-lazy classes (theoretically :) ).
Lazy properties collecting was improved for better subclassing support.
First, total amount of examined classes was reduced by checking if superclass confirms to BMLasy protocol.
If not - we're not interested in its (and its superclasses) dynamic properties.
Secondly, we don't collect dynamic properties for 'intermediate' classes (those between 'lazy' classes in hierarchy).
@@ -8,28 +8,39 @@
#import "BMPropertyCollector.h"
#import "BMProperty.h"
#import "BMPrivateCoreDefinitions.h"
#import "BMClass.h"

@protocol BMLazy;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core should knew nothing about concrete protocols.

@AlexDenisov
Copy link
Contributor

@0xc010d, here is my vision about how it should be, but currently it's very inefficient.
#4

P.S. we should determine coding style 😸

@AlexDenisov AlexDenisov merged commit b4fb008 into railsware:master Nov 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants