This fixes two warnings produced by Clang-SA and avoids sticking an |+alloc|ed but non-
|-init...|ed class inside the |stackFrames_| array.
// 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
/**
* 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
#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,
*/
- (BOOL)isShiftedFrame:(StackFrame*)frame
{
- return ([filename isEqualToString:frame.filename] && [function isEqualToString:frame.function]);
+ return ([self.filename isEqualToString:frame.filename] && [self.function isEqualToString:frame.function]);
}
/**
*/
- (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