forked from Polidea/ios-class-guard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDOCClass.m
124 lines (94 loc) · 2.75 KB
/
CDOCClass.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// -*- 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 "CDOCClass.h"
#import <Foundation/Foundation.h>
#import "NSArray-Extensions.h"
#import "CDClassDump.h"
#import "CDOCIvar.h"
#import "CDOCMethod.h"
#import "CDSymbolReferences.h"
#import "CDType.h"
#import "CDTypeParser.h"
#import "CDVisitor.h"
@implementation CDOCClass
- (void)dealloc;
{
[superClassName release];
[ivars release];
[super dealloc];
}
- (NSString *)superClassName;
{
return superClassName;
}
- (void)setSuperClassName:(NSString *)newSuperClassName;
{
if (newSuperClassName == superClassName)
return;
[superClassName release];
superClassName = [newSuperClassName retain];
}
- (NSArray *)ivars;
{
return ivars;
}
- (void)setIvars:(NSArray *)newIvars;
{
if (newIvars == ivars)
return;
[ivars release];
ivars = [newIvars retain];
}
- (void)registerStructuresWithObject:(id <CDStructureRegistration>)anObject phase:(int)phase;
{
CDTypeParser *parser;
[super registerStructuresWithObject:anObject phase:phase];
for (CDOCIvar *ivar in ivars) {
CDType *aType;
NSError *error;
parser = [[CDTypeParser alloc] initWithType:[ivar type]];
aType = [parser parseType:&error];
[aType phase:phase registerStructuresWithObject:anObject usedInMethod:NO];
[parser release];
}
}
- (NSString *)findTag:(CDSymbolReferences *)symbolReferences;
{
NSMutableString *resultString = [NSMutableString string];
[resultString appendFormat:@"@interface %@", name];
if (superClassName != nil)
[resultString appendFormat:@" : %@", superClassName];
if ([protocols count] > 0)
[resultString appendFormat:@" <%@>", [[protocols arrayByMappingSelector:@selector(name)] componentsJoinedByString:@", "]];
return resultString;
}
- (void)recursivelyVisit:(CDVisitor *)aVisitor;
{
if ([[aVisitor classDump] shouldMatchRegex] && [[aVisitor classDump] regexMatchesString:[self name]] == NO)
return;
[aVisitor willVisitClass:self];
[aVisitor willVisitIvarsOfClass:self];
for (CDOCIvar *ivar in ivars)
[aVisitor visitIvar:ivar];
[aVisitor didVisitIvarsOfClass:self];
[aVisitor willVisitPropertiesOfClass:self];
[self visitProperties:aVisitor];
[aVisitor didVisitPropertiesOfClass:self];
[self recursivelyVisitMethods:aVisitor];
[aVisitor didVisitClass:self];
}
//
// CDTopologicalSort protocol
//
- (NSString *)identifier;
{
return [self name];
}
- (NSArray *)dependancies;
{
if (superClassName == nil)
return [NSArray array];
return [NSArray arrayWithObject:superClassName];
}
@end