From 9d492ed8ed5627bcac0b20d1b0d8e0e440fab044 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 30 Nov 2008 19:09:23 -0500 Subject: [PATCH] Add the StackController class * Source/StackController.m+h: New files * MacGDBp.xcodeproj: Project updates for new files --- MacGDBp.xcodeproj/project.pbxproj | 6 +++ Source/StackController.h | 33 ++++++++++++++++ Source/StackController.m | 64 +++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 Source/StackController.h create mode 100644 Source/StackController.m diff --git a/MacGDBp.xcodeproj/project.pbxproj b/MacGDBp.xcodeproj/project.pbxproj index 20b5c4d..a5c7d59 100644 --- a/MacGDBp.xcodeproj/project.pbxproj +++ b/MacGDBp.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 1E9583200E2531BD001A3D89 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E95831F0E2531BD001A3D89 /* Sparkle.framework */; }; 1E95834C0E2531D5001A3D89 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1E95831F0E2531BD001A3D89 /* Sparkle.framework */; }; 1EB7BED50ECF3CA90033283A /* StackFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EB7BED40ECF3CA90033283A /* StackFrame.m */; }; + 1EBF4D5D0EE35F0700B62769 /* StackController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EBF4D5C0EE35F0700B62769 /* StackController.m */; }; 1EEBFBE50D34C793008F835B /* Debugger.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1EEBFBE30D34C793008F835B /* Debugger.xib */; }; 1EEBFC2B0D358EBD008F835B /* StepIn.png in Resources */ = {isa = PBXBuildFile; fileRef = 1EEBFC2A0D358EBD008F835B /* StepIn.png */; }; 1EEBFC370D358F1B008F835B /* StepOut.png in Resources */ = {isa = PBXBuildFile; fileRef = 1EEBFC360D358F1B008F835B /* StepOut.png */; }; @@ -88,6 +89,8 @@ 1E95831F0E2531BD001A3D89 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = ""; }; 1EB7BED30ECF3CA90033283A /* StackFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StackFrame.h; path = Source/StackFrame.h; sourceTree = ""; }; 1EB7BED40ECF3CA90033283A /* StackFrame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StackFrame.m; path = Source/StackFrame.m; sourceTree = ""; }; + 1EBF4D5B0EE35F0700B62769 /* StackController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StackController.h; path = Source/StackController.h; sourceTree = ""; }; + 1EBF4D5C0EE35F0700B62769 /* StackController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StackController.m; path = Source/StackController.m; sourceTree = ""; }; 1EEBFBE40D34C793008F835B /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/Debugger.xib; sourceTree = ""; }; 1EEBFC2A0D358EBD008F835B /* StepIn.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = StepIn.png; path = Icons/StepIn.png; sourceTree = ""; }; 1EEBFC360D358F1B008F835B /* StepOut.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = StepOut.png; path = Icons/StepOut.png; sourceTree = ""; }; @@ -241,6 +244,8 @@ 1E02C5F50C610724006F1752 /* DebuggerController.m */, 1EB7BED30ECF3CA90033283A /* StackFrame.h */, 1EB7BED40ECF3CA90033283A /* StackFrame.m */, + 1EBF4D5B0EE35F0700B62769 /* StackController.h */, + 1EBF4D5C0EE35F0700B62769 /* StackController.m */, ); name = Debugger; sourceTree = ""; @@ -389,6 +394,7 @@ 1EFF70C30DFDC018006B9D33 /* BreakpointController.m in Sources */, 1E9582670E2524AD001A3D89 /* PreferencesController.m in Sources */, 1EB7BED50ECF3CA90033283A /* StackFrame.m in Sources */, + 1EBF4D5D0EE35F0700B62769 /* StackController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/StackController.h b/Source/StackController.h new file mode 100644 index 0000000..fe58dda --- /dev/null +++ b/Source/StackController.h @@ -0,0 +1,33 @@ +/* + * MacGDBp + * Copyright (c) 2007 - 2008, Blue Static + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; if not, + * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#import +#import "StackFrame.h" + +@interface StackController : NSObject +{ + /** + * Array of StackFrame's (LIFO stack) + */ + NSMutableArray *stack; +} + +@property(readonly) NSMutableArray *stack; + +- (StackFrame *)pop; +- (void)push:(StackFrame *)frame; + +@end diff --git a/Source/StackController.m b/Source/StackController.m new file mode 100644 index 0000000..2caea7d --- /dev/null +++ b/Source/StackController.m @@ -0,0 +1,64 @@ +/* + * MacGDBp + * Copyright (c) 2007 - 2008, Blue Static + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; if not, + * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#import "StackController.h" + + +@implementation StackController + +@synthesize stack; + +/** + * Constructor + */ +- (id)init +{ + if (self = [super init]) + { + stack = [[NSMutableArray alloc] init]; + } + return self; +} + +/** + * Destructor + */ +- (void)dealloc +{ + [stack release]; + [super dealloc]; +} + +/** + * Pops the current frame off the stack and returns the frame + */ +- (StackFrame *)pop +{ + StackFrame *frame = [stack lastObject]; + if (frame != nil) + [stack removeLastObject]; + return frame; +} + +/** + * Pushes a frame onto the end of the stack + */ +- (void)push:(StackFrame *)frame +{ + [stack insertObject:frame atIndex:[stack count]]; +} + +@end -- 2.22.5