Create string constants for all preference names.
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 10 Apr 2016 16:37:48 +0000 (12:37 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 10 Apr 2016 16:37:48 +0000 (12:37 -0400)
MacGDBp.xcodeproj/project.pbxproj
Source/AppDelegate.m
Source/Breakpoint.m
Source/BreakpointController.m
Source/BreakpointManager.m
Source/DebuggerController.m
Source/PreferenceNames.h [new file with mode: 0644]
Source/PreferenceNames.m [new file with mode: 0644]

index 595735fb3a6c845e6028ae643d8dd00fa18c295a..075aefeb9e3c92f60961619fec22ff7897aaaae4 100644 (file)
@@ -21,6 +21,7 @@
                1E1E53030DF9B89800D334F9 /* Breakpoints.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1E1E53010DF9B89800D334F9 /* Breakpoints.xib */; };
                1E2F0A6912D5371C00EBF675 /* Stop.png in Resources */ = {isa = PBXBuildFile; fileRef = 1E2F0A6812D5371B00EBF675 /* Stop.png */; };
                1E35FC760C6579CA0030F527 /* NSXMLElementAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E35FC750C6579CA0030F527 /* NSXMLElementAdditions.m */; };
+               1E3F9D941CBAB57B005D896B /* PreferenceNames.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E3F9D931CBAB57B005D896B /* PreferenceNames.m */; };
                1E416FF90D36F821009A53A2 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1E416FF60D36F821009A53A2 /* MainMenu.xib */; };
                1E42F1D70F53317B008412DB /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 1E42F1D60F53317B008412DB /* dsa_pub.pem */; };
                1E4C7AF90DA401C7000A9DC7 /* BreakpointManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E4C7AF80DA401C7000A9DC7 /* BreakpointManager.m */; };
                1E2F0A6812D5371B00EBF675 /* Stop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Stop.png; path = Icons/Stop.png; sourceTree = "<group>"; };
                1E35FC750C6579CA0030F527 /* NSXMLElementAdditions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = NSXMLElementAdditions.m; path = Source/NSXMLElementAdditions.m; sourceTree = "<group>"; };
                1E35FFB00C65A74C0030F527 /* NSXMLElementAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSXMLElementAdditions.h; path = Source/NSXMLElementAdditions.h; sourceTree = "<group>"; };
+               1E3F9D931CBAB57B005D896B /* PreferenceNames.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PreferenceNames.m; path = Source/PreferenceNames.m; sourceTree = "<group>"; };
+               1E3F9D951CBAB589005D896B /* PreferenceNames.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PreferenceNames.h; path = Source/PreferenceNames.h; sourceTree = "<group>"; };
                1E416FF70D36F821009A53A2 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
                1E42F1D60F53317B008412DB /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = "<group>"; };
                1E4C7AF70DA401C7000A9DC7 /* BreakpointManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BreakpointManager.h; path = Source/BreakpointManager.h; sourceTree = "<group>"; };
                1E9582640E252480001A3D89 /* Preferences */ = {
                        isa = PBXGroup;
                        children = (
+                               1E3F9D951CBAB589005D896B /* PreferenceNames.h */,
+                               1E3F9D931CBAB57B005D896B /* PreferenceNames.m */,
                                1E9582650E2524AD001A3D89 /* PreferencesController.h */,
                                1E9582660E2524AD001A3D89 /* PreferencesController.m */,
                                1E67E6FB0F3C052000E68F1B /* PreferencesPathsArrayController.h */,
                                1E02C5710C610158006F1752 /* DebuggerBackEnd.m in Sources */,
                                1E02C5F60C610724006F1752 /* DebuggerController.m in Sources */,
                                1E35FC760C6579CA0030F527 /* NSXMLElementAdditions.m in Sources */,
+                               1E3F9D941CBAB57B005D896B /* PreferenceNames.m in Sources */,
                                1E7188690D839F6300969277 /* BSSourceView.mm in Sources */,
                                1E822CDD0DA28AC30027A23F /* Breakpoint.m in Sources */,
                                1E4C7AF90DA401C7000A9DC7 /* BreakpointManager.m in Sources */,
index d3ab27bc7b07f27ae5ec5c2cce390573a5282178..7e398385c3bdbb7aa4c1e256df03d9723d8c155c 100644 (file)
@@ -18,6 +18,8 @@
 
 #import <Sparkle/Sparkle.h>
 
+#import "PreferenceNames.h"
+
 @implementation AppDelegate
 
 @synthesize debugger;
 {
   @autoreleasepool {
     NSDictionary* defaults = @{
-      @"Port"                     : @9000,
-      @"BreakpointsWindowVisible" : @YES,
-      @"InspectorWindowVisible"   : @YES,
-      @"PathReplacements"         : [NSMutableArray array],
-      @"BreakOnFirstLine"         : @YES,
-      @"DebuggerAttached"         : @YES
+      kPrefPort                     : @9000,
+      kPrefBreakpointsWindowVisible : @YES,
+      kPrefInspectorWindowVisible   : @YES,
+      kPrefPathReplacements         : [NSMutableArray array],
+      kPrefBreakOnFirstLine         : @YES,
+      kPrefDebuggerAttached         : @YES
     };
     [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
   }
   // Record whether this user ever used the beta VersionCast feed. In the
   // future, we will use this bit to query for unstable releases after the user
   // has upgraded to a stable version.
-  NSString* const kUsesUnstableVersionCast = @"UnstableVersionCast";
   NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
 
-  BOOL usesUnstable = [defaults boolForKey:kUsesUnstableVersionCast];
+  BOOL usesUnstable = [defaults boolForKey:kPrefUnstableVersionCast];
   NSURL* feedURL = [[SUUpdater sharedUpdater] feedURL];
   usesUnstable = usesUnstable ||
       [[feedURL absoluteString] rangeOfString:@"?unstable"].location != NSNotFound;
-  [defaults setBool:usesUnstable forKey:kUsesUnstableVersionCast];
+  [defaults setBool:usesUnstable forKey:kPrefUnstableVersionCast];
 }
 
 - (void)applicationWillTerminate:(NSNotification*)notification
 {
   [[NSUserDefaults standardUserDefaults] setBool:self.debugger.connection.autoAttach
-                                          forKey:@"DebuggerAttached"];
+                                          forKey:kPrefDebuggerAttached];
 }
 
 /**
index 7f70153ec48826097a7a8b884e0e234617d4580e..1629a6580aa97168686c999da463372324474bab 100644 (file)
@@ -16,6 +16,7 @@
 
 #import "Breakpoint.h"
 
+#import "PreferenceNames.h"
 
 @implementation Breakpoint
 
@@ -65,7 +66,7 @@
 {
   NSString* path = self.file;
   
-  NSMutableArray* transforms = [[NSUserDefaults standardUserDefaults] mutableArrayValueForKey:@"PathReplacements"];
+  NSMutableArray* transforms = [[NSUserDefaults standardUserDefaults] mutableArrayValueForKey:kPrefPathReplacements];
   if (!transforms || [transforms count] < 1)
     return path;
   
index 382d7ecb135834a5341f167c66b0e62ef35a263f..34a52a1c4243d21655de2990c284c8ce1c166ed2 100644 (file)
@@ -17,6 +17,7 @@
 #import "BreakpointController.h"
 
 #import "AppDelegate.h"
+#import "PreferenceNames.h"
 
 @implementation BreakpointController
 
@@ -30,7 +31,7 @@
   if (self = [super initWithWindowNibName:@"Breakpoints"])
   {
     manager = [BreakpointManager sharedManager];
-    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"BreakpointsWindowVisible"])
+    if ([[NSUserDefaults standardUserDefaults] boolForKey:kPrefBreakpointsWindowVisible])
       [[self window] orderBack:nil];
   }
   return self;
index 76a540c472bca839a6053f8ef896c1f4cbcec9d0..1301ae5c5039ab83ecd1be1b9d5f0e474b5ca24e 100644 (file)
@@ -15,7 +15,9 @@
  */
 
 #import "BreakpointManager.h"
+
 #import "AppDelegate.h"
+#import "PreferenceNames.h"
 
 @interface BreakpointManager (Private)
 - (void)updateDisplaysForFile:(NSString*)file;
@@ -37,7 +39,7 @@
       breakpoints = [[NSMutableArray alloc] init];
     }
     
-    savedBreakpoints = [[[NSUserDefaults standardUserDefaults] arrayForKey:@"Breakpoints"] mutableCopy];
+    savedBreakpoints = [[[NSUserDefaults standardUserDefaults] arrayForKey:kPrefBreakpoints] mutableCopy];
     if (savedBreakpoints)
     {
       for (NSDictionary* d in savedBreakpoints)
@@ -77,7 +79,7 @@
     [connection addBreakpoint:bp];
     
     [savedBreakpoints addObject:[bp dictionary]];
-    [[NSUserDefaults standardUserDefaults] setObject:savedBreakpoints forKey:@"Breakpoints"];
+    [[NSUserDefaults standardUserDefaults] setObject:savedBreakpoints forKey:kPrefBreakpoints];
     
     [self updateDisplaysForFile:[bp file]];
   }
@@ -96,7 +98,7 @@
       [connection removeBreakpoint:b];
       
       [savedBreakpoints removeObject:[b dictionary]];
-      [[NSUserDefaults standardUserDefaults] setObject:savedBreakpoints forKey:@"Breakpoints"];
+      [[NSUserDefaults standardUserDefaults] setObject:savedBreakpoints forKey:kPrefBreakpoints];
       
       [self updateDisplaysForFile:file];
       return b;
index 3037ae450225c0bbd1d626c8c80aecc255b26825..9bba07e2f09114c303ef521bef6cefa55ea65ec4 100644 (file)
@@ -22,6 +22,7 @@
 #import "DebuggerBackEnd.h"
 #import "DebuggerModel.h"
 #import "EvalController.h"
+#import "PreferenceNames.h"
 #import "NSXMLElementAdditions.h"
 #import "StackFrame.h"
 
                 options:NSKeyValueObservingOptionNew
                 context:nil];
 
-    connection = [[DebuggerBackEnd alloc] initWithPort:[defaults integerForKey:@"Port"]
-                                            autoAttach:[defaults boolForKey:@"DebuggerAttached"]];
+    connection = [[DebuggerBackEnd alloc] initWithPort:[defaults integerForKey:kPrefPort]
+                                            autoAttach:[defaults boolForKey:kPrefDebuggerAttached]];
     connection.model = _model;
     expandedVariables = [[NSMutableSet alloc] init];
     [[self window] makeKeyAndOrderFront:nil];
     [[self window] setDelegate:self];
     
-    if ([defaults boolForKey:@"InspectorWindowVisible"])
+    if ([defaults boolForKey:kPrefInspectorWindowVisible])
       [inspector orderFront:self];
   }
   return self;
   [errormsg setHidden:YES];
   if (!self.connection.autoAttach)
     return;
-  if ([[NSUserDefaults standardUserDefaults] boolForKey:@"BreakOnFirstLine"])
+  if ([[NSUserDefaults standardUserDefaults] boolForKey:kPrefBreakOnFirstLine])
     [self stepIn:self];
   // Do not cache the file between debugger executions.
   sourceViewer.file = nil;
diff --git a/Source/PreferenceNames.h b/Source/PreferenceNames.h
new file mode 100644 (file)
index 0000000..0a1b5ef
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * MacGDBp
+ * Copyright (c) 2016, Blue Static <https://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
+ */
+
+@class NSString;
+
+// NSNumber integer for the port to listen on.
+extern NSString* const kPrefPort;
+
+// NSNumber bool for whether the breakpoints window is visible.
+extern NSString* const kPrefBreakpointsWindowVisible;
+
+// NSNumber bool for whether the inspector window is visible.
+extern NSString* const kPrefInspectorWindowVisible;
+
+// NSMutableArray of path replacements.
+extern NSString* const kPrefPathReplacements;
+
+// NSNumber bool for whether to stop the debugger on the first line of the
+// program.
+extern NSString* const kPrefBreakOnFirstLine;
+
+// NSNumber bool for whether the debugger is currently listening/attached.
+extern NSString* const kPrefDebuggerAttached;
+
+// NSNumber bool for whether the app ever reported as an unstable version in
+// update checks. This will let the user download future unstable versions.
+extern NSString* const kPrefUnstableVersionCast;
+
+// NSMutableArray of breakpoints.
+extern NSString* const kPrefBreakpoints;
diff --git a/Source/PreferenceNames.m b/Source/PreferenceNames.m
new file mode 100644 (file)
index 0000000..1c398ef
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * MacGDBp
+ * Copyright (c) 2016, Blue Static <https://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 <Foundation/Foundation.h>
+
+NSString* const kPrefPort = @"Port";
+
+NSString* const kPrefBreakpointsWindowVisible = @"BreakpointsWindowVisible";
+
+NSString* const kPrefInspectorWindowVisible = @"InspectorWindowVisible";
+
+NSString* const kPrefPathReplacements = @"PathReplacements";
+
+NSString* const kPrefBreakOnFirstLine = @"BreakOnFirstLine";
+
+NSString* const kPrefDebuggerAttached = @"DebuggerAttached";
+
+NSString* const kPrefUnstableVersionCast = @"UnstableVersionCast";
+
+NSString* const kPrefBreakpoints = @"Breakpoints";