Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1137)

Side by Side Diff: class-dump/src/CDSymbolReferences.m

Issue 7793008: Add the 3.3.3 sources for class-dump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « class-dump/src/CDSymbolReferences.h ('k') | class-dump/src/CDTextClassDumpVisitor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 "CDSymbolReferences.h"
7
8 @implementation CDSymbolReferences
9
10 - (id)init;
11 {
12 if ([super init] == nil)
13 return nil;
14
15 frameworkNamesByClassName = nil;
16 frameworkNamesByProtocolName = nil;
17
18 classes = [[NSMutableSet alloc] init];
19 protocols = [[NSMutableSet alloc] init];
20
21 return self;
22 }
23
24 - (void)dealloc;
25 {
26 [frameworkNamesByClassName release];
27 [frameworkNamesByProtocolName release];
28
29 [classes release];
30 [protocols release];
31
32 [super dealloc];
33 }
34
35 - (void)setFrameworkNamesByClassName:(NSDictionary *)newValue;
36 {
37 if (newValue == frameworkNamesByClassName)
38 return;
39
40 [frameworkNamesByClassName release];
41 frameworkNamesByClassName = [newValue retain];
42 }
43
44 - (void)setFrameworkNamesByProtocolName:(NSDictionary *)newValue;
45 {
46 if (newValue == frameworkNamesByProtocolName)
47 return;
48
49 [frameworkNamesByProtocolName release];
50 frameworkNamesByProtocolName = [newValue retain];
51 }
52
53 - (NSString *)frameworkForClassName:(NSString *)aClassName;
54 {
55 return [frameworkNamesByClassName objectForKey:aClassName];
56 }
57
58 - (NSString *)frameworkForProtocolName:(NSString *)aProtocolName;
59 {
60 return [frameworkNamesByProtocolName objectForKey:aProtocolName];
61 }
62
63 - (NSArray *)classes;
64 {
65 return [[classes allObjects] sortedArrayUsingSelector:@selector(compare:)];
66 }
67
68 - (void)addClassName:(NSString *)aClassName;
69 {
70 [classes addObject:aClassName];
71 }
72
73 - (void)removeClassName:(NSString *)aClassName;
74 {
75 if (aClassName != nil)
76 [classes removeObject:aClassName];
77 }
78
79 - (NSArray *)protocols;
80 {
81 return [[protocols allObjects] sortedArrayUsingSelector:@selector(compare:)] ;
82 }
83
84 - (void)addProtocolName:(NSString *)aProtocolName;
85 {
86 [protocols addObject:aProtocolName];
87 }
88
89 - (void)addProtocolNamesFromArray:(NSArray *)protocolNames;
90 {
91 [protocols addObjectsFromArray:protocolNames];
92 }
93
94 - (NSString *)description;
95 {
96 return [NSString stringWithFormat:@"<%@:%p> frameworkNamesByClassName: %@, f rameworkNamesByProtocolName: %@, classes: %@, protocols: %@",
97 NSStringFromClass([self class]), self,
98 frameworkNamesByClassName, frameworkNamesByProtocolName,
99 [self classes], [self protocols]];
100 }
101
102 - (void)_appendToString:(NSMutableString *)resultString;
103 {
104 NSArray *names;
105
106 names = [self protocols];
107 for (NSString *name in names) {
108 NSString *str;
109
110 str = [self importStringForProtocolName:name];
111 if (str != nil)
112 [resultString appendString:str];
113 }
114 if ([names count] > 0)
115 [resultString appendString:@"\n"];
116
117 names = [self classes];
118 if ([names count] > 0) {
119 [resultString appendFormat:@"@class %@;\n\n", [names componentsJoinedByS tring:@", "]];
120 }
121 }
122
123 - (NSString *)referenceString;
124 {
125 NSMutableString *referenceString;
126
127 referenceString = [[[NSMutableString alloc] init] autorelease];
128 [self _appendToString:referenceString];
129
130 if ([referenceString length] == 0)
131 return nil;
132
133 return referenceString;
134 }
135
136 - (void)removeAllReferences;
137 {
138 [classes removeAllObjects];
139 [protocols removeAllObjects];
140 }
141
142 - (NSString *)importStringForClassName:(NSString *)aClassName;
143 {
144 if (aClassName != nil) {
145 NSString *framework;
146
147 framework = [self frameworkForClassName:aClassName];
148 if (framework == nil)
149 return [NSString stringWithFormat:@"#import \"%@.h\"\n", aClassName] ;
150 else
151 return [NSString stringWithFormat:@"#import <%@/%@.h>\n", framework, aClassName];
152 }
153
154 return nil;
155 }
156
157 - (NSString *)importStringForProtocolName:(NSString *)aProtocolName;
158 {
159 if (aProtocolName != nil) {
160 NSString *framework;
161
162 framework = [self frameworkForClassName:aProtocolName];
163 if (framework == nil)
164 return [NSString stringWithFormat:@"#import \"%@-Protocol.h\"\n", aP rotocolName];
165 else
166 return [NSString stringWithFormat:@"#import <%@/%@-Protocol.h>\n", f ramework, aProtocolName];
167 }
168
169 return nil;
170 }
171
172 @end
OLDNEW
« no previous file with comments | « class-dump/src/CDSymbolReferences.h ('k') | class-dump/src/CDTextClassDumpVisitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698