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

Side by Side Diff: class-dump/src/CDStructureInfo.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/CDStructureInfo.h ('k') | class-dump/src/CDStructureTable.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 "CDStructureInfo.h"
7
8 #import "NSError-CDExtensions.h"
9 #import "NSString-Extensions.h"
10 #import "CDType.h"
11
12 // If it's used in a method, then it should be declared at the top. (name or typ edef)
13
14 @implementation CDStructureInfo
15
16 - (id)initWithType:(CDType *)aType;
17 {
18 if ([super init] == nil)
19 return nil;
20
21 type = [aType copy];
22 referenceCount = 1;
23 isUsedInMethod = NO;
24 typedefName = nil;
25
26 return self;
27 }
28
29 - (void)dealloc;
30 {
31 [type release];
32
33 [super dealloc];
34 }
35
36 - (CDType *)type;
37 {
38 return type;
39 }
40
41 - (NSUInteger)referenceCount;
42 {
43 return referenceCount;
44 }
45
46 - (void)setReferenceCount:(NSUInteger)newCount;
47 {
48 referenceCount = newCount;
49 }
50
51 - (void)addReferenceCount:(NSUInteger)count;
52 {
53 referenceCount += count;
54 }
55
56 - (BOOL)isUsedInMethod;
57 {
58 return isUsedInMethod;
59 }
60
61 - (void)setIsUsedInMethod:(BOOL)newFlag;
62 {
63 isUsedInMethod = newFlag;
64 }
65
66 - (NSString *)typedefName;
67 {
68 return typedefName;
69 }
70
71 - (void)setTypedefName:(NSString *)newName;
72 {
73 if (newName == typedefName)
74 return;
75
76 [typedefName release];
77 typedefName = [newName retain];
78 }
79
80 // Do this before generating member names.
81 - (void)generateTypedefName:(NSString *)baseName;
82 {
83 NSString *digest;
84 NSUInteger length;
85
86 digest = [[type typeString] SHA1DigestString];
87 length = [digest length];
88 if (length > 8)
89 digest = [digest substringFromIndex:length - 8];
90
91 [self setTypedefName:[NSString stringWithFormat:@"%@%@", baseName, digest]];
92 //NSLog(@"typedefName: %@", typedefName);
93 }
94
95 - (NSString *)name;
96 {
97 return [[type typeName] description];
98 }
99
100 - (NSString *)description;
101 {
102 return [NSString stringWithFormat:@"<%@:%p> depth: %u, refcount: %u, isUsedI nMethod: %u, type: %p",
103 NSStringFromClass([self class]), self,
104 [type structureDepth], referenceCount, isUsedInMethod, type ];
105 }
106
107 - (NSString *)shortDescription;
108 {
109 return [NSString stringWithFormat:@"%u %u m?%u %@ %@", [type structureDepth] , referenceCount, isUsedInMethod, [type bareTypeString], [type typeString]];
110 }
111
112 // Structure depth, reallyBareTypeString, typeString
113 - (NSComparisonResult)ascendingCompareByStructureDepth:(CDStructureInfo *)otherI nfo;
114 {
115 NSUInteger thisDepth, otherDepth;
116 NSString *str1, *str2;
117 NSComparisonResult result;
118
119 thisDepth = [type structureDepth];
120 otherDepth = [[otherInfo type] structureDepth];
121
122 if (thisDepth < otherDepth)
123 return NSOrderedAscending;
124 else if (thisDepth > otherDepth)
125 return NSOrderedDescending;
126
127 str1 = [type reallyBareTypeString];
128 str2 = [[otherInfo type] reallyBareTypeString];
129 result = [str1 compare:str2];
130 if (result == NSOrderedSame) {
131 str1 = [type typeString];
132 str2 = [[otherInfo type] typeString];
133 result = [str1 compare:str2];
134 }
135
136 return result;
137 }
138
139 - (NSComparisonResult)descendingCompareByStructureDepth:(CDStructureInfo *)other Info;
140 {
141 NSUInteger thisDepth, otherDepth;
142 NSString *str1, *str2;
143 NSComparisonResult result;
144
145 thisDepth = [type structureDepth];
146 otherDepth = [[otherInfo type] structureDepth];
147
148 if (thisDepth < otherDepth)
149 return NSOrderedDescending;
150 else if (thisDepth > otherDepth)
151 return NSOrderedAscending;
152
153 str1 = [type reallyBareTypeString];
154 str2 = [[otherInfo type] reallyBareTypeString];
155 result = -[str1 compare:str2];
156 if (result == NSOrderedSame) {
157 str1 = [type typeString];
158 str2 = [[otherInfo type] typeString];
159 result = -[str1 compare:str2];
160 }
161
162 return result;
163 }
164
165 - (id)copyWithZone:(NSZone *)zone;
166 {
167 CDStructureInfo *copy;
168
169 copy = [[CDStructureInfo alloc] initWithType:type]; // type gets copied
170 [copy setReferenceCount:referenceCount];
171 [copy setIsUsedInMethod:isUsedInMethod];
172 [copy setTypedefName:typedefName];
173
174 return copy;
175 }
176
177 @end
OLDNEW
« no previous file with comments | « class-dump/src/CDStructureInfo.h ('k') | class-dump/src/CDStructureTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698