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 "CDOCMethod.h" |
| 7 |
| 8 #import "CDClassDump.h" |
| 9 #import "CDTypeFormatter.h" |
| 10 #import "CDTypeParser.h" |
| 11 #import "NSError-CDExtensions.h" |
| 12 #import "CDTypeController.h" |
| 13 |
| 14 @implementation CDOCMethod |
| 15 |
| 16 - (id)init; |
| 17 { |
| 18 [NSException raise:@"RejectUnusedImplementation" format:@"-initWithName:type
:imp: is the designated initializer"]; |
| 19 return nil; |
| 20 } |
| 21 |
| 22 - (id)initWithName:(NSString *)aName type:(NSString *)aType imp:(NSUInteger)anIm
p; |
| 23 { |
| 24 if ([self initWithName:aName type:aType] == nil) |
| 25 return nil; |
| 26 |
| 27 [self setImp:anImp]; |
| 28 |
| 29 return self; |
| 30 } |
| 31 |
| 32 - (id)initWithName:(NSString *)aName type:(NSString *)aType; |
| 33 { |
| 34 if ([super init] == nil) |
| 35 return nil; |
| 36 |
| 37 name = [aName retain]; |
| 38 type = [aType retain]; |
| 39 imp = 0; |
| 40 |
| 41 hasParsedType = NO; |
| 42 parsedMethodTypes = nil; |
| 43 |
| 44 return self; |
| 45 } |
| 46 |
| 47 - (void)dealloc; |
| 48 { |
| 49 [name release]; |
| 50 [type release]; |
| 51 |
| 52 [parsedMethodTypes release]; |
| 53 |
| 54 [super dealloc]; |
| 55 } |
| 56 |
| 57 - (NSString *)name; |
| 58 { |
| 59 return name; |
| 60 } |
| 61 |
| 62 - (NSString *)type; |
| 63 { |
| 64 return type; |
| 65 } |
| 66 |
| 67 - (NSUInteger)imp; |
| 68 { |
| 69 return imp; |
| 70 } |
| 71 |
| 72 - (void)setImp:(NSUInteger)newValue; |
| 73 { |
| 74 imp = newValue; |
| 75 } |
| 76 |
| 77 - (NSArray *)parsedMethodTypes; |
| 78 { |
| 79 if (hasParsedType == NO) { |
| 80 CDTypeParser *parser; |
| 81 NSError *error; |
| 82 |
| 83 parser = [[CDTypeParser alloc] initWithType:type]; |
| 84 parsedMethodTypes = [[parser parseMethodType:&error] retain]; |
| 85 if (parsedMethodTypes == nil) |
| 86 NSLog(@"Warning: Parsing method types failed, %@", name); |
| 87 [parser release]; |
| 88 hasParsedType = YES; |
| 89 } |
| 90 |
| 91 return parsedMethodTypes; |
| 92 } |
| 93 |
| 94 - (NSString *)description; |
| 95 { |
| 96 return [NSString stringWithFormat:@"[%@] name: %@, type: %@, imp: 0x%016lx", |
| 97 NSStringFromClass([self class]), name, type, imp]; |
| 98 } |
| 99 |
| 100 - (void)appendToString:(NSMutableString *)resultString typeController:(CDTypeCon
troller *)typeController symbolReferences:(CDSymbolReferences *)symbolReferences
; |
| 101 { |
| 102 NSString *formattedString; |
| 103 |
| 104 formattedString = [[typeController methodTypeFormatter] formatMethodName:nam
e type:type symbolReferences:symbolReferences]; |
| 105 if (formattedString != nil) { |
| 106 [resultString appendString:formattedString]; |
| 107 [resultString appendString:@";"]; |
| 108 if ([typeController shouldShowMethodAddresses] && imp != 0) { |
| 109 if ([typeController targetArchUses64BitABI]) |
| 110 [resultString appendFormat:@"\t// IMP=0x%016lx", imp]; |
| 111 else |
| 112 [resultString appendFormat:@"\t// IMP=0x%08lx", imp]; |
| 113 } |
| 114 } else |
| 115 [resultString appendFormat:@" // Error parsing type: %@, name: %@", t
ype, name]; |
| 116 } |
| 117 |
| 118 - (NSComparisonResult)ascendingCompareByName:(CDOCMethod *)otherMethod; |
| 119 { |
| 120 return [name compare:[otherMethod name]]; |
| 121 } |
| 122 |
| 123 - (id)copyWithZone:(NSZone *)zone; |
| 124 { |
| 125 return [[CDOCMethod alloc] initWithName:name type:type imp:imp]; |
| 126 } |
| 127 |
| 128 @end |
OLD | NEW |