From 0823427a4412e9acf095cd5873e1bcc0753b9f40 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 8 Jul 2010 23:59:39 -0400 Subject: [PATCH] Make StackFrame a dumb data structure and remove its initializer. All properties are now read-write. This fixes two warnings produced by Clang-SA and avoids sticking an |+alloc|ed but non- |-init...|ed class inside the |stackFrames_| array. --- Source/DebuggerProcessor.m | 12 +++++------ Source/StackFrame.h | 27 ++++++++++--------------- Source/StackFrame.m | 41 ++++++++------------------------------ 3 files changed, 23 insertions(+), 57 deletions(-) diff --git a/Source/DebuggerProcessor.m b/Source/DebuggerProcessor.m index 42af132..3beee94 100644 --- a/Source/DebuggerProcessor.m +++ b/Source/DebuggerProcessor.m @@ -306,7 +306,7 @@ // Use the transaction ID to create a routing path. NSNumber* routingID = [connection_ sendCommandWithFormat:@"stack_get -d %d", i]; [self recordCallback:@selector(getStackFrame:) forTransaction:routingID]; - [stackFrames_ setObject:[StackFrame alloc] forKey:routingID]; + [stackFrames_ setObject:[[StackFrame new] autorelease] forKey:routingID]; } } @@ -330,12 +330,10 @@ NSXMLElement* xmlframe = [[[response rootElement] children] objectAtIndex:0]; // Initialize the stack frame. - [frame initWithIndex:[[[xmlframe attributeForName:@"level"] stringValue] intValue] - withFilename:[[xmlframe attributeForName:@"filename"] stringValue] - withSource:nil - atLine:[[[xmlframe attributeForName:@"lineno"] stringValue] intValue] - inFunction:[[xmlframe attributeForName:@"where"] stringValue] - withVariables:nil]; + frame.index = [[[xmlframe attributeForName:@"level"] stringValue] intValue]; + frame.filename = [[xmlframe attributeForName:@"filename"] stringValue]; + frame.lineNumber = [[[xmlframe attributeForName:@"lineno"] stringValue] intValue]; + frame.function = [[xmlframe attributeForName:@"where"] stringValue]; frame.routingID = routingID; // Only get the complete frame for the first level. The other frames will get diff --git a/Source/StackFrame.h b/Source/StackFrame.h index 591d8e0..5c1926f 100644 --- a/Source/StackFrame.h +++ b/Source/StackFrame.h @@ -31,50 +31,43 @@ /** * The position in the stack */ - int index; + NSUInteger index_; /** * File the current frame is in */ - NSString* filename; + NSString* filename_; /** * Cached, highlighted version of the source */ - NSString* source; + NSString* source_; /** * Line number of the source the frame points to */ - int lineNumber; + NSUInteger lineNumber_; /** * Current-executing function */ - NSString* function; + NSString* function_; /** * Variable list */ - NSArray* variables; + NSArray* variables_; } @property BOOL loaded; @property NSUInteger routingID; -@property (readwrite) int index; -@property (readonly, copy) NSString* filename; +@property (readwrite) NSUInteger index; +@property (copy) NSString* filename; @property (copy) NSString* source; -@property (readwrite) int lineNumber; -@property (readwrite, copy) NSString* function; +@property (readwrite) NSUInteger lineNumber; +@property (copy) NSString* function; @property (retain) NSArray* variables; -- (id)initWithIndex:(int)anIndex - withFilename:(NSString*)aFilename - withSource:(NSString*)aSource - atLine:(int)aLineNumber - inFunction:(NSString*)function - withVariables:(NSArray*)variables; - - (BOOL)isShiftedFrame:(StackFrame*)frame; @end diff --git a/Source/StackFrame.m b/Source/StackFrame.m index bdb9193..2337f9a 100644 --- a/Source/StackFrame.m +++ b/Source/StackFrame.m @@ -16,41 +16,16 @@ #import "StackFrame.h" -/** - * Private class continuation - */ -@interface StackFrame() -@property(readwrite, copy) NSString* filename; -@end -/***/ - @implementation StackFrame @synthesize loaded = loaded_; @synthesize routingID = routingID_; -@synthesize index, filename, source, lineNumber, function, variables; - -/** - * Constructor - */ -- (id)initWithIndex:(int)anIndex - withFilename:(NSString*)aFilename - withSource:(NSString*)aSource - atLine:(int)aLineNumber - inFunction:(NSString*)aFunction - withVariables:(NSArray*)aVariables -{ - if (self = [super init]) - { - self.index = anIndex; - self.filename = aFilename; - self.source = aSource; - self.lineNumber = aLineNumber; - self.function = aFunction; - self.variables = aVariables; - } - return self; -} +@synthesize index = index_; +@synthesize filename = filename_; +@synthesize source = source_; +@synthesize lineNumber = lineNumber_; +@synthesize function = function_; +@synthesize variables = variables_; /** * Determines whether or not the given frame was shifted, rather than jumped. Essentially, @@ -58,7 +33,7 @@ */ - (BOOL)isShiftedFrame:(StackFrame*)frame { - return ([filename isEqualToString:frame.filename] && [function isEqualToString:frame.function]); + return ([self.filename isEqualToString:frame.filename] && [self.function isEqualToString:frame.function]); } /** @@ -66,7 +41,7 @@ */ - (NSString*)description { - return [NSString stringWithFormat:@"#%d %@ [%@:%d]", index, function, filename, lineNumber]; + return [NSString stringWithFormat:@"#%d %@ [%@:%d]", self.index, self.function, self.filename, self.lineNumber]; } @end -- 2.22.5