Updated some deprecated code for the OSX version to compile under Snow

Leopard (10.6).  From this point on, the lowest supported version is
OSX 10.4.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1886 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-10-13 00:30:45 +00:00
parent f283052d36
commit 7a5b2c3661
8 changed files with 51 additions and 67 deletions

View File

@ -5,7 +5,7 @@
*/ */
/* $Id: AboutBox.m,v 1.2 2005-06-04 02:04:06 markgrebe Exp $ */ /* $Id: AboutBox.m,v 1.2 2005-06-04 02:04:06 markgrebe Exp $ */
#import "AboutBox.h"; #import "AboutBox.h"
@implementation AboutBox @implementation AboutBox

View File

@ -34,12 +34,12 @@ void releaseCmdKeys(NSString *character, int keyCode)
NSPoint point; NSPoint point;
event1 = [NSEvent keyEventWithType:NSKeyUp location:point modifierFlags:0 event1 = [NSEvent keyEventWithType:NSKeyUp location:point modifierFlags:0
timestamp:nil windowNumber:0 context:nil characters:character timestamp:0.0 windowNumber:0 context:nil characters:character
charactersIgnoringModifiers:character isARepeat:NO keyCode:keyCode]; charactersIgnoringModifiers:character isARepeat:NO keyCode:keyCode];
[NSApp postEvent:event1 atStart:NO]; [NSApp postEvent:event1 atStart:NO];
event2 = [NSEvent keyEventWithType:NSFlagsChanged location:point modifierFlags:0 event2 = [NSEvent keyEventWithType:NSFlagsChanged location:point modifierFlags:0
timestamp:nil windowNumber:0 context:nil characters:nil timestamp:0.0 windowNumber:0 context:nil characters:nil
charactersIgnoringModifiers:nil isARepeat:NO keyCode:0]; charactersIgnoringModifiers:nil isARepeat:NO keyCode:0];
[NSApp postEvent:event2 atStart:NO]; [NSApp postEvent:event2 atStart:NO];
} }

View File

@ -15,8 +15,8 @@
} }
+ (Preferences *)sharedInstance; + (Preferences *)sharedInstance;
- (void)setString:(char *)key:(char *)value; - (void)setString:(const char *)key:(const char *)value;
- (void)getString:(char *)key:(char *)value; - (void)getString:(const char *)key:(char *)value:(int)size;
- (void)save; - (void)save;
@end @end

View File

@ -13,14 +13,14 @@
#import "Preferences.h" #import "Preferences.h"
#import "SDL.h" #import "SDL.h"
void prefsSetString(char *key, char *value) void prefsSetString(const char* key, const char* value)
{ {
[[Preferences sharedInstance] setString:key:value]; [[Preferences sharedInstance] setString:key:value];
} }
void prefsGetString(char *key, char *value) void prefsGetString(const char* key, char* value, int size)
{ {
[[Preferences sharedInstance] getString:key:value]; [[Preferences sharedInstance] getString:key:value:size];
} }
void prefsSave(void) void prefsSave(void)
@ -43,31 +43,27 @@ static Preferences *sharedInstance = nil;
return(self); return(self);
} }
- (void)setString:(char *)key:(char *)value - (void)setString:(const char *)key:(const char *)value
{ {
NSNumber *theValue; NSString* theKey = [NSString stringWithCString:key encoding:NSASCIIStringEncoding];
NSString *theKey; NSString* theValue = [NSString stringWithCString:value encoding:NSASCIIStringEncoding];
theKey = [NSString stringWithCString:key]; [defaults setObject:theValue forKey:theKey];
theValue = [NSString stringWithCString:value]; [theKey release];
[defaults setObject:theValue forKey:theKey]; [theValue release];
[theKey release];
[theValue release];
} }
- (void)getString:(char *)key:(char *)value - (void)getString:(const char *)key:(char *)value:(int)size
{ {
NSString *theKey; NSString* theKey = [NSString stringWithCString:key encoding:NSASCIIStringEncoding];
NSString *theValue; NSString* theValue = [defaults objectForKey:theKey];
if (theValue != nil)
theKey = [NSString stringWithCString:key]; strncpy(value, [theValue cStringUsingEncoding: NSASCIIStringEncoding], size);
theValue = [defaults objectForKey:theKey]; else
if (theValue == nil) value[0] = 0;
value[0] = 0;
else { [theKey release];
[theValue getCString:value]; [theValue release];
[theKey release];
}
} }
- (void)save - (void)save

View File

@ -83,11 +83,10 @@ static SDLMain *sharedInstance = nil;
if ([menuItem hasSubmenu]) if ([menuItem hasSubmenu])
[self fixMenu:[menuItem submenu] withAppName:appName]; [self fixMenu:[menuItem submenu] withAppName:appName];
} }
[ aMenu sizeToFit ]; /* SA [ aMenu sizeToFit ]; */
} }
char *appName = "StellaOSX"; char *appName = "StellaOSX";
char fileName[FILENAME_MAX];
/* Called when the internal event loop has just started running */ /* Called when the internal event loop has just started running */
- (void) applicationDidFinishLaunching: (NSNotification *) note - (void) applicationDidFinishLaunching: (NSNotification *) note
@ -121,22 +120,20 @@ char fileName[FILENAME_MAX];
*-----------------------------------------------------------------------------*/ *-----------------------------------------------------------------------------*/
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{ {
char *cFilename; if (started)
{
if (started) { char cFilename[FILENAME_MAX];
cFilename = malloc(FILENAME_MAX); strncpy(cFilename, [filename cStringUsingEncoding: NSASCIIStringEncoding], FILENAME_MAX-1);
if (cFilename) if (strlen(cFilename) > 0)
{
[filename getCString:cFilename];
macOpenConsole(cFilename); macOpenConsole(cFilename);
} }
} else
else { {
fileToLoad = TRUE; fileToLoad = TRUE;
[filename getCString:startupFile]; strncpy(startupFile, [filename cStringUsingEncoding: NSASCIIStringEncoding], FILENAME_MAX-1);
} }
return(FALSE); return(FALSE);
} }
@end @end

View File

@ -33,8 +33,8 @@
#include "SettingsMACOSX.hxx" #include "SettingsMACOSX.hxx"
extern "C" { extern "C" {
void prefsSetString(char *key, char *value); void prefsSetString(const char* key, const char* value);
void prefsGetString(char *key, char *value); void prefsGetString(const char* key, char* value, int size);
void prefsSave(void); void prefsSave(void);
} }
@ -62,7 +62,7 @@ void SettingsMACOSX::loadConfig()
const SettingsArray& settings = getInternalSettings(); const SettingsArray& settings = getInternalSettings();
for(unsigned int i = 0; i < settings.size(); ++i) for(unsigned int i = 0; i < settings.size(); ++i)
{ {
prefsGetString((char *) settings[i].key.c_str(), cvalue); prefsGetString(settings[i].key.c_str(), cvalue, 2047);
if(cvalue[0] != 0) if(cvalue[0] != 0)
setInternal(settings[i].key, cvalue, i, true); setInternal(settings[i].key, cvalue, i, true);
} }
@ -74,9 +74,7 @@ void SettingsMACOSX::saveConfig()
// Write out each of the key and value pairs // Write out each of the key and value pairs
const SettingsArray& settings = getInternalSettings(); const SettingsArray& settings = getInternalSettings();
for(unsigned int i = 0; i < settings.size(); ++i) for(unsigned int i = 0; i < settings.size(); ++i)
{ prefsSetString(settings[i].key.c_str(), settings[i].value.c_str());
prefsSetString((char *) settings[i].key.c_str(),
(char *) settings[i].value.c_str());
}
prefsSave(); prefsSave();
} }

View File

@ -1,6 +0,0 @@
SDKROOT_ppc = /Developer/SDKs/MacOSX10.3.9.sdk
SDKROOT_i386 = /Developer/SDKs/MacOSX10.4u.sdk
GCC_VERSION_ppc = 3.3
GCC_VERSION_i386 = 4.0
MACOSX_DEPLOYMENT_TARGET_ppc = 10.2
MACOSX_DEPLOYMENT_TARGET_i386 = 10.4

View File

@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 42; objectVersion = 46;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
@ -473,7 +473,7 @@
2D73959508C3EB4E0060BB99 /* CommandMenu.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CommandMenu.cxx; path = ../gui/CommandMenu.cxx; sourceTree = SOURCE_ROOT; }; 2D73959508C3EB4E0060BB99 /* CommandMenu.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CommandMenu.cxx; path = ../gui/CommandMenu.cxx; sourceTree = SOURCE_ROOT; };
2D73959608C3EB4E0060BB99 /* CommandMenu.hxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; name = CommandMenu.hxx; path = ../gui/CommandMenu.hxx; sourceTree = SOURCE_ROOT; }; 2D73959608C3EB4E0060BB99 /* CommandMenu.hxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; name = CommandMenu.hxx; path = ../gui/CommandMenu.hxx; sourceTree = SOURCE_ROOT; };
2D7B4F6C063B513200579B93 /* Credits.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html; path = Credits.html; sourceTree = SOURCE_ROOT; }; 2D7B4F6C063B513200579B93 /* Credits.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html; path = Credits.html; sourceTree = SOURCE_ROOT; };
2D91751A09BA90380026E9FF /* Info-StellaOSX__Upgraded_.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Info-StellaOSX__Upgraded_.plist"; sourceTree = "<group>"; }; 2D91751A09BA90380026E9FF /* Info-StellaOSX__Upgraded_.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-StellaOSX__Upgraded_.plist"; sourceTree = "<group>"; };
2D91751E09BA90390026E9FF /* StellaOSX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StellaOSX.app; sourceTree = BUILT_PRODUCTS_DIR; }; 2D91751E09BA90390026E9FF /* StellaOSX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StellaOSX.app; sourceTree = BUILT_PRODUCTS_DIR; };
2D91753709BA91BC0026E9FF /* StellaOSX.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; path = StellaOSX.xcconfig; sourceTree = SOURCE_ROOT; }; 2D91753709BA91BC0026E9FF /* StellaOSX.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; path = StellaOSX.xcconfig; sourceTree = SOURCE_ROOT; };
2D9217FA0857CC88001D664B /* ConsoleFont.hxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; name = ConsoleFont.hxx; path = ../gui/ConsoleFont.hxx; sourceTree = SOURCE_ROOT; }; 2D9217FA0857CC88001D664B /* ConsoleFont.hxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; name = ConsoleFont.hxx; path = ../gui/ConsoleFont.hxx; sourceTree = SOURCE_ROOT; };
@ -1414,7 +1414,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = { 29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject; isa = PBXProject;
buildConfigurationList = 2D91752109BA903B0026E9FF /* Build configuration list for PBXProject "stella" */; buildConfigurationList = 2D91752109BA903B0026E9FF /* Build configuration list for PBXProject "stella" */;
compatibilityVersion = "Xcode 2.4"; compatibilityVersion = "Xcode 3.2";
hasScannedForEncodings = 1; hasScannedForEncodings = 1;
mainGroup = 29B97314FDCFA39411CA2CEA /* «PROJECTNAMEASXML» */; mainGroup = 29B97314FDCFA39411CA2CEA /* «PROJECTNAMEASXML» */;
projectDirPath = ""; projectDirPath = "";
@ -1817,6 +1817,7 @@
2D91752209BA903B0026E9FF /* Development */ = { 2D91752209BA903B0026E9FF /* Development */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
., .,
"$(HOME)/Library/Frameworks", "$(HOME)/Library/Frameworks",
@ -1828,25 +1829,23 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 2D91753709BA91BC0026E9FF /* StellaOSX.xcconfig */; baseConfigurationReference = 2D91753709BA91BC0026E9FF /* StellaOSX.xcconfig */;
buildSettings = { buildSettings = {
ARCHS = ( ARCHS = "$(ARCHS_STANDARD_32_BIT)";
ppc,
i386,
);
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
., .,
"$(HOME)/Library/Frameworks", "$(HOME)/Library/Frameworks",
); );
GCC_ENABLE_CPP_RTTI = NO; GCC_ENABLE_CPP_RTTI = NO;
GCC_OPTIMIZATION_LEVEL = 3; GCC_OPTIMIZATION_LEVEL = 3;
SDKROOT_ppc = /Developer/SDKs/MacOSX10.3.9.sdk; GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
}; };
name = Deployment; name = Deployment;
}; };
2D91752409BA903B0026E9FF /* Default */ = { 2D91752409BA903B0026E9FF /* Default */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
MACOSX_DEPLOYMENT_TARGET = 10.4; MACOSX_DEPLOYMENT_TARGET = 10.4;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; SDKROOT = macosx10.4;
}; };
name = Default; name = Default;
}; };