mirror of
https://github.com/darlinghq/class-dump.git
synced 2024-11-27 06:10:25 +00:00
Foundation looks pretty good with the structs. Whew!
This commit is contained in:
parent
eeba64f2c8
commit
73ac3fefad
@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CDClassDump.h,v 1.24 2004/01/07 21:26:47 nygard Exp $
|
||||
// $Id: CDClassDump.h,v 1.25 2004/01/08 00:43:08 nygard Exp $
|
||||
//
|
||||
|
||||
// This file is part of class-dump, a utility for examining the
|
||||
@ -9,7 +9,7 @@
|
||||
#import <Foundation/NSObject.h>
|
||||
#import "CDStructRegistrationProtocol.h"
|
||||
|
||||
@class NSMutableArray, NSMutableDictionary, NSMutableString, NSString;
|
||||
@class NSMutableArray, NSMutableDictionary, NSMutableSet, NSMutableString, NSString;
|
||||
@class CDDylibCommand, CDMachOFile;
|
||||
@class CDType, CDTypeFormatter;
|
||||
|
||||
@ -26,6 +26,8 @@
|
||||
NSMutableDictionary *anonymousStructsByType;
|
||||
NSMutableDictionary *replacementTypes;
|
||||
|
||||
NSMutableSet *forcedTypedefs;
|
||||
|
||||
int anonymousStructCounter;
|
||||
|
||||
CDTypeFormatter *ivarTypeFormatter;
|
||||
@ -63,8 +65,8 @@
|
||||
- (void)appendNamedStructsToString:(NSMutableString *)resultString;
|
||||
- (void)appendTypedefsToString:(NSMutableString *)resultString;
|
||||
|
||||
- (void)registerStruct:(CDType *)structType name:(NSString *)aName countReferences:(BOOL)shouldCountReferences;
|
||||
- (void)registerStruct:(CDType *)structType name:(NSString *)aName usedInMethod:(BOOL)isUsedInMethod countReferences:(BOOL)shouldCountReferences;
|
||||
- (CDType *)typeFormatter:(CDTypeFormatter *)aFormatter replacementForType:(CDType *)aType;
|
||||
- (NSString *)typeFormatter:(CDTypeFormatter *)aFormatter typedefNameForStruct:(NSString *)structTypeString;
|
||||
- (NSString *)typeFormatter:(CDTypeFormatter *)aFormatter typedefNameForStruct:(CDType *)structType level:(int)level;
|
||||
|
||||
@end
|
||||
|
114
CDClassDump.m
114
CDClassDump.m
@ -14,7 +14,7 @@
|
||||
#import "CDTypeFormatter.h"
|
||||
#import "CDTypeParser.h"
|
||||
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01/07 21:26:47 nygard Exp $");
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.36 2004/01/08 00:43:08 nygard Exp $");
|
||||
|
||||
@implementation CDClassDump2
|
||||
|
||||
@ -31,6 +31,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
anonymousStructNamesByType = [[NSMutableDictionary alloc] init];
|
||||
anonymousStructsByType = [[NSMutableDictionary alloc] init];
|
||||
replacementTypes = [[NSMutableDictionary alloc] init];
|
||||
forcedTypedefs = [[NSMutableSet alloc] init];
|
||||
|
||||
ivarTypeFormatter = [[CDTypeFormatter alloc] init];
|
||||
[ivarTypeFormatter setShouldExpand:NO];
|
||||
@ -48,6 +49,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
[structDeclarationTypeFormatter setShouldExpand:YES]; // But don't expand named struct members...
|
||||
[structDeclarationTypeFormatter setShouldAutoExpand:YES];
|
||||
[structDeclarationTypeFormatter setBaseLevel:0];
|
||||
[structDeclarationTypeFormatter setDelegate:self]; // But need to ignore some things?
|
||||
|
||||
NSLog(@"ivarTypeFormatter: %@", ivarTypeFormatter);
|
||||
NSLog(@"methodTypeFormatter: %@", methodTypeFormatter);
|
||||
@ -65,6 +67,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
[anonymousStructNamesByType release];
|
||||
[anonymousStructsByType release];
|
||||
[replacementTypes release];
|
||||
[forcedTypedefs release];
|
||||
[ivarTypeFormatter release];
|
||||
[methodTypeFormatter release];
|
||||
[structDeclarationTypeFormatter release];
|
||||
@ -136,10 +139,11 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
NSArray *keys;
|
||||
int count, index;
|
||||
NSString *key;
|
||||
NSMutableArray *bares = [NSMutableArray array];
|
||||
//NSMutableArray *bares = [NSMutableArray array];
|
||||
NSMutableSet *duplicateMappings = [NSMutableSet set];
|
||||
|
||||
NSLog(@"processIsomorphicStructs ----------------------------------------");
|
||||
//[self logAnonymousStructs];
|
||||
anonymousRemapping = [[NSMutableDictionary alloc] init];
|
||||
|
||||
keys = [[anonymousStructsByType allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
||||
@ -155,7 +159,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
//NSLog(@"%@ -> %@", key, bareTypeString);
|
||||
//NSLog(@"%@ <- %@", bareTypeString, key);
|
||||
#if 1
|
||||
if ([duplicateMappings containsObject:bareTypeString] == NO) {
|
||||
if ([duplicateMappings containsObject:bareTypeString] == NO && [anonymousStructsByType objectForKey:bareTypeString] != nil) {
|
||||
NSString *existingValue;
|
||||
|
||||
existingValue = [anonymousRemapping objectForKey:bareTypeString];
|
||||
@ -167,27 +171,12 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
}
|
||||
}
|
||||
#endif
|
||||
[bares addObject:bareTypeString];
|
||||
#if 0
|
||||
NSNumber *thisCount, *oldCount;
|
||||
|
||||
// add this count to bare count (if it already exists)
|
||||
thisCount = [anonymousStructCountsByType objectForKey:key];
|
||||
oldCount = [anonymousStructCountsByType objectForKey:bareTypeString];
|
||||
if (oldCount != nil) {
|
||||
NSNumber *newCount;
|
||||
|
||||
newCount = [NSNumber numberWithInt:[thisCount intValue] + [oldCount intValue]];
|
||||
[anonymousStructCountsByType setObject:newCount forKey:bareTypeString];
|
||||
[anonymousStructCountsByType setObject:newCount forKey:key]; // Need to update both of 'em
|
||||
[anonymousRemapping setObject:key forKey:bareTypeString];
|
||||
}
|
||||
#endif
|
||||
//[bares addObject:bareTypeString];
|
||||
}
|
||||
}
|
||||
|
||||
[bares sortUsingSelector:@selector(compare:)];
|
||||
NSLog(@"bares: %@", [bares description]);
|
||||
//[bares sortUsingSelector:@selector(compare:)];
|
||||
//NSLog(@"bares: %@", [bares description]);
|
||||
#endif
|
||||
|
||||
// Now we need to combine anything that gets remapped.
|
||||
@ -214,6 +203,8 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
}
|
||||
|
||||
[anonymousRemapping release];
|
||||
|
||||
NSLog(@"forcedTypedefs: %@", [forcedTypedefs description]);
|
||||
}
|
||||
|
||||
- (void)replaceTypeString:(NSString *)originalTypeString withTypeString:(NSString *)replacementTypeString;
|
||||
@ -227,7 +218,9 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
[replacementTypes setObject:replacementType forKey:originalTypeString];
|
||||
}
|
||||
|
||||
// First, let's just name all of them.
|
||||
// Need to name anonymous structs if:
|
||||
// - used more than once
|
||||
// - OR used in a method
|
||||
- (void)generateNamesForAnonymousStructs;
|
||||
{
|
||||
int nameIndex = 1;
|
||||
@ -239,7 +232,10 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
count = [keys count];
|
||||
for (index = 0; index < count; index++) {
|
||||
key = [keys objectAtIndex:index];
|
||||
[anonymousStructNamesByType setObject:[NSString stringWithFormat:@"CDAnonymousStruct%d", nameIndex++] forKey:key];
|
||||
if ([[anonymousStructCountsByType objectForKey:key] intValue] > 1
|
||||
|| [forcedTypedefs containsObject:key] == YES) {
|
||||
[anonymousStructNamesByType setObject:[NSString stringWithFormat:@"CDAnonymousStruct%d", nameIndex++] forKey:key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,7 +245,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
int count, index;
|
||||
NSString *key;
|
||||
|
||||
NSLog(@" > %s", _cmd);
|
||||
NSLog(@"%s ----------------------------------------", _cmd);
|
||||
keys = [[anonymousStructCountsByType allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
||||
count = [keys count];
|
||||
for (index = 0; index < count; index++) {
|
||||
@ -259,7 +255,6 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
|
||||
// If a structure doesn't have any named members, it should be typedef'd
|
||||
// Any structure in a return value or argument should be typedef'd
|
||||
NSLog(@"< %s", _cmd);
|
||||
}
|
||||
|
||||
- (void)logAnonymousRemappings;
|
||||
@ -268,7 +263,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
int count, index;
|
||||
NSString *key;
|
||||
|
||||
NSLog(@"replacement types ----------------------------------------------------------------------");
|
||||
NSLog(@"%s ----------------------------------------", _cmd);
|
||||
keys = [[replacementTypes allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
||||
count = [keys count];
|
||||
for (index = 0; index < count; index++) {
|
||||
@ -286,7 +281,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
NSString *key;
|
||||
int count, index;
|
||||
|
||||
NSLog(@"----------------------------------------------------------------------");
|
||||
NSLog(@"%s ----------------------------------------", _cmd);
|
||||
keys = [[structsByName allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
||||
count = [keys count];
|
||||
for (index = 0; index < count; index++) {
|
||||
@ -301,9 +296,10 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
NSString *key;
|
||||
int count, index;
|
||||
|
||||
NSLog(@"----------------------------------------------------------------------");
|
||||
NSLog(@"%s ----------------------------------------", _cmd);
|
||||
keys = [[anonymousStructNamesByType allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
||||
count = [keys count];
|
||||
NSLog(@"count: %d", count);
|
||||
for (index = 0; index < count; index++) {
|
||||
key = [keys objectAtIndex:index];
|
||||
NSLog(@"%2d: %@ => %@", index, [anonymousStructNamesByType objectForKey:key], key);
|
||||
@ -460,7 +456,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
}
|
||||
}
|
||||
|
||||
- (void)registerStruct:(CDType *)structType name:(NSString *)aName countReferences:(BOOL)shouldCountReferences;
|
||||
- (void)registerStruct:(CDType *)structType name:(NSString *)aName usedInMethod:(BOOL)isUsedInMethod countReferences:(BOOL)shouldCountReferences;
|
||||
{
|
||||
NSNumber *oldCount;
|
||||
NSString *typeString;
|
||||
@ -470,6 +466,8 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
|
||||
// First, register member structs
|
||||
//[structType registerMemberStructsWithObject:self];
|
||||
if (isUsedInMethod == YES)
|
||||
[forcedTypedefs addObject:[structType typeString]];
|
||||
|
||||
// Handle named structs
|
||||
if (aName != nil && [aName isEqual:@"?"] == NO) {
|
||||
@ -480,12 +478,13 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
|
||||
existingType = [structsByName objectForKey:aName];
|
||||
if (existingType == nil) {
|
||||
[structType registerMemberStructsWithObject:self countReferences:shouldCountReferences];
|
||||
//[structType registerMemberStructsWithObject:self usedInMethod:NO countReferences:shouldCountReferences];
|
||||
[structType registerMemberStructsWithObject:self usedInMethod:NO countReferences:YES];
|
||||
[structsByName setObject:structType forKey:aName];
|
||||
} else if ([structType isEqual:existingType] == NO) {
|
||||
NSString *before;
|
||||
|
||||
[structType registerMemberStructsWithObject:self countReferences:NO];
|
||||
[structType registerMemberStructsWithObject:self usedInMethod:NO countReferences:NO];
|
||||
before = [existingType typeString];
|
||||
[existingType mergeWithType:structType];
|
||||
if ([before isEqual:[existingType typeString]] == NO) {
|
||||
@ -503,38 +502,42 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
CDType *previousType;
|
||||
|
||||
//NSLog(@"%s, name: %@, typeString: %@", _cmd, aName, typeString);
|
||||
#if 0
|
||||
// Maybe we want to number them later, when we know which ones will be used.
|
||||
if ([anonymousStructNamesByType objectForKey:typeString] == nil) {
|
||||
[anonymousStructNamesByType setObject:[NSString stringWithFormat:@"CDAnonymousStruct%d", ++anonymousStructCounter] forKey:typeString];
|
||||
}
|
||||
#endif
|
||||
|
||||
previousType = [anonymousStructsByType objectForKey:typeString];
|
||||
if (previousType == nil)
|
||||
if (previousType == nil) {
|
||||
[anonymousStructsByType setObject:structType forKey:typeString];
|
||||
else {
|
||||
[structType registerMemberStructsWithObject:self usedInMethod:NO countReferences:YES];
|
||||
} else {
|
||||
NSLog(@"Already registered this anonymous struct, previous: %@, current: %@", [previousType typeString], typeString);
|
||||
}
|
||||
|
||||
// Just count anonymous structs
|
||||
oldCount = [anonymousStructCountsByType objectForKey:typeString];
|
||||
if (oldCount == nil)
|
||||
[anonymousStructCountsByType setObject:[NSNumber numberWithInt:1] forKey:typeString];
|
||||
else
|
||||
[anonymousStructCountsByType setObject:[NSNumber numberWithInt:[oldCount intValue] + 1] forKey:typeString];
|
||||
if (shouldCountReferences == YES) {
|
||||
oldCount = [anonymousStructCountsByType objectForKey:typeString];
|
||||
if (oldCount == nil)
|
||||
[anonymousStructCountsByType setObject:[NSNumber numberWithInt:1] forKey:typeString];
|
||||
else
|
||||
[anonymousStructCountsByType setObject:[NSNumber numberWithInt:[oldCount intValue] + 1] forKey:typeString];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (CDType *)typeFormatter:(CDTypeFormatter *)aFormatter replacementForType:(CDType *)aType;
|
||||
{
|
||||
NSLog(@" > %s", _cmd);
|
||||
NSLog(@"aFormatter: %@", aFormatter);
|
||||
NSLog(@"%@ -> %@", [aType typeString], [replacementTypes objectForKey:[aType typeString]]);
|
||||
NSLog(@"< %s", _cmd);
|
||||
return [replacementTypes objectForKey:[aType typeString]];
|
||||
}
|
||||
|
||||
- (NSString *)typeFormatter:(CDTypeFormatter *)aFormatter typedefNameForStruct:(NSString *)structTypeString;
|
||||
- (NSString *)typeFormatter:(CDTypeFormatter *)aFormatter typedefNameForStruct:(CDType *)structType level:(int)level;
|
||||
{
|
||||
NSLog(@" > %s", _cmd);
|
||||
NSLog(@"structTypeString: %@", structTypeString);
|
||||
NSString *structTypeString;
|
||||
CDType *replacementType;
|
||||
|
||||
NSLog(@" > %s", _cmd);
|
||||
#if 0
|
||||
return nil;
|
||||
// Count has been adjusted.
|
||||
|
||||
@ -546,7 +549,24 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDClassDump.m,v 1.35 2004/01
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// TODO (2004-01-07): This isn't quite right. We'll need to reference typedefs when defining structs.
|
||||
if (level == 0 && aFormatter == structDeclarationTypeFormatter) {
|
||||
NSLog(@"Returning nil.");
|
||||
NSLog(@"< %s", _cmd);
|
||||
return nil;
|
||||
}
|
||||
|
||||
// We need to catch top level replacements, not just replacements for struct members.
|
||||
replacementType = [self typeFormatter:aFormatter replacementForType:structType];
|
||||
if (replacementType != nil)
|
||||
structTypeString = [replacementType typeString];
|
||||
else
|
||||
structTypeString = [structType typeString];
|
||||
NSLog(@"structTypeString: %@", [structType typeString]);
|
||||
|
||||
NSLog(@"level: %d", level);
|
||||
NSLog(@"Returning: %@", [anonymousStructNamesByType objectForKey:structTypeString]);
|
||||
NSLog(@"< %s", _cmd);
|
||||
return [anonymousStructNamesByType objectForKey:structTypeString];
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CDMethodType.h,v 1.3 2004/01/06 02:31:41 nygard Exp $
|
||||
// $Id: CDMethodType.h,v 1.4 2004/01/08 00:43:08 nygard Exp $
|
||||
//
|
||||
|
||||
// This file is part of class-dump, a utility for examining the
|
||||
@ -8,6 +8,8 @@
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
#import "CDStructRegistrationProtocol.h"
|
||||
|
||||
@class NSMutableArray;
|
||||
@class CDType;
|
||||
|
||||
@ -25,4 +27,6 @@
|
||||
|
||||
- (NSString *)description;
|
||||
|
||||
- (void)registerStructsWithObject:(id <CDStructRegistration>)anObject;
|
||||
|
||||
@end
|
||||
|
@ -8,7 +8,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "CDType.h"
|
||||
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDMethodType.m,v 1.4 2004/01/06 02:31:41 nygard Exp $");
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDMethodType.m,v 1.5 2004/01/08 00:43:08 nygard Exp $");
|
||||
|
||||
@implementation CDMethodType
|
||||
|
||||
@ -46,4 +46,9 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDMethodType.m,v 1.4 2004/01
|
||||
return [NSString stringWithFormat:@"[%@] type: %@, offset: %@", NSStringFromClass([self class]), type, offset];
|
||||
}
|
||||
|
||||
- (void)registerStructsWithObject:(id <CDStructRegistration>)anObject;
|
||||
{
|
||||
[type registerStructsWithObject:anObject usedInMethod:YES countReferences:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -12,7 +12,7 @@
|
||||
#import "CDType.h"
|
||||
#import "CDTypeParser.h"
|
||||
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDOCClass.m,v 1.19 2004/01/07 21:26:47 nygard Exp $");
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDOCClass.m,v 1.20 2004/01/08 00:43:08 nygard Exp $");
|
||||
|
||||
@implementation CDOCClass
|
||||
|
||||
@ -119,7 +119,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDOCClass.m,v 1.19 2004/01/0
|
||||
NSLog(@"Registering struct for %@: %@", [self name], [structType typeString]);
|
||||
}
|
||||
#endif
|
||||
[structType registerStructsWithObject:anObject countReferences:YES];
|
||||
[structType registerStructsWithObject:anObject usedInMethod:NO countReferences:YES];
|
||||
[parser release];
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
#import "CDClassDump.h"
|
||||
#import "CDTypeFormatter.h"
|
||||
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDOCMethod.m,v 1.15 2004/01/06 02:31:42 nygard Exp $");
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDOCMethod.m,v 1.16 2004/01/08 00:43:08 nygard Exp $");
|
||||
|
||||
@implementation CDOCMethod
|
||||
|
||||
@ -61,7 +61,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDOCMethod.m,v 1.15 2004/01/
|
||||
{
|
||||
NSString *formattedString;
|
||||
|
||||
formattedString = [[aClassDump ivarTypeFormatter] formatMethodName:name type:type];
|
||||
formattedString = [[aClassDump methodTypeFormatter] formatMethodName:name type:type];
|
||||
//NSLog(@"%s, formattedString: '%@'", _cmd, formattedString);
|
||||
if (formattedString != nil) {
|
||||
[resultString appendString:formattedString];
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CDOCProtocol.h,v 1.10 2004/01/06 02:31:42 nygard Exp $
|
||||
// $Id: CDOCProtocol.h,v 1.11 2004/01/08 00:43:08 nygard Exp $
|
||||
//
|
||||
|
||||
// This file is part of class-dump, a utility for examining the
|
||||
@ -7,6 +7,7 @@
|
||||
// Copyright (C) 1997-1998, 2000-2001, 2004 Steve Nygard
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
#import "CDStructRegistrationProtocol.h"
|
||||
|
||||
@class NSArray, NSMutableArray, NSMutableSet, NSMutableString, NSString;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#import "CDOCSymtab.h"
|
||||
#import "CDTypeParser.h"
|
||||
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDOCProtocol.m,v 1.12 2004/01/06 02:31:42 nygard Exp $");
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDOCProtocol.m,v 1.13 2004/01/08 00:43:08 nygard Exp $");
|
||||
|
||||
@implementation CDOCProtocol
|
||||
|
||||
@ -156,7 +156,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDOCProtocol.m,v 1.12 2004/0
|
||||
for (index = 0; index < count; index++) {
|
||||
parser = [[CDTypeParser alloc] initWithType:[(CDOCMethod *)[classMethods objectAtIndex:index] type]];
|
||||
methodTypes = [parser parseMethodType];
|
||||
[[methodTypes arrayByMappingSelector:@selector(type)] makeObjectsPerformSelector:_cmd withObject:anObject];
|
||||
[methodTypes makeObjectsPerformSelector:_cmd withObject:anObject];
|
||||
[parser release];
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDOCProtocol.m,v 1.12 2004/0
|
||||
for (index = 0; index < count; index++) {
|
||||
parser = [[CDTypeParser alloc] initWithType:[(CDOCMethod *)[instanceMethods objectAtIndex:index] type]];
|
||||
methodTypes = [parser parseMethodType];
|
||||
[[methodTypes arrayByMappingSelector:@selector(type)] makeObjectsPerformSelector:_cmd withObject:anObject];
|
||||
[methodTypes makeObjectsPerformSelector:_cmd withObject:anObject];
|
||||
[parser release];
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CDStructRegistrationProtocol.h,v 1.6 2004/01/07 18:14:18 nygard Exp $
|
||||
// $Id: CDStructRegistrationProtocol.h,v 1.7 2004/01/08 00:43:08 nygard Exp $
|
||||
//
|
||||
|
||||
// This file is part of class-dump, a utility for examining the
|
||||
@ -10,5 +10,5 @@
|
||||
@class CDType;
|
||||
|
||||
@protocol CDStructRegistration
|
||||
- (void)registerStruct:(CDType *)structType name:(NSString *)aName countReferences:(BOOL)shouldCountReferences;
|
||||
- (void)registerStruct:(CDType *)structType name:(NSString *)aName usedInMethod:(BOOL)isUsedInMethod countReferences:(BOOL)shouldCountReferences;
|
||||
@end
|
||||
|
8
CDType.h
8
CDType.h
@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CDType.h,v 1.10 2004/01/07 18:14:18 nygard Exp $
|
||||
// $Id: CDType.h,v 1.11 2004/01/08 00:43:08 nygard Exp $
|
||||
//
|
||||
|
||||
// This file is part of class-dump, a utility for examining the
|
||||
@ -59,9 +59,9 @@
|
||||
- (NSString *)_typeStringWithVariableNames:(BOOL)shouldUseVariableNames;
|
||||
- (NSString *)_typeStringForMembersWithVariableNames:(BOOL)shouldUseVariableNames;
|
||||
|
||||
- (void)registerStructsWithObject:(id <CDStructRegistration>)anObject;
|
||||
- (void)registerStructsWithObject:(id <CDStructRegistration>)anObject countReferences:(BOOL)shouldCountReferences;
|
||||
- (void)registerMemberStructsWithObject:(id <CDStructRegistration>)anObject countReferences:(BOOL)shouldCountReferences;
|
||||
//- (void)registerStructsWithObject:(id <CDStructRegistration>)anObject usedInMethod:(BOOL)isUsedInMethod;
|
||||
- (void)registerStructsWithObject:(id <CDStructRegistration>)anObject usedInMethod:(BOOL)isUsedInMethod countReferences:(BOOL)shouldCountReferences;
|
||||
- (void)registerMemberStructsWithObject:(id <CDStructRegistration>)anObject usedInMethod:(BOOL)isUsedInMethod countReferences:(BOOL)shouldCountReferences;
|
||||
|
||||
- (BOOL)isEqual:(CDType *)otherType;
|
||||
- (BOOL)isStructureEqual:(CDType *)otherType;
|
||||
|
18
CDType.m
18
CDType.m
@ -10,7 +10,7 @@
|
||||
#import "CDTypeLexer.h" // For T_NAMED_OBJECT
|
||||
#import "CDTypeFormatter.h"
|
||||
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDType.m,v 1.17 2004/01/07 21:26:47 nygard Exp $");
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDType.m,v 1.18 2004/01/08 00:43:09 nygard Exp $");
|
||||
|
||||
@implementation CDType
|
||||
|
||||
@ -281,7 +281,7 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDType.m,v 1.17 2004/01/07 2
|
||||
NSString *typedefName;
|
||||
|
||||
NSLog(@"[%p], typeFormatter: %@", self, typeFormatter);
|
||||
typedefName = [typeFormatter typedefNameForStruct:[self typeString]];
|
||||
typedefName = [typeFormatter typedefNameForStruct:self level:level];
|
||||
if (typedefName != nil) {
|
||||
baseType = typedefName;
|
||||
}
|
||||
@ -504,35 +504,37 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDType.m,v 1.17 2004/01/07 2
|
||||
return str;
|
||||
}
|
||||
|
||||
#if 0
|
||||
- (void)registerStructsWithObject:(id <CDStructRegistration>)anObject;
|
||||
{
|
||||
[self registerStructsWithObject:anObject countReferences:YES];
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)registerStructsWithObject:(id <CDStructRegistration>)anObject countReferences:(BOOL)shouldCountReferences;
|
||||
- (void)registerStructsWithObject:(id <CDStructRegistration>)anObject usedInMethod:(BOOL)isUsedInMethod countReferences:(BOOL)shouldCountReferences;
|
||||
{
|
||||
if (subtype != nil)
|
||||
[subtype registerStructsWithObject:anObject countReferences:shouldCountReferences];
|
||||
[subtype registerStructsWithObject:anObject usedInMethod:isUsedInMethod countReferences:shouldCountReferences];
|
||||
|
||||
if (type == '{' && [members count] > 0) {
|
||||
NSString *typeString;
|
||||
|
||||
typeString = [self typeString];
|
||||
[anObject registerStruct:self name:typeName countReferences:shouldCountReferences];
|
||||
[anObject registerStruct:self name:typeName usedInMethod:isUsedInMethod countReferences:shouldCountReferences];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)registerMemberStructsWithObject:(id <CDStructRegistration>)anObject countReferences:(BOOL)shouldCountReferences;
|
||||
- (void)registerMemberStructsWithObject:(id <CDStructRegistration>)anObject usedInMethod:(BOOL)isUsedInMethod countReferences:(BOOL)shouldCountReferences;
|
||||
{
|
||||
int count, index;
|
||||
|
||||
if (subtype != nil)
|
||||
[subtype registerMemberStructsWithObject:anObject countReferences:shouldCountReferences];
|
||||
[subtype registerMemberStructsWithObject:anObject usedInMethod:isUsedInMethod countReferences:shouldCountReferences];
|
||||
|
||||
count = [members count];
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
[[members objectAtIndex:index] registerStructsWithObject:anObject countReferences:shouldCountReferences];
|
||||
[[members objectAtIndex:index] registerStructsWithObject:anObject usedInMethod:isUsedInMethod countReferences:shouldCountReferences];
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(CDType *)otherType;
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CDTypeFormatter.h,v 1.10 2004/01/07 21:26:47 nygard Exp $
|
||||
// $Id: CDTypeFormatter.h,v 1.11 2004/01/08 00:43:09 nygard Exp $
|
||||
//
|
||||
|
||||
// This file is part of class-dump, a utility for examining the
|
||||
@ -43,6 +43,6 @@
|
||||
- (NSString *)formatMethodName:(NSString *)methodName type:(NSString *)type;
|
||||
|
||||
- (CDType *)replacementForType:(CDType *)aType;
|
||||
- (NSString *)typedefNameForStruct:(NSString *)structTypeString;
|
||||
- (NSString *)typedefNameForStruct:(CDType *)structType level:(int)level;
|
||||
|
||||
@end
|
||||
|
@ -14,7 +14,7 @@
|
||||
#import "CDType.h"
|
||||
#import "CDTypeParser.h"
|
||||
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDTypeFormatter.m,v 1.18 2004/01/07 21:26:47 nygard Exp $");
|
||||
RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDTypeFormatter.m,v 1.19 2004/01/08 00:43:09 nygard Exp $");
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@ -215,6 +215,8 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDTypeFormatter.m,v 1.18 200
|
||||
|
||||
- (CDType *)replacementForType:(CDType *)aType;
|
||||
{
|
||||
//NSLog(@"[%p] %s, aType: %@", self, _cmd, [aType typeString]);
|
||||
//NSLog(@"[nonretainedDelegate respondsToSelector:@selector(typeFormatter:replacementForType:)]: %d", [nonretainedDelegate respondsToSelector:@selector(typeFormatter:replacementForType:)]);
|
||||
if ([nonretainedDelegate respondsToSelector:@selector(typeFormatter:replacementForType:)] == YES) {
|
||||
return [nonretainedDelegate typeFormatter:self replacementForType:aType];
|
||||
}
|
||||
@ -222,16 +224,11 @@ RCS_ID("$Header: /Volumes/Data/tmp/Tools/class-dump/CDTypeFormatter.m,v 1.18 200
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *)typedefNameForStruct:(NSString *)structTypeString;
|
||||
- (NSString *)typedefNameForStruct:(CDType *)structType level:(int)level;
|
||||
{
|
||||
#if 0
|
||||
if (self == [CDTypeFormatter sharedIvarTypeFormatter]) {
|
||||
NSLog(@"%s (ivar): structTypeString: %@", _cmd, structTypeString);
|
||||
}
|
||||
#endif
|
||||
NSLog(@"[%p] %s, delegate: %p", self, _cmd, nonretainedDelegate);
|
||||
if ([nonretainedDelegate respondsToSelector:@selector(typeFormatter:typedefNameForStruct:)] == YES) //TODO (2004-01-07): This is wrong, the semicolon!
|
||||
return [nonretainedDelegate typeFormatter:self typedefNameForStruct:structTypeString];
|
||||
if ([nonretainedDelegate respondsToSelector:@selector(typeFormatter:typedefNameForStruct:level:)] == YES)
|
||||
return [nonretainedDelegate typeFormatter:self typedefNameForStruct:structType level:level];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CDStructHandlingUnitTest.h,v 1.6 2004/01/07 18:14:19 nygard Exp $
|
||||
// $Id: CDStructHandlingUnitTest.h,v 1.7 2004/01/08 00:43:09 nygard Exp $
|
||||
//
|
||||
|
||||
// This file is part of class-dump, a utility for examining the
|
||||
@ -28,12 +28,15 @@
|
||||
- (void)testOne;
|
||||
- (void)testTwo;
|
||||
- (void)testThree;
|
||||
|
||||
#if 0
|
||||
- (void)testFour;
|
||||
- (void)testFive;
|
||||
- (void)testSix;
|
||||
- (void)testSeven;
|
||||
- (void)testEight;
|
||||
- (void)testNine;
|
||||
- (void)testTen;
|
||||
- (void)testEleven;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CDStructHandlingUnitTest.m,v 1.7 2004/01/07 21:26:47 nygard Exp $
|
||||
// $Id: CDStructHandlingUnitTest.m,v 1.8 2004/01/08 00:43:09 nygard Exp $
|
||||
//
|
||||
|
||||
// This file is part of class-dump, a utility for examining the
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
parser = [[CDTypeParser alloc] initWithType:aTypeString];
|
||||
type = [parser parseType];
|
||||
[type registerStructsWithObject:classDump];
|
||||
[type registerStructsWithObject:classDump usedInMethod:NO countReferences:YES];
|
||||
[parser release];
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
[self assert:resultString equals:expectedOutputContents];
|
||||
[self assert:resultString equals:expectedOutputContents message:testFilename];
|
||||
}
|
||||
|
||||
- (void)testOne;
|
||||
@ -204,4 +204,14 @@
|
||||
[self testFilename:@"shud06"];
|
||||
}
|
||||
|
||||
- (void)testTen;
|
||||
{
|
||||
[self testFilename:@"shud07"];
|
||||
}
|
||||
|
||||
- (void)testEleven;
|
||||
{
|
||||
[self testFilename:@"shud08"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
2
UnitTests/shud07-in.txt
Normal file
2
UnitTests/shud07-in.txt
Normal file
@ -0,0 +1,2 @@
|
||||
{one="field1"i"field2"c"field3"{?="x"f"y"f}}
|
||||
{one="field1"i"field2"c"field3"{?="x"f"y"f}}
|
12
UnitTests/shud07-out.txt
Normal file
12
UnitTests/shud07-out.txt
Normal file
@ -0,0 +1,12 @@
|
||||
// Named struct/union types
|
||||
struct one {
|
||||
int field1;
|
||||
char field2;
|
||||
struct {
|
||||
float x;
|
||||
float y;
|
||||
} field3;
|
||||
};
|
||||
|
||||
struct one var;
|
||||
struct one var;
|
3
UnitTests/shud08-in.txt
Normal file
3
UnitTests/shud08-in.txt
Normal file
@ -0,0 +1,3 @@
|
||||
{one="field1"i"field2"c"field3"{?="x"f"y"f}}
|
||||
{one="field1"i"field2"c"field3"{?="x"f"y"f}}
|
||||
{?="x"f"y"f}
|
16
UnitTests/shud08-out.txt
Normal file
16
UnitTests/shud08-out.txt
Normal file
@ -0,0 +1,16 @@
|
||||
// Named struct/union types
|
||||
struct one {
|
||||
int field1;
|
||||
char field2;
|
||||
CDAnonymousStruct1 field3;
|
||||
};
|
||||
|
||||
// Anonymous struct/union types
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
} CDAnonymousStruct1;
|
||||
|
||||
struct one var;
|
||||
struct one var;
|
||||
CDAnonymousStruct1 var;
|
Loading…
Reference in New Issue
Block a user