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

Add support for non-lazy classes and categories #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions Source/CDOCProtocol.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ - (id)init;
return self;
}

- (BOOL)isEqual:(id)object;
{
return [object isKindOfClass:[CDOCProtocol class]] && [self.sortableName isEqualToString:((CDOCProtocol *)object).sortableName];
}

- (NSUInteger)hash;
{
return [self.sortableName hash];
}

#pragma mark - Debugging

- (NSString *)description;
Expand Down
32 changes: 18 additions & 14 deletions Source/CDObjectiveC2Processor.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,30 @@ - (void)loadProtocols;

- (void)loadClasses;
{
CDSection *section = [[self.machOFile segmentWithName:@"__DATA"] sectionWithName:@"__objc_classlist"];

CDMachOFileDataCursor *cursor = [[CDMachOFileDataCursor alloc] initWithSection:section];
while ([cursor isAtEnd] == NO) {
uint64_t val = [cursor readPtr];
CDOCClass *aClass = [self loadClassAtAddress:val];
if (aClass != nil) {
[self addClass:aClass withAddress:val];
for (NSString *sectionName in @[@"__objc_classlist", @"__objc_nlclslist"]) {
CDSection *section = [[self.machOFile segmentWithName:@"__DATA"] sectionWithName:sectionName];

CDMachOFileDataCursor *cursor = [[CDMachOFileDataCursor alloc] initWithSection:section];
while ([cursor isAtEnd] == NO) {
uint64_t val = [cursor readPtr];
CDOCClass *aClass = [self loadClassAtAddress:val];
if (aClass != nil) {
[self addClass:aClass withAddress:val];
}
}
}
}

- (void)loadCategories;
{
CDSection *section = [[self.machOFile segmentWithName:@"__DATA"] sectionWithName:@"__objc_catlist"];

CDMachOFileDataCursor *cursor = [[CDMachOFileDataCursor alloc] initWithSection:section];
while ([cursor isAtEnd] == NO) {
CDOCCategory *category = [self loadCategoryAtAddress:[cursor readPtr]];
[self addCategory:category];
for (NSString *sectionName in @[@"__objc_catlist", @"__objc_nlcatlist"]) {
CDSection *section = [[self.machOFile segmentWithName:@"__DATA"] sectionWithName:sectionName];

CDMachOFileDataCursor *cursor = [[CDMachOFileDataCursor alloc] initWithSection:section];
while ([cursor isAtEnd] == NO) {
CDOCCategory *category = [self loadCategoryAtAddress:[cursor readPtr]];
[self addCategory:category];
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions Source/CDObjectiveCProcessor.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ @implementation CDObjectiveCProcessor
{
CDMachOFile *_machOFile;

NSMutableArray *_classes;
NSMutableOrderedSet *_classes;
NSMutableDictionary *_classesByAddress;

NSMutableArray *_categories;
NSMutableOrderedSet *_categories;

CDProtocolUniquer *_protocolUniquer;
}
Expand All @@ -36,9 +36,9 @@ - (id)initWithMachOFile:(CDMachOFile *)machOFile;
{
if ((self = [super init])) {
_machOFile = machOFile;
_classes = [[NSMutableArray alloc] init];
_classes = [[NSMutableOrderedSet alloc] init];
_classesByAddress = [[NSMutableDictionary alloc] init];
_categories = [[NSMutableArray alloc] init];
_categories = [[NSMutableOrderedSet alloc] init];

_protocolUniquer = [[CDProtocolUniquer alloc] init];
}
Expand Down Expand Up @@ -177,8 +177,8 @@ - (void)registerTypesWithObject:(CDTypeController *)typeController phase:(NSUInt
- (void)recursivelyVisit:(CDVisitor *)visitor;
{
NSMutableArray *classesAndCategories = [[NSMutableArray alloc] init];
[classesAndCategories addObjectsFromArray:_classes];
[classesAndCategories addObjectsFromArray:_categories];
[classesAndCategories addObjectsFromArray:[_classes array]];
[classesAndCategories addObjectsFromArray:[_categories array]];

[visitor willVisitObjectiveCProcessor:self];
[visitor visitObjectiveCProcessor:self];
Expand Down