Testing and tweaking type formatting.

Working on the Safari special case of a lone ^ in a structure.  Cleaning up output of the formatType tool.  Added three test case
files for the problematic type.
This commit is contained in:
Steve Nygard 2009-07-09 07:19:19 +00:00
parent d54a547abd
commit cb7db5adfe
6 changed files with 99 additions and 67 deletions

View File

@ -236,10 +236,8 @@ static NSString *CDTokenDescription(int token)
[self match:'^'];
if (lookahead == TK_QUOTED_STRING) {
NSLog(@"Safari special case.");
type = [[CDType alloc] initSimpleType:'v'];
// Safari on 10.5 has: "m_function"{?="__pfn"^"__delta"i}
// Possibly a poitner to a function?
result = [[CDType alloc] initPointerType:type];
[type release];
} else {

16
UnitTests/ivar-001.txt Normal file
View File

@ -0,0 +1,16 @@
// Test a pointer to no type in a structure.
// This is an excerpt from the _topSitesViewController ivar of BrowserWebView in Safari 4.0 on Mac OS X 10.5.
var1
{?="__pfn"^"__delta"i}
// Similar to the case above, but what happens if it occurs as the last member of the structure?
var2
{?="__pfn"^}
// Combination of the first two cases. Order reversed from first case.
var3
{?="__delta"i"__pfn"^}

4
UnitTests/ivar-002.txt Normal file
View File

@ -0,0 +1,4 @@
// This is an excerpt from the _topSitesViewController ivar of BrowserWebView in Safari 4.0 on Mac OS X 10.5.
var1
{STimer<Safari::TopSitesViewController>="_vptr$STimerBase"^^?"m_ID"I"m_isRepeating"B"m_object"^{TopSitesViewController}"m_function"{?="__pfn"^"__delta"i}}

4
UnitTests/ivar-003.txt Normal file
View File

@ -0,0 +1,4 @@
// This is the full definition of the _topSitesViewController ivar of BrowserWebView in Safari 4.0 on Mac OS X 10.5.
_topSitesViewController
^{TopSitesViewController=^^?@"BrowserWebView"i^{TopSitesViewLayer}BII{SNotifier<Safari::TopSitesViewController>="_vptr$SNotificationObserver"^^?"m_notifiedObject"^{TopSitesViewController}"m_notifications"{HashMap<std::pair<Safari::SString, const void*>,std::mem_fun1_t<void, Safari::TopSitesViewController, const Safari::SNotification&>,WTF::PairHash<Safari::SString, const void*>,WTF::HashTraits<std::pair<Safari::SString, const void*> >,WTF::HashTraits<std::mem_fun1_t<void, Safari::TopSitesViewController, const Safari::SNotification&> > >="m_impl"{HashTable<std::pair<Safari::SString, const void*>,std::pair<std::pair<Safari::SString, const void*>, std::mem_fun1_t<void, Safari::TopSitesViewController, const Safari::SNotification&> >,WTF::PairFirstExtractor<std::pair<std::pair<Safari::SString, const void*>, std::mem_fun1_t<void, Safari::TopSitesViewController, const Safari::SNotification&> > >,WTF::PairHash<Safari::SString, const void*>,WTF::PairHashTraits<WTF::HashTraits<std::pair<Safari::SString, const void*> >, WTF::HashTraits<std::mem_fun1_t<void, Safari::TopSitesViewController, const Safari::SNotification&> > >,WTF::HashTraits<std::pair<Safari::SString, const void*> > >="m_table"^{pair<std::pair<Safari::SString, const void*>,std::mem_fun1_t<void, Safari::TopSitesViewController, const Safari::SNotification&> >}"m_tableSize"i"m_tableSizeMask"i"m_keyCount"i"m_deletedCount"i}}}{STimer<Safari::TopSitesViewController>="_vptr$STimerBase"^^?"m_ID"I"m_isRepeating"B"m_object"^{TopSitesViewController}"m_function"{?="__pfn"^"__delta"i}}BBB{STimer<Safari::TopSitesViewController>="_vptr$STimerBase"^^?"m_ID"I"m_isRepeating"B"m_object"^{TopSitesViewController}"m_function"{?="__pfn"^"__delta"i}}{RefPtr<Safari::TopSite>="m_ptr"^{TopSite}}BB{STimer<Safari::TopSitesViewController>="_vptr$STimerBase"^^?"m_ID"I"m_isRepeating"B"m_object"^{TopSitesViewController}"m_function"{?="__pfn"^"__delta"i}}d{SString="m_cfObject"{RetainPtr<const __CFString*>="m_ptr"^{__CFString}}}BII{RetainPtr<CGImage*>="m_ptr"^{CGImage}}}

View File

@ -321,14 +321,14 @@
isa = PBXContainerItemProxy;
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 01F5238E1001D19A0006B272 /* format-type */;
remoteGlobalIDString = 01F5238E1001D19A0006B272;
remoteInfo = "format-type";
};
01F525051001F3EC0006B272 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 01F524FF1001F3E60006B272 /* deprotect */;
remoteGlobalIDString = 01F524FF1001F3E60006B272;
remoteInfo = deprotect;
};
/* End PBXContainerItemProxy section */
@ -1340,14 +1340,14 @@
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
010C4CD91001930200B27A2B /* Debug-32 */ = {
010C4CD91001930200B27A2B /* 32-Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
};
name = "Debug-32";
name = "32-Debug";
};
010C4CDA1001930200B27A2B /* Debug-32 */ = {
010C4CDA1001930200B27A2B /* 32-Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
@ -1355,9 +1355,9 @@
GCC_OPTIMIZATION_LEVEL = 0;
PRODUCT_NAME = all;
};
name = "Debug-32";
name = "32-Debug";
};
010C4CDB1001930200B27A2B /* Debug-32 */ = {
010C4CDB1001930200B27A2B /* 32-Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
@ -1374,9 +1374,9 @@
PREBINDING = NO;
PRODUCT_NAME = "class-dump";
};
name = "Debug-32";
name = "32-Debug";
};
010C4CDC1001930200B27A2B /* Debug-32 */ = {
010C4CDC1001930200B27A2B /* 32-Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
@ -1401,9 +1401,9 @@
PRODUCT_NAME = CDUnitTests;
WRAPPER_EXTENSION = octest;
};
name = "Debug-32";
name = "32-Debug";
};
010C4CDD1001930200B27A2B /* Debug-32 */ = {
010C4CDD1001930200B27A2B /* 32-Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
@ -1428,7 +1428,7 @@
PRODUCT_NAME = CDUnitTests;
WRAPPER_EXTENSION = octest;
};
name = "Debug-32";
name = "32-Debug";
};
012E2A9508AE9B4F003E99F8 /* Debug */ = {
isa = XCBuildConfiguration;
@ -1640,7 +1640,7 @@
};
name = Debug;
};
01F523921001D19C0006B272 /* Debug-32 */ = {
01F523921001D19C0006B272 /* 32-Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
@ -1658,7 +1658,7 @@
PREBINDING = NO;
PRODUCT_NAME = formatType;
};
name = "Debug-32";
name = "32-Debug";
};
01F523931001D19C0006B272 /* Release */ = {
isa = XCBuildConfiguration;
@ -1706,7 +1706,7 @@
};
name = Debug;
};
01F525031001F3E80006B272 /* Debug-32 */ = {
01F525031001F3E80006B272 /* 32-Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
@ -1724,7 +1724,7 @@
PREBINDING = NO;
PRODUCT_NAME = deprotect;
};
name = "Debug-32";
name = "32-Debug";
};
01F525041001F3E80006B272 /* Release */ = {
isa = XCBuildConfiguration;
@ -1756,7 +1756,7 @@
isa = XCConfigurationList;
buildConfigurations = (
012E2A9508AE9B4F003E99F8 /* Debug */,
010C4CD91001930200B27A2B /* Debug-32 */,
010C4CD91001930200B27A2B /* 32-Debug */,
012E2A9608AE9B4F003E99F8 /* Release */,
);
defaultConfigurationIsVisible = 0;
@ -1766,7 +1766,7 @@
isa = XCConfigurationList;
buildConfigurations = (
012FF18C0CDB886D00F31E61 /* Debug */,
010C4CDC1001930200B27A2B /* Debug-32 */,
010C4CDC1001930200B27A2B /* 32-Debug */,
012FF18D0CDB886D00F31E61 /* Release */,
);
defaultConfigurationIsVisible = 0;
@ -1776,7 +1776,7 @@
isa = XCConfigurationList;
buildConfigurations = (
013183030CDF6EE400EC5A2C /* Debug */,
010C4CDD1001930200B27A2B /* Debug-32 */,
010C4CDD1001930200B27A2B /* 32-Debug */,
013183040CDF6EE400EC5A2C /* Release */,
);
defaultConfigurationIsVisible = 0;
@ -1786,7 +1786,7 @@
isa = XCConfigurationList;
buildConfigurations = (
01A9A4BF0FF19B2F00475772 /* Debug */,
010C4CDB1001930200B27A2B /* Debug-32 */,
010C4CDB1001930200B27A2B /* 32-Debug */,
01A9A4C00FF19B2F00475772 /* Release */,
);
defaultConfigurationIsVisible = 0;
@ -1796,7 +1796,7 @@
isa = XCConfigurationList;
buildConfigurations = (
01A9A4C50FF19BAE00475772 /* Debug */,
010C4CDA1001930200B27A2B /* Debug-32 */,
010C4CDA1001930200B27A2B /* 32-Debug */,
01A9A4C60FF19BAE00475772 /* Release */,
);
defaultConfigurationIsVisible = 0;
@ -1806,7 +1806,7 @@
isa = XCConfigurationList;
buildConfigurations = (
01F523911001D19C0006B272 /* Debug */,
01F523921001D19C0006B272 /* Debug-32 */,
01F523921001D19C0006B272 /* 32-Debug */,
01F523931001D19C0006B272 /* Release */,
);
defaultConfigurationIsVisible = 0;
@ -1816,7 +1816,7 @@
isa = XCConfigurationList;
buildConfigurations = (
01F525021001F3E80006B272 /* Debug */,
01F525031001F3E80006B272 /* Debug-32 */,
01F525031001F3E80006B272 /* 32-Debug */,
01F525041001F3E80006B272 /* Release */,
);
defaultConfigurationIsVisible = 0;

View File

@ -46,11 +46,12 @@ int main(int argc, char *argv[])
CDTypeFormatter *ivarTypeFormatter;
CDTypeFormatter *methodTypeFormatter;
NSUInteger index;
ivarTypeFormatter = [[CDTypeFormatter alloc] init];
[ivarTypeFormatter setShouldExpand:YES];
[ivarTypeFormatter setShouldAutoExpand:YES];
[ivarTypeFormatter setBaseLevel:1];
[ivarTypeFormatter setBaseLevel:0];
//[ivarTypeFormatter setDelegate:self];
methodTypeFormatter = [[CDTypeFormatter alloc] init];
@ -92,58 +93,67 @@ int main(int argc, char *argv[])
exit(2);
}
if (optind < argc) {
switch (formatType) {
case CDFormatIvar: printf("Format as ivars\n"); break;
case CDFormatMethod: printf("Format as methods\n"); break;
case CDFormatBalance: printf("Format as balance\n"); break;
}
for (index = optind; index < argc; index++) {
NSString *arg;
NSString *input;
NSError *error;
NSArray *lines;
NSUInteger count, index;
CDTypeFormatter *formatter;
NSString *name, *type;
arg = [NSString stringWithFileSystemRepresentation:argv[optind]];
arg = [NSString stringWithFileSystemRepresentation:argv[index]];
printf("======================================================================\n");
printf("File: %s\n", argv[index]);
input = [[NSString alloc] initWithContentsOfFile:arg encoding:NSUTF8StringEncoding error:&error];
lines = [input componentsSeparatedByString:@"\n"];
count = [lines count];
NSLog(@"%u lines", count);
NSLog(@"%u pairs", count / 2);
switch (formatType) {
case CDFormatIvar: NSLog(@"Format as ivars"); break;
case CDFormatMethod: NSLog(@"Format as methods"); break;
case CDFormatBalance: NSLog(@"Format as balance"); break;
}
for (index = 0; index < count / 2; index++) {
NSString *name, *type;
NSString *str;
name = [lines objectAtIndex:index * 2];
type = [lines objectAtIndex:index * 2 + 1];
NSLog(@"----------------------------------------------------------------------");
NSLog(@"name: %@", name);
NSLog(@"type: %@", type);
switch (formatType) {
case CDFormatIvar:
str = [ivarTypeFormatter formatVariable:name type:type symbolReferences:nil];
break;
case CDFormatMethod:
str = [methodTypeFormatter formatMethodName:name type:type symbolReferences:nil];
break;
case CDFormatBalance: {
CDBalanceFormatter *balance;
NSLog(@"----------------------------------------------------------------------");
balance = [[CDBalanceFormatter alloc] initWithString:type];
str = [balance format];
[balance release];
}
name = type = nil;
for (NSString *line in lines) {
if ([line hasPrefix:@"//"] || [line length] == 0) {
printf("%s\n", [line UTF8String]);
continue;
}
NSLog(@"str: %@", str);
if (name == nil)
name = line;
else if (type == nil) {
NSString *str;
type = line;
switch (formatType) {
case CDFormatIvar:
str = [ivarTypeFormatter formatVariable:name type:type symbolReferences:nil];
break;
case CDFormatMethod:
str = [methodTypeFormatter formatMethodName:name type:type symbolReferences:nil];
break;
case CDFormatBalance: {
CDBalanceFormatter *balance;
balance = [[CDBalanceFormatter alloc] initWithString:type];
str = [balance format];
[balance release];
}
}
if (str == nil)
printf("Error formatting type.\n");
else
printf("%s\n", [str UTF8String]);
printf("----------------------------------------------------------------------\n");
name = type = nil;
}
}
[input release];