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 "CDOCClass.h" |
| 7 |
| 8 #import "NSArray-Extensions.h" |
| 9 #import "CDClassDump.h" |
| 10 #import "CDOCIvar.h" |
| 11 #import "CDOCMethod.h" |
| 12 #import "CDSymbolReferences.h" |
| 13 #import "CDType.h" |
| 14 #import "CDTypeController.h" |
| 15 #import "CDTypeParser.h" |
| 16 #import "CDVisitor.h" |
| 17 #import "CDVisitorPropertyState.h" |
| 18 |
| 19 @implementation CDOCClass |
| 20 |
| 21 - (id)init; |
| 22 { |
| 23 if ([super init] == nil) |
| 24 return nil; |
| 25 |
| 26 superClassName = nil; |
| 27 ivars = nil; |
| 28 |
| 29 isExported = YES; |
| 30 |
| 31 return self; |
| 32 } |
| 33 |
| 34 - (void)dealloc; |
| 35 { |
| 36 [superClassName release]; |
| 37 [ivars release]; |
| 38 |
| 39 [super dealloc]; |
| 40 } |
| 41 |
| 42 - (NSString *)superClassName; |
| 43 { |
| 44 return superClassName; |
| 45 } |
| 46 |
| 47 - (void)setSuperClassName:(NSString *)newSuperClassName; |
| 48 { |
| 49 if (newSuperClassName == superClassName) |
| 50 return; |
| 51 |
| 52 [superClassName release]; |
| 53 superClassName = [newSuperClassName retain]; |
| 54 } |
| 55 |
| 56 - (NSArray *)ivars; |
| 57 { |
| 58 return ivars; |
| 59 } |
| 60 |
| 61 - (void)setIvars:(NSArray *)newIvars; |
| 62 { |
| 63 if (newIvars == ivars) |
| 64 return; |
| 65 |
| 66 [ivars release]; |
| 67 ivars = [newIvars retain]; |
| 68 } |
| 69 |
| 70 @synthesize isExported; |
| 71 |
| 72 - (NSString *)description; |
| 73 { |
| 74 return [NSString stringWithFormat:@"%@, exported: %@", [super description],
isExported ? @"YES" : @"NO"]; |
| 75 } |
| 76 |
| 77 - (void)registerTypesWithObject:(CDTypeController *)typeController phase:(NSUInt
eger)phase; |
| 78 { |
| 79 [super registerTypesWithObject:typeController phase:phase]; |
| 80 |
| 81 for (CDOCIvar *ivar in ivars) { |
| 82 [[ivar parsedType] phase:phase registerTypesWithObject:typeController us
edInMethod:NO]; |
| 83 } |
| 84 } |
| 85 |
| 86 - (NSString *)findTag:(CDSymbolReferences *)symbolReferences; |
| 87 { |
| 88 NSMutableString *resultString = [NSMutableString string]; |
| 89 |
| 90 [resultString appendFormat:@"@interface %@", name]; |
| 91 if (superClassName != nil) |
| 92 [resultString appendFormat:@" : %@", superClassName]; |
| 93 |
| 94 if ([protocols count] > 0) |
| 95 [resultString appendFormat:@" <%@>", [[protocols arrayByMappingSelector:
@selector(name)] componentsJoinedByString:@", "]]; |
| 96 |
| 97 return resultString; |
| 98 } |
| 99 |
| 100 - (void)recursivelyVisit:(CDVisitor *)aVisitor; |
| 101 { |
| 102 CDVisitorPropertyState *propertyState; |
| 103 |
| 104 if ([[aVisitor classDump] shouldMatchRegex] && [[aVisitor classDump] regexMa
tchesString:[self name]] == NO) |
| 105 return; |
| 106 |
| 107 // Wonderful. Need to typecast because there's also -[NSHTTPCookie initWith
Properties:] that takes a dictionary. |
| 108 propertyState = [(CDVisitorPropertyState *)[CDVisitorPropertyState alloc] in
itWithProperties:[self properties]]; |
| 109 |
| 110 [aVisitor willVisitClass:self]; |
| 111 |
| 112 [aVisitor willVisitIvarsOfClass:self]; |
| 113 for (CDOCIvar *ivar in ivars) |
| 114 [aVisitor visitIvar:ivar]; |
| 115 [aVisitor didVisitIvarsOfClass:self]; |
| 116 |
| 117 //[aVisitor willVisitPropertiesOfClass:self]; |
| 118 //[self visitProperties:aVisitor]; |
| 119 //[aVisitor didVisitPropertiesOfClass:self]; |
| 120 |
| 121 [self visitMethods:aVisitor propertyState:propertyState]; |
| 122 // Should mostly be dynamic properties |
| 123 [aVisitor visitRemainingProperties:propertyState]; |
| 124 [aVisitor didVisitClass:self]; |
| 125 |
| 126 [propertyState release]; |
| 127 } |
| 128 |
| 129 // |
| 130 // CDTopologicalSort protocol |
| 131 // |
| 132 |
| 133 - (NSString *)identifier; |
| 134 { |
| 135 return [self name]; |
| 136 } |
| 137 |
| 138 - (NSArray *)dependancies; |
| 139 { |
| 140 if (superClassName == nil) |
| 141 return [NSArray array]; |
| 142 |
| 143 return [NSArray arrayWithObject:superClassName]; |
| 144 } |
| 145 |
| 146 @end |
OLD | NEW |