mirror of
https://github.com/darlinghq/class-dump.git
synced 2024-11-23 04:19:41 +00:00
Working on the visitor classes and CDSearchPathState.
- use properties - rearranged some methods in implementations - made some methods and properties private to particular classes - renamed parameters to get rid of a/an/some prefixes - renamed findString to searchString
This commit is contained in:
parent
2d196e692d
commit
801207f60c
@ -34,7 +34,7 @@
|
||||
[self.classDump appendHeaderToString:self.resultString];
|
||||
|
||||
if (self.classDump.hasObjectiveCRuntimeInfo) {
|
||||
[[self.classDump typeController] appendStructuresToString:self.resultString symbolReferences:nil];
|
||||
[self.classDump.typeController appendStructuresToString:self.resultString symbolReferences:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,27 +45,26 @@
|
||||
[self writeResultToStandardOutput];
|
||||
}
|
||||
|
||||
- (void)visitObjectiveCProcessor:(CDObjectiveCProcessor *)aProcessor;
|
||||
- (void)visitObjectiveCProcessor:(CDObjectiveCProcessor *)processor;
|
||||
{
|
||||
CDMachOFile *machOFile = [aProcessor machOFile];
|
||||
CDMachOFile *machOFile = processor.machOFile;
|
||||
|
||||
[self.resultString appendString:@"#pragma mark -\n\n"];
|
||||
[self.resultString appendString:@"/*\n"];
|
||||
[self.resultString appendFormat:@" * File: %@\n", [machOFile filename]];
|
||||
[self.resultString appendFormat:@" * UUID: %@\n", [machOFile uuidString]];
|
||||
[self.resultString appendFormat:@" * File: %@\n", machOFile.filename];
|
||||
[self.resultString appendFormat:@" * UUID: %@\n", machOFile.uuidString];
|
||||
|
||||
const NXArchInfo *archInfo = NXGetArchInfoFromCpuType([machOFile cputypePlusArchBits], [machOFile cpusubtype]);
|
||||
//archInfo = [machOFile archInfo];
|
||||
const NXArchInfo *archInfo = NXGetArchInfoFromCpuType(machOFile.cputypePlusArchBits, machOFile.cpusubtype);
|
||||
if (archInfo == NULL)
|
||||
[self.resultString appendFormat:@" * Arch: cputype: 0x%x, cpusubtype: 0x%x\n", [machOFile cputype], [machOFile cpusubtype]];
|
||||
[self.resultString appendFormat:@" * Arch: cputype: 0x%x, cpusubtype: 0x%x\n", machOFile.cputype, machOFile.cpusubtype];
|
||||
else
|
||||
[self.resultString appendFormat:@" * Arch: %s (%s)\n", archInfo->description, archInfo->name];
|
||||
|
||||
if ([machOFile filetype] == MH_DYLIB) {
|
||||
CDLCDylib *identifier = [machOFile dylibIdentifier];
|
||||
if (machOFile.filetype == MH_DYLIB) {
|
||||
CDLCDylib *identifier = machOFile.dylibIdentifier;
|
||||
if (identifier != nil)
|
||||
[self.resultString appendFormat:@" * Current version: %@, Compatibility version: %@\n",
|
||||
[identifier formattedCurrentVersion], [identifier formattedCompatibilityVersion]];
|
||||
identifier.formattedCurrentVersion, identifier.formattedCompatibilityVersion];
|
||||
}
|
||||
|
||||
if (machOFile.minVersionMacOSX != nil)
|
||||
@ -74,8 +73,8 @@
|
||||
[self.resultString appendFormat:@" * Minimum iOS version: %@\n", machOFile.minVersionIOS.minimumVersionString];
|
||||
|
||||
[self.resultString appendFormat:@" *\n"];
|
||||
if (aProcessor.garbageCollectionStatus != nil)
|
||||
[self.resultString appendFormat:@" * Objective-C Garbage Collection: %@\n", aProcessor.garbageCollectionStatus];
|
||||
if (processor.garbageCollectionStatus != nil)
|
||||
[self.resultString appendFormat:@" * Objective-C Garbage Collection: %@\n", processor.garbageCollectionStatus];
|
||||
|
||||
if ([machOFile.dyldEnvironment count] > 0) {
|
||||
BOOL first = YES;
|
||||
@ -89,39 +88,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
for (CDLoadCommand *loadCommand in [machOFile loadCommands]) {
|
||||
for (CDLoadCommand *loadCommand in machOFile.loadCommands) {
|
||||
if ([loadCommand isKindOfClass:[CDLCRunPath class]]) {
|
||||
CDLCRunPath *runPath = (CDLCRunPath *)loadCommand;
|
||||
|
||||
[self.resultString appendFormat:@" * Run path: %@\n", [runPath path]];
|
||||
[self.resultString appendFormat:@" * = %@\n", [runPath resolvedRunPath]];
|
||||
[self.resultString appendFormat:@" * Run path: %@\n", runPath.path];
|
||||
[self.resultString appendFormat:@" * = %@\n", runPath.resolvedRunPath];
|
||||
}
|
||||
}
|
||||
|
||||
if ([machOFile isEncrypted]) {
|
||||
if (machOFile.isEncrypted) {
|
||||
[self.resultString appendString:@" * This file is encrypted:\n"];
|
||||
for (CDLoadCommand *loadCommand in [machOFile loadCommands]) {
|
||||
for (CDLoadCommand *loadCommand in machOFile.loadCommands) {
|
||||
if ([loadCommand isKindOfClass:[CDLCEncryptionInfo class]]) {
|
||||
CDLCEncryptionInfo *encryptionInfo = (CDLCEncryptionInfo *)loadCommand;
|
||||
|
||||
[self.resultString appendFormat:@" * cryptid: 0x%08x, cryptoff: 0x%08x, cryptsize: 0x%08x\n",
|
||||
[encryptionInfo cryptid], [encryptionInfo cryptoff], [encryptionInfo cryptsize]];
|
||||
encryptionInfo.cryptid, encryptionInfo.cryptoff, encryptionInfo.cryptsize];
|
||||
}
|
||||
}
|
||||
} else if ([machOFile hasProtectedSegments]) {
|
||||
if ([machOFile canDecryptAllSegments]) {
|
||||
} else if (machOFile.hasProtectedSegments) {
|
||||
if (machOFile.canDecryptAllSegments) {
|
||||
[self.resultString appendString:@" * This file has protected segments, decrypting.\n"];
|
||||
} else {
|
||||
NSUInteger index = 0;
|
||||
|
||||
[self.resultString appendString:@" * This file has protected segments that can't be decrypted:\n"];
|
||||
for (CDLoadCommand *loadCommand in [machOFile loadCommands]) {
|
||||
for (CDLoadCommand *loadCommand in machOFile.loadCommands) {
|
||||
if ([loadCommand isKindOfClass:[CDLCSegment class]]) {
|
||||
CDLCSegment *segment = (CDLCSegment *)loadCommand;
|
||||
|
||||
if ([segment canDecrypt] == NO) {
|
||||
if (segment.canDecrypt == NO) {
|
||||
[self.resultString appendFormat:@" * Load command %u, segment encryption: %@\n",
|
||||
index, CDSegmentEncryptionTypeName([segment encryptionType])];
|
||||
index, CDSegmentEncryptionTypeName(segment.encryptionType)];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,7 @@
|
||||
|
||||
@interface CDClassFrameworkVisitor : CDVisitor
|
||||
|
||||
- (NSDictionary *)frameworkNamesByClassName;
|
||||
- (NSDictionary *)frameworkNamesByProtocolName;
|
||||
|
||||
@property (retain) NSString *frameworkName;
|
||||
@property (readonly) NSDictionary *frameworkNamesByClassName;
|
||||
@property (readonly) NSDictionary *frameworkNamesByProtocolName;
|
||||
|
||||
@end
|
||||
|
@ -11,10 +11,16 @@
|
||||
|
||||
// This builds up a dictionary mapping class names to a framework name. It is used to generate individual imports when creating separate header files.
|
||||
|
||||
@interface CDClassFrameworkVisitor ()
|
||||
@property (retain) NSString *frameworkName;
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation CDClassFrameworkVisitor
|
||||
{
|
||||
NSMutableDictionary *frameworkNamesByClassName;
|
||||
NSMutableDictionary *frameworkNamesByProtocolName;
|
||||
NSMutableDictionary *frameworkNamesByClassName; // NSString (class name) -> NSString (framework name)
|
||||
NSMutableDictionary *frameworkNamesByProtocolName; // NSString (protocol name) -> NSString (framework name)
|
||||
NSString *frameworkName;
|
||||
}
|
||||
|
||||
@ -40,35 +46,29 @@
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (NSDictionary *)frameworkNamesByClassName;
|
||||
- (void)willVisitObjectiveCProcessor:(CDObjectiveCProcessor *)processor;
|
||||
{
|
||||
return frameworkNamesByClassName;
|
||||
}
|
||||
|
||||
- (NSDictionary *)frameworkNamesByProtocolName;
|
||||
{
|
||||
return frameworkNamesByProtocolName;
|
||||
}
|
||||
|
||||
@synthesize frameworkName;
|
||||
|
||||
- (void)willVisitObjectiveCProcessor:(CDObjectiveCProcessor *)anObjCSegment;
|
||||
{
|
||||
[self setFrameworkName:[[anObjCSegment machOFile] importBaseName]];
|
||||
self.frameworkName = [processor.machOFile importBaseName];
|
||||
}
|
||||
|
||||
- (void)willVisitClass:(CDOCClass *)aClass;
|
||||
{
|
||||
if (frameworkName != nil) {
|
||||
[frameworkNamesByClassName setObject:frameworkName forKey:[aClass name]];
|
||||
if (self.frameworkName != nil) {
|
||||
[frameworkNamesByClassName setObject:self.frameworkName forKey:aClass.name];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
if (frameworkName != nil) {
|
||||
[frameworkNamesByProtocolName setObject:frameworkName forKey:[aProtocol name]];
|
||||
if (self.frameworkName != nil) {
|
||||
[frameworkNamesByProtocolName setObject:self.frameworkName forKey:protocol.name];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@synthesize frameworkNamesByClassName;
|
||||
@synthesize frameworkNamesByProtocolName;
|
||||
@synthesize frameworkName;
|
||||
|
||||
@end
|
||||
|
@ -7,11 +7,6 @@
|
||||
|
||||
@interface CDFindMethodVisitor : CDVisitor
|
||||
|
||||
@property (retain) NSString *findString;
|
||||
|
||||
- (void)setContext:(CDOCProtocol *)newContext;
|
||||
- (void)showContextIfNecessary;
|
||||
|
||||
- (void)writeResultToStandardOutput;
|
||||
@property (retain) NSString *searchString;
|
||||
|
||||
@end
|
||||
|
@ -16,9 +16,17 @@
|
||||
#import "CDOCMethod.h"
|
||||
#import "CDTypeController.h"
|
||||
|
||||
@interface CDFindMethodVisitor ()
|
||||
@property (nonatomic, retain) CDOCProtocol *context;
|
||||
- (void)showContextIfNecessary;
|
||||
- (void)writeResultToStandardOutput;
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation CDFindMethodVisitor
|
||||
{
|
||||
NSString *findString;
|
||||
NSString *searchString;
|
||||
NSMutableString *resultString;
|
||||
CDOCProtocol *context;
|
||||
BOOL hasShownContext;
|
||||
@ -27,7 +35,7 @@
|
||||
- (id)init;
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
findString = nil;
|
||||
searchString = nil;
|
||||
resultString = [[NSMutableString alloc] init];
|
||||
context = nil;
|
||||
hasShownContext = NO;
|
||||
@ -38,7 +46,7 @@
|
||||
|
||||
- (void)dealloc;
|
||||
{
|
||||
[findString release];
|
||||
[searchString release];
|
||||
[resultString release];
|
||||
[context release];
|
||||
|
||||
@ -47,28 +55,6 @@
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@synthesize findString;
|
||||
|
||||
- (void)setContext:(CDOCProtocol *)newContext;
|
||||
{
|
||||
if (newContext == context)
|
||||
return;
|
||||
|
||||
[context release];
|
||||
context = [newContext retain];
|
||||
|
||||
hasShownContext = NO;
|
||||
}
|
||||
|
||||
- (void)showContextIfNecessary;
|
||||
{
|
||||
if (hasShownContext == NO) {
|
||||
[resultString appendString:[context findTag:nil]];
|
||||
[resultString appendString:@"\n"];
|
||||
hasShownContext = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)willBeginVisiting;
|
||||
{
|
||||
[self.classDump appendHeaderToString:resultString];
|
||||
@ -79,7 +65,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)visitObjectiveCProcessor:(CDObjectiveCProcessor *)aProcessor;
|
||||
- (void)visitObjectiveCProcessor:(CDObjectiveCProcessor *)processor;
|
||||
{
|
||||
if (!self.classDump.hasObjectiveCRuntimeInfo) {
|
||||
[resultString appendString:@"//\n"];
|
||||
@ -99,12 +85,12 @@
|
||||
[(NSFileHandle *)[NSFileHandle fileHandleWithStandardOutput] writeData:data];
|
||||
}
|
||||
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
[self setContext:aProtocol];
|
||||
[self setContext:protocol];
|
||||
}
|
||||
|
||||
- (void)didVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)didVisitProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
if (hasShownContext)
|
||||
[resultString appendString:@"\n"];
|
||||
@ -129,43 +115,67 @@
|
||||
{
|
||||
}
|
||||
|
||||
- (void)willVisitCategory:(CDOCCategory *)aCategory;
|
||||
- (void)willVisitCategory:(CDOCCategory *)category;
|
||||
{
|
||||
[self setContext:aCategory];
|
||||
[self setContext:category];
|
||||
}
|
||||
|
||||
- (void)didVisitCategory:(CDOCCategory *)aCategory;
|
||||
- (void)didVisitCategory:(CDOCCategory *)category;
|
||||
{
|
||||
if (hasShownContext)
|
||||
[resultString appendString:@"\n"];
|
||||
}
|
||||
|
||||
- (void)visitClassMethod:(CDOCMethod *)aMethod;
|
||||
- (void)visitClassMethod:(CDOCMethod *)method;
|
||||
{
|
||||
NSRange range = [[aMethod name] rangeOfString:findString];
|
||||
NSRange range = [[method name] rangeOfString:searchString];
|
||||
if (range.length > 0) {
|
||||
[self showContextIfNecessary];
|
||||
|
||||
[resultString appendString:@"+ "];
|
||||
[aMethod appendToString:resultString typeController:[self.classDump typeController] symbolReferences:nil];
|
||||
[method appendToString:resultString typeController:[self.classDump typeController] symbolReferences:nil];
|
||||
[resultString appendString:@"\n"];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)visitInstanceMethod:(CDOCMethod *)aMethod propertyState:(CDVisitorPropertyState *)propertyState;
|
||||
- (void)visitInstanceMethod:(CDOCMethod *)method propertyState:(CDVisitorPropertyState *)propertyState;
|
||||
{
|
||||
NSRange range = [[aMethod name] rangeOfString:findString];
|
||||
NSRange range = [[method name] rangeOfString:searchString];
|
||||
if (range.length > 0) {
|
||||
[self showContextIfNecessary];
|
||||
|
||||
[resultString appendString:@"- "];
|
||||
[aMethod appendToString:resultString typeController:[self.classDump typeController] symbolReferences:nil];
|
||||
[method appendToString:resultString typeController:[self.classDump typeController] symbolReferences:nil];
|
||||
[resultString appendString:@"\n"];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)visitIvar:(CDOCIvar *)anIvar;
|
||||
- (void)visitIvar:(CDOCIvar *)ivar;
|
||||
{
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@synthesize searchString;
|
||||
@synthesize context;
|
||||
|
||||
- (void)setContext:(CDOCProtocol *)newContext;
|
||||
{
|
||||
if (newContext != context) {
|
||||
[context release];
|
||||
context = [newContext retain];
|
||||
|
||||
hasShownContext = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showContextIfNecessary;
|
||||
{
|
||||
if (hasShownContext == NO) {
|
||||
[resultString appendString:[self.context findTag:nil]];
|
||||
[resultString appendString:@"\n"];
|
||||
hasShownContext = YES;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -59,7 +59,7 @@ typedef NSUInteger CDByteOrder;
|
||||
- (NSString *)filetypeDescription;
|
||||
- (NSString *)flagDescription;
|
||||
|
||||
- (CDLCDylib *)dylibIdentifier;
|
||||
@property (nonatomic, readonly) CDLCDylib *dylibIdentifier;
|
||||
|
||||
- (CDLCSegment *)segmentWithName:(NSString *)segmentName;
|
||||
- (CDLCSegment *)segmentContainingAddress:(NSUInteger)address;
|
||||
@ -80,8 +80,8 @@ typedef NSUInteger CDByteOrder;
|
||||
- (NSString *)loadCommandString:(BOOL)isVerbose;
|
||||
- (NSString *)headerString:(BOOL)isVerbose;
|
||||
|
||||
- (NSString *)uuidString;
|
||||
- (NSString *)archName;
|
||||
@property (nonatomic, readonly) NSString *uuidString;
|
||||
@property (nonatomic, readonly) NSString *archName;
|
||||
|
||||
- (Class)processorClass;
|
||||
- (void)logInfoForAddress:(NSUInteger)address;
|
||||
|
@ -5,16 +5,8 @@
|
||||
|
||||
#import "CDTextClassDumpVisitor.h"
|
||||
|
||||
@class CDSymbolReferences;
|
||||
|
||||
@interface CDMultiFileVisitor : CDTextClassDumpVisitor
|
||||
|
||||
@property (retain) NSString *outputPath;
|
||||
|
||||
- (void)createOutputPathIfNecessary;
|
||||
|
||||
- (void)buildClassFrameworks;
|
||||
|
||||
- (void)generateStructureHeader;
|
||||
|
||||
@end
|
||||
|
@ -14,21 +14,20 @@
|
||||
#import "CDOCIvar.h"
|
||||
#import "CDTypeController.h"
|
||||
|
||||
@interface CDMultiFileVisitor ()
|
||||
- (void)createOutputPathIfNecessary;
|
||||
- (void)buildClassFrameworks;
|
||||
- (void)generateStructureHeader;
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation CDMultiFileVisitor
|
||||
{
|
||||
NSString *outputPath;
|
||||
NSUInteger referenceIndex;
|
||||
}
|
||||
|
||||
- (id)init;
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
outputPath = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc;
|
||||
{
|
||||
[outputPath release];
|
||||
@ -38,60 +37,6 @@
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@synthesize outputPath;
|
||||
|
||||
- (void)createOutputPathIfNecessary;
|
||||
{
|
||||
if (outputPath != nil) {
|
||||
BOOL isDirectory;
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
if ([fileManager fileExistsAtPath:outputPath isDirectory:&isDirectory] == NO) {
|
||||
NSError *error = nil;
|
||||
BOOL result = [fileManager createDirectoryAtPath:outputPath withIntermediateDirectories:YES attributes:nil error:&error];
|
||||
if (result == NO) {
|
||||
NSLog(@"Error: Couldn't create output directory: %@", outputPath);
|
||||
NSLog(@"error: %@", error); // TODO: Test this
|
||||
return;
|
||||
}
|
||||
} else if (isDirectory == NO) {
|
||||
NSLog(@"Error: File exists at output path: %@", outputPath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)buildClassFrameworks;
|
||||
{
|
||||
CDClassFrameworkVisitor *visitor = [[CDClassFrameworkVisitor alloc] init];
|
||||
[visitor setClassDump:self.classDump];
|
||||
[self.classDump recursivelyVisit:visitor];
|
||||
[self.symbolReferences setFrameworkNamesByClassName:[visitor frameworkNamesByClassName]];
|
||||
[self.symbolReferences setFrameworkNamesByProtocolName:[visitor frameworkNamesByProtocolName]];
|
||||
[visitor release];
|
||||
}
|
||||
|
||||
- (void)generateStructureHeader;
|
||||
{
|
||||
[self.resultString setString:@""];
|
||||
[self.classDump appendHeaderToString:self.resultString];
|
||||
|
||||
[self.symbolReferences removeAllReferences];
|
||||
referenceIndex = [self.resultString length];
|
||||
|
||||
[[self.classDump typeController] appendStructuresToString:self.resultString symbolReferences:self.symbolReferences];
|
||||
|
||||
NSString *referenceString = [self.symbolReferences referenceString];
|
||||
if (referenceString != nil)
|
||||
[self.resultString insertString:referenceString atIndex:referenceIndex];
|
||||
|
||||
NSString *filename = @"CDStructures.h";
|
||||
if (outputPath != nil)
|
||||
filename = [outputPath stringByAppendingPathComponent:filename];
|
||||
|
||||
[[self.resultString dataUsingEncoding:NSUTF8StringEncoding] writeToFile:filename atomically:YES];
|
||||
}
|
||||
|
||||
- (void)willBeginVisiting;
|
||||
{
|
||||
[super willBeginVisiting];
|
||||
@ -146,14 +91,14 @@
|
||||
[[self.resultString dataUsingEncoding:NSUTF8StringEncoding] writeToFile:filename atomically:YES];
|
||||
}
|
||||
|
||||
- (void)willVisitCategory:(CDOCCategory *)aCategory;
|
||||
- (void)willVisitCategory:(CDOCCategory *)category;
|
||||
{
|
||||
// First, we set up some context...
|
||||
[self.resultString setString:@""];
|
||||
[self.classDump appendHeaderToString:self.resultString];
|
||||
|
||||
[self.symbolReferences removeAllReferences];
|
||||
NSString *str = [self.symbolReferences importStringForClassName:[aCategory className]];
|
||||
NSString *str = [self.symbolReferences importStringForClassName:[category className]];
|
||||
if (str != nil) {
|
||||
[self.resultString appendString:str];
|
||||
[self.resultString appendString:@"\n"];
|
||||
@ -161,28 +106,28 @@
|
||||
referenceIndex = [self.resultString length];
|
||||
|
||||
// And then generate the regular output
|
||||
[super willVisitCategory:aCategory];
|
||||
[super willVisitCategory:category];
|
||||
}
|
||||
|
||||
- (void)didVisitCategory:(CDOCCategory *)aCategory;
|
||||
- (void)didVisitCategory:(CDOCCategory *)category;
|
||||
{
|
||||
// Generate the regular output
|
||||
[super didVisitCategory:aCategory];
|
||||
[super didVisitCategory:category];
|
||||
|
||||
// Then insert the imports and write the file.
|
||||
[self.symbolReferences removeClassName:[aCategory className]];
|
||||
[self.symbolReferences removeClassName:[category className]];
|
||||
NSString *referenceString = [self.symbolReferences referenceString];
|
||||
if (referenceString != nil)
|
||||
[self.resultString insertString:referenceString atIndex:referenceIndex];
|
||||
|
||||
NSString *filename = [NSString stringWithFormat:@"%@-%@.h", [aCategory className], [aCategory name]];
|
||||
NSString *filename = [NSString stringWithFormat:@"%@-%@.h", [category className], [category name]];
|
||||
if (outputPath != nil)
|
||||
filename = [outputPath stringByAppendingPathComponent:filename];
|
||||
|
||||
[[self.resultString dataUsingEncoding:NSUTF8StringEncoding] writeToFile:filename atomically:YES];
|
||||
}
|
||||
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
[self.resultString setString:@""];
|
||||
[self.classDump appendHeaderToString:self.resultString];
|
||||
@ -191,24 +136,80 @@
|
||||
referenceIndex = [self.resultString length];
|
||||
|
||||
// And then generate the regular output
|
||||
[super willVisitProtocol:aProtocol];
|
||||
[super willVisitProtocol:protocol];
|
||||
}
|
||||
|
||||
- (void)didVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)didVisitProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
// Generate the regular output
|
||||
[super didVisitProtocol:aProtocol];
|
||||
[super didVisitProtocol:protocol];
|
||||
|
||||
// Then insert the imports and write the file.
|
||||
NSString *referenceString = [self.symbolReferences referenceString];
|
||||
if (referenceString != nil)
|
||||
[self.resultString insertString:referenceString atIndex:referenceIndex];
|
||||
|
||||
NSString *filename = [NSString stringWithFormat:@"%@-Protocol.h", [aProtocol name]];
|
||||
NSString *filename = [NSString stringWithFormat:@"%@-Protocol.h", [protocol name]];
|
||||
if (outputPath != nil)
|
||||
filename = [outputPath stringByAppendingPathComponent:filename];
|
||||
|
||||
[[self.resultString dataUsingEncoding:NSUTF8StringEncoding] writeToFile:filename atomically:YES];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@synthesize outputPath;
|
||||
|
||||
- (void)createOutputPathIfNecessary;
|
||||
{
|
||||
if (outputPath != nil) {
|
||||
BOOL isDirectory;
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
if ([fileManager fileExistsAtPath:outputPath isDirectory:&isDirectory] == NO) {
|
||||
NSError *error = nil;
|
||||
BOOL result = [fileManager createDirectoryAtPath:outputPath withIntermediateDirectories:YES attributes:nil error:&error];
|
||||
if (result == NO) {
|
||||
NSLog(@"Error: Couldn't create output directory: %@", outputPath);
|
||||
NSLog(@"error: %@", error); // TODO: Test this
|
||||
return;
|
||||
}
|
||||
} else if (isDirectory == NO) {
|
||||
NSLog(@"Error: File exists at output path: %@", outputPath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)buildClassFrameworks;
|
||||
{
|
||||
CDClassFrameworkVisitor *visitor = [[CDClassFrameworkVisitor alloc] init];
|
||||
[visitor setClassDump:self.classDump];
|
||||
[self.classDump recursivelyVisit:visitor];
|
||||
[self.symbolReferences setFrameworkNamesByClassName:[visitor frameworkNamesByClassName]];
|
||||
[self.symbolReferences setFrameworkNamesByProtocolName:[visitor frameworkNamesByProtocolName]];
|
||||
[visitor release];
|
||||
}
|
||||
|
||||
- (void)generateStructureHeader;
|
||||
{
|
||||
[self.resultString setString:@""];
|
||||
[self.classDump appendHeaderToString:self.resultString];
|
||||
|
||||
[self.symbolReferences removeAllReferences];
|
||||
referenceIndex = [self.resultString length];
|
||||
|
||||
[[self.classDump typeController] appendStructuresToString:self.resultString symbolReferences:self.symbolReferences];
|
||||
|
||||
NSString *referenceString = [self.symbolReferences referenceString];
|
||||
if (referenceString != nil)
|
||||
[self.resultString insertString:referenceString atIndex:referenceIndex];
|
||||
|
||||
NSString *filename = @"CDStructures.h";
|
||||
if (outputPath != nil)
|
||||
filename = [outputPath stringByAppendingPathComponent:filename];
|
||||
|
||||
[[self.resultString dataUsingEncoding:NSUTF8StringEncoding] writeToFile:filename atomically:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -34,10 +34,10 @@
|
||||
- (NSArray *)optionalInstanceMethods;
|
||||
- (void)addOptionalInstanceMethod:(CDOCMethod *)method;
|
||||
|
||||
- (NSArray *)properties;
|
||||
@property (readonly) NSArray *properties;
|
||||
- (void)addProperty:(CDOCProperty *)property;
|
||||
|
||||
- (BOOL)hasMethods;
|
||||
@property (nonatomic, readonly) BOOL hasMethods;
|
||||
|
||||
- (void)registerTypesWithObject:(CDTypeController *)typeController phase:(NSUInteger)phase;
|
||||
- (void)registerTypesFromMethods:(NSArray *)methods withObject:(CDTypeController *)typeController phase:(NSUInteger)phase;
|
||||
|
@ -132,10 +132,7 @@
|
||||
[optionalInstanceMethods addObject:method];
|
||||
}
|
||||
|
||||
- (NSArray *)properties;
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
@synthesize properties;
|
||||
|
||||
- (void)addProperty:(CDOCProperty *)property;
|
||||
{
|
||||
|
@ -12,7 +12,7 @@
|
||||
- (void)pushSearchPaths:(NSArray *)searchPaths;
|
||||
- (void)popSearchPaths;
|
||||
|
||||
- (NSString *)resolvePath:(NSString *)aPath;
|
||||
- (NSString *)resolvePath:(NSString *)path;
|
||||
- (NSArray *)searchPaths;
|
||||
|
||||
@end
|
||||
|
@ -48,15 +48,15 @@
|
||||
|
||||
}
|
||||
|
||||
- (NSString *)resolvePath:(NSString *)aPath;
|
||||
- (NSString *)resolvePath:(NSString *)path;
|
||||
{
|
||||
for (NSArray *group in searchPathStack) {
|
||||
for (NSString *path in group) {
|
||||
NSLog(@"path %@", path);
|
||||
for (NSString *thisPath in group) {
|
||||
NSLog(@"path %@", thisPath);
|
||||
}
|
||||
}
|
||||
|
||||
return aPath;
|
||||
return path;
|
||||
}
|
||||
|
||||
- (NSArray *)searchPaths;
|
||||
|
@ -52,20 +52,18 @@
|
||||
|
||||
- (void)setFrameworkNamesByClassName:(NSDictionary *)newValue;
|
||||
{
|
||||
if (newValue == frameworkNamesByClassName)
|
||||
return;
|
||||
|
||||
[frameworkNamesByClassName release];
|
||||
frameworkNamesByClassName = [newValue retain];
|
||||
if (newValue != frameworkNamesByClassName) {
|
||||
[frameworkNamesByClassName release];
|
||||
frameworkNamesByClassName = [newValue retain];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setFrameworkNamesByProtocolName:(NSDictionary *)newValue;
|
||||
{
|
||||
if (newValue == frameworkNamesByProtocolName)
|
||||
return;
|
||||
|
||||
[frameworkNamesByProtocolName release];
|
||||
frameworkNamesByProtocolName = [newValue retain];
|
||||
if (newValue != frameworkNamesByProtocolName) {
|
||||
[frameworkNamesByProtocolName release];
|
||||
frameworkNamesByProtocolName = [newValue retain];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)frameworkForClassName:(NSString *)aClassName;
|
||||
|
@ -14,6 +14,4 @@
|
||||
|
||||
- (void)writeResultToStandardOutput;
|
||||
|
||||
- (void)_visitProperty:(CDOCProperty *)aProperty parsedType:(CDType *)parsedType attributes:(NSArray *)attrs;
|
||||
|
||||
@end
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#import "CDTextClassDumpVisitor.h"
|
||||
|
||||
#include <mach-o/arch.h>
|
||||
|
||||
#import "NSArray-Extensions.h"
|
||||
#import "CDClassDump.h"
|
||||
#import "CDObjectiveC1Processor.h"
|
||||
@ -22,8 +20,17 @@
|
||||
#import "CDTypeController.h"
|
||||
#import "CDVisitorPropertyState.h"
|
||||
|
||||
// Add newlines after properties
|
||||
#define ADD_SPACE
|
||||
|
||||
static BOOL debug = NO;
|
||||
|
||||
@interface CDTextClassDumpVisitor ()
|
||||
- (void)_visitProperty:(CDOCProperty *)property parsedType:(CDType *)parsedType attributes:(NSArray *)attrs;
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation CDTextClassDumpVisitor
|
||||
{
|
||||
NSMutableString *resultString;
|
||||
@ -50,25 +57,16 @@ static BOOL debug = NO;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@synthesize resultString;
|
||||
@synthesize symbolReferences;
|
||||
|
||||
- (void)writeResultToStandardOutput;
|
||||
{
|
||||
NSData *data = [resultString dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[(NSFileHandle *)[NSFileHandle fileHandleWithStandardOutput] writeData:data];
|
||||
}
|
||||
|
||||
- (void)willVisitClass:(CDOCClass *)aClass;
|
||||
{
|
||||
if ([aClass isExported] == NO)
|
||||
if (aClass.isExported == NO)
|
||||
[resultString appendString:@"// Not exported\n"];
|
||||
|
||||
[resultString appendFormat:@"@interface %@", [aClass name]];
|
||||
if ([aClass superClassName] != nil)
|
||||
[resultString appendFormat:@" : %@", [aClass superClassName]];
|
||||
[resultString appendFormat:@"@interface %@", aClass.name];
|
||||
if (aClass.superClassName != nil)
|
||||
[resultString appendFormat:@" : %@", aClass.superClassName];
|
||||
|
||||
NSArray *protocols = [aClass protocols];
|
||||
NSArray *protocols = aClass.protocols;
|
||||
if ([protocols count] > 0) {
|
||||
[resultString appendFormat:@" <%@>", [[protocols arrayByMappingSelector:@selector(name)] componentsJoinedByString:@", "]];
|
||||
[symbolReferences addProtocolNamesFromArray:[protocols arrayByMappingSelector:@selector(name)]];
|
||||
@ -79,7 +77,7 @@ static BOOL debug = NO;
|
||||
|
||||
- (void)didVisitClass:(CDOCClass *)aClass;
|
||||
{
|
||||
if ([aClass hasMethods])
|
||||
if (aClass.hasMethods)
|
||||
[resultString appendString:@"\n"];
|
||||
|
||||
[resultString appendString:@"@end\n\n"];
|
||||
@ -95,13 +93,11 @@ static BOOL debug = NO;
|
||||
[resultString appendString:@"}\n\n"];
|
||||
}
|
||||
|
||||
- (void)willVisitCategory:(CDOCCategory *)aCategory;
|
||||
- (void)willVisitCategory:(CDOCCategory *)category;
|
||||
{
|
||||
NSArray *protocols;
|
||||
[resultString appendFormat:@"@interface %@ (%@)", category.className, category.name];
|
||||
|
||||
[resultString appendFormat:@"@interface %@ (%@)", [aCategory className], [aCategory name]];
|
||||
|
||||
protocols = [aCategory protocols];
|
||||
NSArray *protocols = category.protocols;
|
||||
if ([protocols count] > 0) {
|
||||
[resultString appendFormat:@" <%@>", [[protocols arrayByMappingSelector:@selector(name)] componentsJoinedByString:@", "]];
|
||||
[symbolReferences addProtocolNamesFromArray:[protocols arrayByMappingSelector:@selector(name)]];
|
||||
@ -110,16 +106,16 @@ static BOOL debug = NO;
|
||||
[resultString appendString:@"\n"];
|
||||
}
|
||||
|
||||
- (void)didVisitCategory:(CDOCCategory *)aCategory;
|
||||
- (void)didVisitCategory:(CDOCCategory *)category;
|
||||
{
|
||||
[resultString appendString:@"@end\n\n"];
|
||||
}
|
||||
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
[resultString appendFormat:@"@protocol %@", [aProtocol name]];
|
||||
[resultString appendFormat:@"@protocol %@", protocol.name];
|
||||
|
||||
NSArray *protocols = [aProtocol protocols];
|
||||
NSArray *protocols = protocol.protocols;
|
||||
if ([protocols count] > 0) {
|
||||
[resultString appendFormat:@" <%@>", [[protocols arrayByMappingSelector:@selector(name)] componentsJoinedByString:@", "]];
|
||||
[symbolReferences addProtocolNamesFromArray:[protocols arrayByMappingSelector:@selector(name)]];
|
||||
@ -133,54 +129,135 @@ static BOOL debug = NO;
|
||||
[resultString appendString:@"\n@optional\n"];
|
||||
}
|
||||
|
||||
- (void)didVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)didVisitProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
[resultString appendString:@"@end\n\n"];
|
||||
}
|
||||
|
||||
- (void)visitClassMethod:(CDOCMethod *)aMethod;
|
||||
- (void)visitClassMethod:(CDOCMethod *)method;
|
||||
{
|
||||
[resultString appendString:@"+ "];
|
||||
[aMethod appendToString:resultString typeController:[self.classDump typeController] symbolReferences:symbolReferences];
|
||||
[method appendToString:resultString typeController:self.classDump.typeController symbolReferences:symbolReferences];
|
||||
[resultString appendString:@"\n"];
|
||||
}
|
||||
|
||||
- (void)visitInstanceMethod:(CDOCMethod *)aMethod propertyState:(CDVisitorPropertyState *)propertyState;
|
||||
- (void)visitInstanceMethod:(CDOCMethod *)method propertyState:(CDVisitorPropertyState *)propertyState;
|
||||
{
|
||||
CDOCProperty *property = [propertyState propertyForAccessor:[aMethod name]];
|
||||
CDOCProperty *property = [propertyState propertyForAccessor:method.name];
|
||||
if (property == nil) {
|
||||
//NSLog(@"No property for method: %@", [aMethod name]);
|
||||
//NSLog(@"No property for method: %@", method.name);
|
||||
[resultString appendString:@"- "];
|
||||
[aMethod appendToString:resultString typeController:[self.classDump typeController] symbolReferences:symbolReferences];
|
||||
[method appendToString:resultString typeController:self.classDump.typeController symbolReferences:symbolReferences];
|
||||
[resultString appendString:@"\n"];
|
||||
} else {
|
||||
if ([propertyState hasUsedProperty:property] == NO) {
|
||||
//NSLog(@"Emitting property %@ triggered by method %@", [property name], [aMethod name]);
|
||||
//NSLog(@"Emitting property %@ triggered by method %@", property.name, method.name);
|
||||
[self visitProperty:property];
|
||||
[propertyState useProperty:property];
|
||||
} else {
|
||||
//NSLog(@"Have already emitted property %@ triggered by method %@", [property name], [aMethod name]);
|
||||
//NSLog(@"Have already emitted property %@ triggered by method %@", property.name, method.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)visitIvar:(CDOCIvar *)anIvar;
|
||||
- (void)visitIvar:(CDOCIvar *)ivar;
|
||||
{
|
||||
[anIvar appendToString:resultString typeController:[self.classDump typeController] symbolReferences:symbolReferences];
|
||||
[ivar appendToString:resultString typeController:self.classDump.typeController symbolReferences:symbolReferences];
|
||||
[resultString appendString:@"\n"];
|
||||
}
|
||||
|
||||
- (void)_visitProperty:(CDOCProperty *)aProperty parsedType:(CDType *)parsedType attributes:(NSArray *)attrs;
|
||||
- (void)visitProperty:(CDOCProperty *)property;
|
||||
{
|
||||
CDType *parsedType = property.type;
|
||||
if (parsedType == nil) {
|
||||
if ([property.attributeString hasPrefix:@"T"]) {
|
||||
[resultString appendFormat:@"// Error parsing type for property %@:\n", property.name];
|
||||
[resultString appendFormat:@"// Property attributes: %@\n\n", property.attributeString];
|
||||
} else {
|
||||
[resultString appendFormat:@"// Error: Property attributes should begin with the type ('T') attribute, property name: %@\n", property.name];
|
||||
[resultString appendFormat:@"// Property attributes: %@\n\n", property.attributeString];
|
||||
}
|
||||
} else {
|
||||
[self _visitProperty:property parsedType:parsedType attributes:property.attributes];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didVisitPropertiesOfClass:(CDOCClass *)aClass;
|
||||
{
|
||||
#ifdef ADD_SPACE
|
||||
if ([aClass.properties count] > 0)
|
||||
[resultString appendString:@"\n"];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)willVisitPropertiesOfCategory:(CDOCCategory *)category;
|
||||
{
|
||||
#ifdef ADD_SPACE
|
||||
if ([category.properties count] > 0)
|
||||
[resultString appendString:@"\n"];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)didVisitPropertiesOfCategory:(CDOCCategory *)category;
|
||||
{
|
||||
#ifdef ADD_SPACE
|
||||
if ([category.properties count] > 0/* && [aCategory hasMethods]*/)
|
||||
[resultString appendString:@"\n"];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)willVisitPropertiesOfProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
#ifdef ADD_SPACE
|
||||
if ([protocol.properties count] > 0)
|
||||
[resultString appendString:@"\n"];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)didVisitPropertiesOfProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
#ifdef ADD_SPACE
|
||||
if ([protocol.properties count] > 0 /*&& [aProtocol hasMethods]*/)
|
||||
[resultString appendString:@"\n"];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)visitRemainingProperties:(CDVisitorPropertyState *)propertyState;
|
||||
{
|
||||
NSArray *remaining = propertyState.remainingProperties;
|
||||
|
||||
if ([remaining count] > 0) {
|
||||
[resultString appendString:@"\n"];
|
||||
[resultString appendFormat:@"// Remaining properties\n"];
|
||||
//NSLog(@"Warning: remaining undeclared property count: %u", [remaining count]);
|
||||
//NSLog(@"remaining: %@", remaining);
|
||||
for (CDOCProperty *property in remaining)
|
||||
[self visitProperty:property];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@synthesize resultString;
|
||||
@synthesize symbolReferences;
|
||||
|
||||
- (void)writeResultToStandardOutput;
|
||||
{
|
||||
NSData *data = [resultString dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[(NSFileHandle *)[NSFileHandle fileHandleWithStandardOutput] writeData:data];
|
||||
}
|
||||
|
||||
- (void)_visitProperty:(CDOCProperty *)property parsedType:(CDType *)parsedType attributes:(NSArray *)attrs;
|
||||
{
|
||||
NSString *backingVar = nil;
|
||||
BOOL isWeak = NO;
|
||||
BOOL isDynamic = NO;
|
||||
|
||||
|
||||
NSMutableArray *alist = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *unknownAttrs = [[NSMutableArray alloc] init];
|
||||
|
||||
|
||||
// objc_v2_encode_prop_attr() in gcc/objc/objc-act.c
|
||||
|
||||
|
||||
for (NSString *attr in attrs) {
|
||||
if ([attr hasPrefix:@"T"]) {
|
||||
if (debug) NSLog(@"Warning: Property attribute 'T' should occur only occur at the beginning");
|
||||
@ -216,113 +293,41 @@ static BOOL debug = NO;
|
||||
[unknownAttrs addObject:attr];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ([alist count] > 0) {
|
||||
[resultString appendFormat:@"@property(%@) ", [alist componentsJoinedByString:@", "]];
|
||||
} else {
|
||||
[resultString appendString:@"@property "];
|
||||
}
|
||||
|
||||
|
||||
if (isWeak)
|
||||
[resultString appendString:@"__weak "];
|
||||
|
||||
NSString *formattedString = [[[self.classDump typeController] propertyTypeFormatter] formatVariable:[aProperty name] parsedType:parsedType symbolReferences:symbolReferences];
|
||||
|
||||
NSString *formattedString = [self.classDump.typeController.propertyTypeFormatter formatVariable:property.name parsedType:parsedType symbolReferences:symbolReferences];
|
||||
[resultString appendFormat:@"%@;", formattedString];
|
||||
|
||||
|
||||
if (isDynamic) {
|
||||
[resultString appendFormat:@" // @dynamic %@;", [aProperty name]];
|
||||
[resultString appendFormat:@" // @dynamic %@;", property.name];
|
||||
} else if (backingVar != nil) {
|
||||
if ([backingVar isEqualToString:[aProperty name]]) {
|
||||
[resultString appendFormat:@" // @synthesize %@;", [aProperty name]];
|
||||
if ([backingVar isEqualToString:property.name]) {
|
||||
[resultString appendFormat:@" // @synthesize %@;", property.name];
|
||||
} else {
|
||||
[resultString appendFormat:@" // @synthesize %@=%@;", [aProperty name], backingVar];
|
||||
[resultString appendFormat:@" // @synthesize %@=%@;", property.name, backingVar];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[resultString appendString:@"\n"];
|
||||
if ([unknownAttrs count] > 0) {
|
||||
[resultString appendFormat:@"// Preceding property had unknown attributes: %@\n", [unknownAttrs componentsJoinedByString:@","]];
|
||||
if ([[aProperty attributeString] length] > 80) {
|
||||
[resultString appendFormat:@"// Original attribute string (following type): %@\n\n", [aProperty attributeStringAfterType]];
|
||||
if ([property.attributeString length] > 80) {
|
||||
[resultString appendFormat:@"// Original attribute string (following type): %@\n\n", property.attributeStringAfterType];
|
||||
} else {
|
||||
[resultString appendFormat:@"// Original attribute string: %@\n\n", [aProperty attributeString]];
|
||||
[resultString appendFormat:@"// Original attribute string: %@\n\n", property.attributeString];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[alist release];
|
||||
[unknownAttrs release];
|
||||
}
|
||||
|
||||
- (void)visitProperty:(CDOCProperty *)aProperty;
|
||||
{
|
||||
CDType *parsedType = [aProperty type];
|
||||
if (parsedType == nil) {
|
||||
if ([[aProperty attributeString] hasPrefix:@"T"]) {
|
||||
[resultString appendFormat:@"// Error parsing type for property %@:\n", [aProperty name]];
|
||||
[resultString appendFormat:@"// Property attributes: %@\n\n", [aProperty attributeString]];
|
||||
} else {
|
||||
[resultString appendFormat:@"// Error: Property attributes should begin with the type ('T') attribute, property name: %@\n", [aProperty name]];
|
||||
[resultString appendFormat:@"// Property attributes: %@\n\n", [aProperty attributeString]];
|
||||
}
|
||||
} else {
|
||||
[self _visitProperty:aProperty parsedType:parsedType attributes:[aProperty attributes]];
|
||||
}
|
||||
}
|
||||
|
||||
#define ADD_SPACE
|
||||
|
||||
- (void)didVisitPropertiesOfClass:(CDOCClass *)aClass;
|
||||
{
|
||||
#ifdef ADD_SPACE
|
||||
if ([[aClass properties] count] > 0)
|
||||
[resultString appendString:@"\n"];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)willVisitPropertiesOfCategory:(CDOCCategory *)aCategory;
|
||||
{
|
||||
#ifdef ADD_SPACE
|
||||
if ([[aCategory properties] count] > 0)
|
||||
[resultString appendString:@"\n"];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)didVisitPropertiesOfCategory:(CDOCCategory *)aCategory;
|
||||
{
|
||||
#ifdef ADD_SPACE
|
||||
if ([[aCategory properties] count] > 0/* && [aCategory hasMethods]*/)
|
||||
[resultString appendString:@"\n"];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)willVisitPropertiesOfProtocol:(CDOCProtocol *)aProtocol;
|
||||
{
|
||||
#ifdef ADD_SPACE
|
||||
if ([[aProtocol properties] count] > 0)
|
||||
[resultString appendString:@"\n"];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)didVisitPropertiesOfProtocol:(CDOCProtocol *)aProtocol;
|
||||
{
|
||||
#ifdef ADD_SPACE
|
||||
if ([[aProtocol properties] count] > 0 /*&& [aProtocol hasMethods]*/)
|
||||
[resultString appendString:@"\n"];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)visitRemainingProperties:(CDVisitorPropertyState *)propertyState;
|
||||
{
|
||||
NSArray *remaining = [propertyState remainingProperties];
|
||||
|
||||
if ([remaining count] > 0) {
|
||||
[resultString appendString:@"\n"];
|
||||
[resultString appendFormat:@"// Remaining properties\n"];
|
||||
//NSLog(@"Warning: remaining undeclared property count: %u", [remaining count]);
|
||||
//NSLog(@"remaining: %@", remaining);
|
||||
for (CDOCProperty *property in remaining)
|
||||
[self visitProperty:property];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -15,15 +15,15 @@
|
||||
- (void)willBeginVisiting;
|
||||
- (void)didEndVisiting;
|
||||
|
||||
- (void)willVisitObjectiveCProcessor:(CDObjectiveCProcessor *)aProcessor;
|
||||
- (void)visitObjectiveCProcessor:(CDObjectiveCProcessor *)aProcessor;
|
||||
- (void)didVisitObjectiveCProcessor:(CDObjectiveCProcessor *)aProcessor;
|
||||
- (void)willVisitObjectiveCProcessor:(CDObjectiveCProcessor *)processor;
|
||||
- (void)visitObjectiveCProcessor:(CDObjectiveCProcessor *)processor;
|
||||
- (void)didVisitObjectiveCProcessor:(CDObjectiveCProcessor *)processor;
|
||||
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)didVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)protocol;
|
||||
- (void)didVisitProtocol:(CDOCProtocol *)protocol;
|
||||
|
||||
- (void)willVisitPropertiesOfProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)didVisitPropertiesOfProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)willVisitPropertiesOfProtocol:(CDOCProtocol *)protocol;
|
||||
- (void)didVisitPropertiesOfProtocol:(CDOCProtocol *)protocol;
|
||||
|
||||
- (void)willVisitOptionalMethods;
|
||||
- (void)didVisitOptionalMethods;
|
||||
@ -37,16 +37,16 @@
|
||||
- (void)willVisitPropertiesOfClass:(CDOCClass *)aClass;
|
||||
- (void)didVisitPropertiesOfClass:(CDOCClass *)aClass;
|
||||
|
||||
- (void)willVisitCategory:(CDOCCategory *)aCategory;
|
||||
- (void)didVisitCategory:(CDOCCategory *)aCategory;
|
||||
- (void)willVisitCategory:(CDOCCategory *)category;
|
||||
- (void)didVisitCategory:(CDOCCategory *)category;
|
||||
|
||||
- (void)willVisitPropertiesOfCategory:(CDOCCategory *)aCategory;
|
||||
- (void)didVisitPropertiesOfCategory:(CDOCCategory *)aCategory;
|
||||
- (void)willVisitPropertiesOfCategory:(CDOCCategory *)category;
|
||||
- (void)didVisitPropertiesOfCategory:(CDOCCategory *)category;
|
||||
|
||||
- (void)visitClassMethod:(CDOCMethod *)aMethod;
|
||||
- (void)visitInstanceMethod:(CDOCMethod *)aMethod propertyState:(CDVisitorPropertyState *)propertyState;
|
||||
- (void)visitIvar:(CDOCIvar *)anIvar;
|
||||
- (void)visitProperty:(CDOCProperty *)aProperty;
|
||||
- (void)visitClassMethod:(CDOCMethod *)method;
|
||||
- (void)visitInstanceMethod:(CDOCMethod *)method propertyState:(CDVisitorPropertyState *)propertyState;
|
||||
- (void)visitIvar:(CDOCIvar *)ivar;
|
||||
- (void)visitProperty:(CDOCProperty *)property;
|
||||
|
||||
- (void)visitRemainingProperties:(CDVisitorPropertyState *)propertyState;
|
||||
|
||||
|
@ -15,15 +15,6 @@
|
||||
CDClassDump *classDump;
|
||||
}
|
||||
|
||||
- (id)init;
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
classDump = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc;
|
||||
{
|
||||
[classDump release];
|
||||
@ -44,20 +35,20 @@
|
||||
}
|
||||
|
||||
// Called before visiting.
|
||||
- (void)willVisitObjectiveCProcessor:(CDObjectiveCProcessor *)aProcessor;
|
||||
- (void)willVisitObjectiveCProcessor:(CDObjectiveCProcessor *)processor;
|
||||
{
|
||||
}
|
||||
|
||||
// This gets called before visiting the children, but only if it has children it will visit.
|
||||
- (void)visitObjectiveCProcessor:(CDObjectiveCProcessor *)aProcessor;
|
||||
- (void)visitObjectiveCProcessor:(CDObjectiveCProcessor *)processor;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)willVisitPropertiesOfProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)willVisitPropertiesOfProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)didVisitPropertiesOfProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)didVisitPropertiesOfProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
}
|
||||
|
||||
@ -70,15 +61,15 @@
|
||||
}
|
||||
|
||||
// Called after visiting.
|
||||
- (void)didVisitObjectiveCProcessor:(CDObjectiveCProcessor *)aProcessor;
|
||||
- (void)didVisitObjectiveCProcessor:(CDObjectiveCProcessor *)processor;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)willVisitProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)didVisitProtocol:(CDOCProtocol *)aProtocol;
|
||||
- (void)didVisitProtocol:(CDOCProtocol *)protocol;
|
||||
{
|
||||
}
|
||||
|
||||
@ -106,35 +97,35 @@
|
||||
{
|
||||
}
|
||||
|
||||
- (void)willVisitCategory:(CDOCCategory *)aCategory;
|
||||
- (void)willVisitCategory:(CDOCCategory *)category;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)didVisitCategory:(CDOCCategory *)aCategory;
|
||||
- (void)didVisitCategory:(CDOCCategory *)category;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)willVisitPropertiesOfCategory:(CDOCCategory *)aCategory;
|
||||
- (void)willVisitPropertiesOfCategory:(CDOCCategory *)category;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)didVisitPropertiesOfCategory:(CDOCCategory *)aCategory;
|
||||
- (void)didVisitPropertiesOfCategory:(CDOCCategory *)category;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)visitClassMethod:(CDOCMethod *)aMethod;
|
||||
- (void)visitClassMethod:(CDOCMethod *)method;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)visitInstanceMethod:(CDOCMethod *)aMethod propertyState:(CDVisitorPropertyState *)propertyState;
|
||||
- (void)visitInstanceMethod:(CDOCMethod *)method propertyState:(CDVisitorPropertyState *)propertyState;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)visitIvar:(CDOCIvar *)anIvar;
|
||||
- (void)visitIvar:(CDOCIvar *)ivar;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)visitProperty:(CDOCProperty *)aProperty;
|
||||
- (void)visitProperty:(CDOCProperty *)property;
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,6 @@
|
||||
- (BOOL)hasUsedProperty:(CDOCProperty *)property;
|
||||
- (void)useProperty:(CDOCProperty *)property;
|
||||
|
||||
- (NSArray *)remainingProperties;
|
||||
@property (nonatomic, readonly) NSArray *remainingProperties;
|
||||
|
||||
@end
|
||||
|
@ -315,7 +315,7 @@ int main(int argc, char *argv[])
|
||||
if (shouldFind) {
|
||||
CDFindMethodVisitor *visitor = [[CDFindMethodVisitor alloc] init];
|
||||
visitor.classDump = classDump;
|
||||
visitor.findString = searchString;
|
||||
visitor.searchString = searchString;
|
||||
[classDump recursivelyVisit:visitor];
|
||||
[visitor release];
|
||||
} else if (shouldGenerateSeparateHeaders) {
|
||||
|
Loading…
Reference in New Issue
Block a user