Make StackFrame a dumb data structure and remove its initializer. All properties...
authorRobert Sesek <rsesek@bluestatic.org>
Fri, 9 Jul 2010 03:59:39 +0000 (23:59 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Fri, 9 Jul 2010 03:59:39 +0000 (23:59 -0400)
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
Source/StackFrame.h
Source/StackFrame.m

index 42af132843b03415138c87592b3c6e5a472d8dd7..3beee9457ed30e01af9c2ea80bdc6c3d8b7e38f8 100644 (file)
                // 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];
        }
 }
 
        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
index 591d8e000344dcc334b1add7105386ccdc5aaea4..5c1926f56e0b3832aac1440a47811c6a7e4fe9e2 100644 (file)
        /**
         * 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
index bdb9193a6da29772ad28bb458e29944385620093..2337f9ace01f65bfddc29327ee19ed50c50e396e 100644 (file)
 
 #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