OLD | NEW |
(Empty) | |
| 1 // -*- mode: ObjC -*- |
| 2 |
| 3 // This file is part of class-dump, a utility for examining the Objective-C seg
ment of Mach-O files. |
| 4 // Copyright (C) 1997-1998, 2000-2001, 2004-2010 Steve Nygard. |
| 5 |
| 6 #import "CDClassFrameworkVisitor.h" |
| 7 |
| 8 #import "CDOCClass.h" |
| 9 #import "CDObjectiveCProcessor.h" |
| 10 #import "CDMachOFile.h" |
| 11 |
| 12 // This builds up a dictionary mapping class names to a framework name. It is u
sed to generate individual imports when creating separate header files. |
| 13 |
| 14 @implementation CDClassFrameworkVisitor |
| 15 |
| 16 - (id)init; |
| 17 { |
| 18 if ([super init] == nil) |
| 19 return nil; |
| 20 |
| 21 frameworkNamesByClassName = [[NSMutableDictionary alloc] init]; |
| 22 frameworkNamesByProtocolName = [[NSMutableDictionary alloc] init]; |
| 23 frameworkName = nil; |
| 24 |
| 25 return self; |
| 26 } |
| 27 |
| 28 - (void)dealloc; |
| 29 { |
| 30 [frameworkNamesByClassName release]; |
| 31 [frameworkNamesByProtocolName release]; |
| 32 [frameworkName release]; |
| 33 |
| 34 [super dealloc]; |
| 35 } |
| 36 |
| 37 - (NSDictionary *)frameworkNamesByClassName; |
| 38 { |
| 39 return frameworkNamesByClassName; |
| 40 } |
| 41 |
| 42 - (NSDictionary *)frameworkNamesByProtocolName; |
| 43 { |
| 44 return frameworkNamesByProtocolName; |
| 45 } |
| 46 |
| 47 - (NSString *)frameworkName; |
| 48 { |
| 49 return frameworkName; |
| 50 } |
| 51 |
| 52 - (void)setFrameworkName:(NSString *)newFrameworkName; |
| 53 { |
| 54 if (newFrameworkName == frameworkName) |
| 55 return; |
| 56 |
| 57 [frameworkName release]; |
| 58 frameworkName = [newFrameworkName retain]; |
| 59 } |
| 60 |
| 61 - (void)willVisitObjectiveCProcessor:(CDObjectiveCProcessor *)anObjCSegment; |
| 62 { |
| 63 [self setFrameworkName:[[anObjCSegment machOFile] importBaseName]]; |
| 64 } |
| 65 |
| 66 - (void)willVisitClass:(CDOCClass *)aClass; |
| 67 { |
| 68 if (frameworkName != nil) { |
| 69 [frameworkNamesByClassName setObject:frameworkName forKey:[aClass name]]
; |
| 70 } |
| 71 } |
| 72 |
| 73 - (void)willVisitProtocol:(CDOCProtocol *)aProtocol; |
| 74 { |
| 75 if (frameworkName != nil) { |
| 76 [frameworkNamesByProtocolName setObject:frameworkName forKey:[aProtocol
name]]; |
| 77 } |
| 78 } |
| 79 |
| 80 @end |
OLD | NEW |