forked from nygard/class-dump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDOCCategory.m
97 lines (71 loc) · 2.4 KB
/
CDOCCategory.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// -*- mode: ObjC -*-
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-1998, 2000-2001, 2004-2009 Steve Nygard.
#import "CDOCCategory.h"
#import "CDClassDump.h"
#import "CDOCMethod.h"
#import "CDSymbolReferences.h"
#import "NSArray-Extensions.h"
#import "CDVisitor.h"
#import "CDVisitorPropertyState.h"
@implementation CDOCCategory
- (void)dealloc;
{
[className release];
[super dealloc];
}
- (NSString *)className;
{
return className;
}
- (void)setClassName:(NSString *)newClassName;
{
if (newClassName == className)
return;
[className release];
className = [newClassName retain];
}
- (NSString *)sortableName;
{
return [NSString stringWithFormat:@"%@ (%@)", className, name];
}
- (NSString *)findTag:(CDSymbolReferences *)symbolReferences;
{
NSMutableString *resultString = [NSMutableString string];
[resultString appendFormat:@"@interface %@ (%@)", className, name];
if ([protocols count] > 0)
[resultString appendFormat:@" <%@>", [[protocols arrayByMappingSelector:@selector(name)] componentsJoinedByString:@", "]];
return resultString;
}
- (void)recursivelyVisit:(CDVisitor *)aVisitor;
{
CDVisitorPropertyState *propertyState;
if ([[aVisitor classDump] shouldMatchRegex] && [[aVisitor classDump] regexMatchesString:[self name]] == NO)
return;
// Wonderful. Need to typecast because there's also -[NSHTTPCookie initWithProperties:] that takes a dictionary.
propertyState = [(CDVisitorPropertyState *)[CDVisitorPropertyState alloc] initWithProperties:[self properties]];
[aVisitor willVisitCategory:self];
//[aVisitor willVisitPropertiesOfCategory:self];
//[self visitProperties:aVisitor];
//[aVisitor didVisitPropertiesOfCategory:self];
[self visitMethods:aVisitor propertyState:propertyState];
// This can happen when... the accessors are implemented on the main class. Odd case, but we should still emit the remaining properties.
// Should mostly be dynamic properties
[aVisitor visitRemainingProperties:propertyState];
[aVisitor didVisitCategory:self];
[propertyState release];
}
//
// CDTopologicalSort protocol
//
- (NSString *)identifier;
{
return [self sortableName];
}
- (NSArray *)dependancies;
{
if (className == nil)
return [NSArray array];
return [NSArray arrayWithObject:className];
}
@end