Skip to content

Commit

Permalink
Force template types that are used in methods to get typedef'd.
Browse files Browse the repository at this point in the history
This makes the output for  Finder on 10.6 a litter more readable.  For example, look
at @interface NSView (NodeDrag).
  • Loading branch information
nygard committed Sep 16, 2009
1 parent 2c416e0 commit 9830c8d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
47 changes: 47 additions & 0 deletions CDStructureTable.m
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,37 @@ - (void)appendTypedefsToString:(NSMutableString *)resultString
}
}
}

for (NSString *key in [[phase3_namedStructureInfo allKeys] sortedArrayUsingSelector:@selector(compare:)]) {
CDStructureInfo *info;
BOOL shouldShow;

info = [phase3_namedStructureInfo objectForKey:key];
shouldShow = [[info type] isTemplateType] && [info isUsedInMethod];
if (shouldShow || debugAnonStructures) {
NSString *formattedString;

if (hasAddedMark == NO) {
[resultString appendFormat:@"#pragma mark %@\n\n", markName];
hasAddedMark = YES;
}

if (hasShownExceptions == NO) {
[resultString appendString:@"// Template types\n"];
hasShownExceptions = YES;
}

if (debugAnonStructures) {
[resultString appendFormat:@"// %@\n", [[info type] reallyBareTypeString]];
[resultString appendFormat:@"// depth: %u, ref: %u, used in method? %u\n", [[info type] structureDepth], [info referenceCount], [info isUsedInMethod]];
}
formattedString = [aTypeFormatter formatVariable:nil parsedType:[info type] symbolReferences:symbolReferences];
if (formattedString != nil) {
//[resultString appendFormat:@"%@;\n\n", formattedString];
[resultString appendFormat:@"typedef %@ %@;\n\n", formattedString, [info typedefName]];
}
}
}
}

- (void)generateTypedefNames;
Expand All @@ -953,6 +984,12 @@ - (void)generateTypedefNames;
[info generateTypedefName:[NSString stringWithFormat:@"%@_", [[[info type] typeName] name]]];
[[[info type] typeName] setName:@"?"];
}

for (CDStructureInfo *info in [phase3_namedStructureInfo allValues]) {
if ([[info type] isTemplateType] && [info isUsedInMethod]) {
[info generateTypedefName:[NSString stringWithFormat:@"%@_", [[[info type] typeName] name]]];
}
}
}

- (void)generateMemberNames;
Expand All @@ -979,6 +1016,7 @@ - (BOOL)shouldExpandStructureInfo:(CDStructureInfo *)info;
{
return (info == nil)
|| ([info isUsedInMethod] == NO
&& ([[info type] isTemplateType] == NO || [info isUsedInMethod] == NO)
&& [info referenceCount] < 2
&& (([[info name] hasPrefix:@"_"] && [[info name] hasUnderscoreCapitalPrefix] == NO) // TODO: Don't need the first hasPrefix check now.
|| [@"?" isEqualToString:[info name]]));
Expand Down Expand Up @@ -1033,6 +1071,15 @@ - (NSString *)typedefNameForType:(CDType *)type;
#endif
}

if (info == nil) {
info = [phase3_namedStructureInfo objectForKey:[[type typeName] description]];
}
#if 0
if ([type isTemplateType] && [info typedefName] == nil) {
NSLog(@"Warning: no typedef name for type: %@", [type typeString]);
}
#endif

return [info typedefName];
}

Expand Down
1 change: 1 addition & 0 deletions CDType.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- (int)type;
- (BOOL)isIDType;
- (BOOL)isNamedObject;
- (BOOL)isTemplateType;

- (CDType *)subtype;
- (CDTypeName *)typeName;
Expand Down
5 changes: 5 additions & 0 deletions CDType.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ - (BOOL)isNamedObject;
return type == T_NAMED_OBJECT;
}

- (BOOL)isTemplateType;
{
return [typeName isTemplateType];
}

- (CDType *)subtype;
{
return subtype;
Expand Down

0 comments on commit 9830c8d

Please sign in to comment.