Add the StackController class
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 1 Dec 2008 00:09:23 +0000 (19:09 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 1 Dec 2008 00:09:23 +0000 (19:09 -0500)
* Source/StackController.m+h: New files
* MacGDBp.xcodeproj: Project updates for new files

MacGDBp.xcodeproj/project.pbxproj
Source/StackController.h [new file with mode: 0644]
Source/StackController.m [new file with mode: 0644]

index 20b5c4d5e4f8701eaa23d08ba93b20fb77822d0d..a5c7d598b6df284fdbd7b62a30b30db9b5b19f85 100644 (file)
@@ -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 = "<group>"; };
                1EB7BED30ECF3CA90033283A /* StackFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StackFrame.h; path = Source/StackFrame.h; sourceTree = "<group>"; };
                1EB7BED40ECF3CA90033283A /* StackFrame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StackFrame.m; path = Source/StackFrame.m; sourceTree = "<group>"; };
+               1EBF4D5B0EE35F0700B62769 /* StackController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StackController.h; path = Source/StackController.h; sourceTree = "<group>"; };
+               1EBF4D5C0EE35F0700B62769 /* StackController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StackController.m; path = Source/StackController.m; sourceTree = "<group>"; };
                1EEBFBE40D34C793008F835B /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/Debugger.xib; sourceTree = "<group>"; };
                1EEBFC2A0D358EBD008F835B /* StepIn.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = StepIn.png; path = Icons/StepIn.png; sourceTree = "<group>"; };
                1EEBFC360D358F1B008F835B /* StepOut.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = StepOut.png; path = Icons/StepOut.png; sourceTree = "<group>"; };
                                1E02C5F50C610724006F1752 /* DebuggerController.m */,
                                1EB7BED30ECF3CA90033283A /* StackFrame.h */,
                                1EB7BED40ECF3CA90033283A /* StackFrame.m */,
+                               1EBF4D5B0EE35F0700B62769 /* StackController.h */,
+                               1EBF4D5C0EE35F0700B62769 /* StackController.m */,
                        );
                        name = Debugger;
                        sourceTree = "<group>";
                                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 (file)
index 0000000..fe58dda
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * MacGDBp
+ * Copyright (c) 2007 - 2008, Blue Static <http://www.bluestatic.org>
+ * 
+ * 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 <Cocoa/Cocoa.h>
+#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 (file)
index 0000000..2caea7d
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * MacGDBp
+ * Copyright (c) 2007 - 2008, Blue Static <http://www.bluestatic.org>
+ * 
+ * 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