mirror of
https://github.com/VibeDarling/class-dump.git
synced 2026-11-15 09:48:10 -10:00
74 lines
1.5 KiB
Objective-C
74 lines
1.5 KiB
Objective-C
// -*- 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
|