blob: 7f20c91a78909edcbd3b0c3e128617f887f28646 [file] [log] [blame]
// -*- 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 "CDOCIvar.h"
#import <Foundation/Foundation.h>
#import "CDClassDump.h"
#import "CDTypeFormatter.h"
@implementation CDOCIvar
- (id)initWithName:(NSString *)aName type:(NSString *)aType offset:(NSUInteger)anOffset;
{
if ([super init] == nil)
return nil;
name = [aName retain];
type = [aType retain];
offset = anOffset;
return self;
}
- (void)dealloc;
{
[name release];
[type release];
[super dealloc];
}
- (NSString *)name;
{
return name;
}
- (NSString *)type;
{
return type;
}
- (NSUInteger)offset;
{
return offset;
}
- (NSString *)description;
{
return [NSString stringWithFormat:@"[%@] name: %@, type: '%@', offset: %lu",
NSStringFromClass([self class]), name, type, offset];
}
- (void)appendToString:(NSMutableString *)resultString classDump:(CDClassDump *)aClassDump symbolReferences:(CDSymbolReferences *)symbolReferences;
{
NSString *formattedString;
formattedString = [[aClassDump ivarTypeFormatter] formatVariable:name type:type symbolReferences:symbolReferences];
if (formattedString != nil) {
[resultString appendString:formattedString];
[resultString appendString:@";"];
if ([aClassDump shouldShowIvarOffsets]) {
[resultString appendFormat:@"\t// %d = 0x%x", offset, offset];
}
} else
[resultString appendFormat:@" // Error parsing type: %@, name: %@", type, name];
}
@end