-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathCDTypeName.m
73 lines (54 loc) · 1.53 KB
/
CDTypeName.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
// -*- mode: ObjC -*-
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-2019 Steve Nygard.
#import "CDTypeName.h"
@implementation CDTypeName
{
NSString *_name;
NSMutableArray *_templateTypes;
NSString *_suffix;
}
- (id)init;
{
if ((self = [super init])) {
_name = nil;
_templateTypes = [[NSMutableArray alloc] init];
_suffix = nil;
}
return self;
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone;
{
CDTypeName *copy = [[CDTypeName alloc] init];
copy.name = self.name;
copy.suffix = self.suffix;
for (CDTypeName *subtype in self.templateTypes) {
CDTypeName *subcopy = [subtype copy];
[copy.templateTypes addObject:subcopy];
}
return copy;
}
#pragma mark -
- (BOOL)isEqual:(id)otherObject;
{
if ([otherObject isKindOfClass:[self class]] == NO)
return NO;
return [[self description] isEqual:[otherObject description]];
}
#pragma mark - Debugging
- (NSString *)description;
{
if ([self.templateTypes count] == 0) {
return self.name ? self.name : @"";
}
if (self.suffix != nil)
return [NSString stringWithFormat:@"%@<%@>%@", self.name, [self.templateTypes componentsJoinedByString:@", "], self.suffix];
return [NSString stringWithFormat:@"%@<%@>", self.name, [self.templateTypes componentsJoinedByString:@", "]];
}
#pragma mark -
- (BOOL)isTemplateType;
{
return [self.templateTypes count] > 0;
}
@end