summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-07-11 00:03:19 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-07-11 00:03:19 +0000
commit04f58e9cbc7396f7a5c9b1de2a9a4640540f7818 (patch)
tree0babc47fbb3d2b752fe97da189fc2efb012d3587
parentbde1f035c1b045f1ed3b678b5545d1de8fb5cd85 (diff)
downloadpcsxr-04f58e9cbc7396f7a5c9b1de2a9a4640540f7818.tar.gz
Revert some SysPrintfs in OS X to NSLogs.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85963 e17a0e51-4ae3-4d35-97c3-1a29b211df97
-rw-r--r--macosx/CheatController.m6
-rwxr-xr-xmacosx/PcsxrController.h1
-rwxr-xr-xmacosx/PcsxrController.m17
-rwxr-xr-xmacosx/PcsxrMemoryObject.m4
-rwxr-xr-xmacosx/PluginController.m1
-rwxr-xr-xmacosx/hotkeys.m2
-rwxr-xr-xmacosx/main.m73
7 files changed, 34 insertions, 70 deletions
diff --git a/macosx/CheatController.m b/macosx/CheatController.m
index 5603b17f..79a66b26 100644
--- a/macosx/CheatController.m
+++ b/macosx/CheatController.m
@@ -32,11 +32,11 @@
return nil;
NSString *ident = [col identifier];
if ([ident isEqualToString:@"COL_NAME"]) {
- return @(Cheats[idx].Descr);
+ return [NSString stringWithCString:Cheats[idx].Descr encoding:NSUTF8StringEncoding];
} else if ([ident isEqualToString:@"COL_ENABLE"]) {
- return @(Cheats[idx].Enabled ? NSOnState : NSOffState);
+ return [NSNumber numberWithInt: Cheats[idx].Enabled ? NSOnState : NSOffState];
}
- SysPrintf("Unknown column identifier: %s\n", [[ident description] UTF8String]);
+ NSLog(@"Unknown column identifier: %@", ident);
return nil;
}
diff --git a/macosx/PcsxrController.h b/macosx/PcsxrController.h
index 5330f382..3510d18b 100755
--- a/macosx/PcsxrController.h
+++ b/macosx/PcsxrController.h
@@ -9,7 +9,6 @@
@class CheatController;
void ShowHelpAndExit(FILE* output, int exitCode);
-void CloseEmuLog();
@interface PcsxrController : NSObject <NSApplicationDelegate>
{
diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m
index 47778c6e..e2e85c88 100755
--- a/macosx/PcsxrController.m
+++ b/macosx/PcsxrController.m
@@ -343,20 +343,9 @@ void ShowHelpAndExit(FILE* output, int exitCode)
self.skipFiles = nil;
}
-- (void)applicationWillTerminate:(NSNotification *)notification
-{
- CloseEmuLog();
-}
-
static void ParseErrorStr(NSString *errStr)
{
- NSString *logStr = [NSString stringWithFormat:@"Parse error: %@", errStr];
-
- SysPrintf("%s\n", [logStr UTF8String]);
- if (!Config.PsxOut) {
- //make sure this comes out on the console.
- NSLog(@"%@", logStr);
- }
+ NSLog(@"Parse error: %@", errStr);
NSRunCriticalAlertPanel(@"Parsing error", @"%@\n\nPlease check the command line options and try again.\n\nPCSXR will now quit.", nil, nil, nil, errStr);
ShowHelpAndExit(stderr, EXIT_FAILURE);
}
@@ -470,7 +459,7 @@ otherblock();\
void (^mcdBlock)(int mcdNumber) = ^(int mcdnumber){
hasParsedAnArgument = YES;
if (memcardHandled & (1 << mcdnumber)) {
- SysPrintf("Memory card %i has already been defined. The latest one passed will be used.\n", mcdnumber);
+ NSLog(@"Memory card %i has already been defined. The latest one passed will be used.", mcdnumber);
} else {
memcardHandled |= (1 << mcdnumber);
}
@@ -538,7 +527,7 @@ otherblock();\
//As there doesn't seem to be a Cocoa/Objective-C method like this...
NSString *unknownString = CFBridgingRelease(CFStringCreateByCombiningStrings(kCFAllocatorDefault, BRIDGE(CFArrayRef, unknownOptions), CFSTR(" ")));
- SysPrintf("The following options weren't recognized by PCSX-R: %s. This may be due to extra arguments passed by the OS or debugger.\n", [unknownString UTF8String]);
+ NSLog(@"The following options weren't recognized by PCSX-R: %@. This may be due to extra arguments passed by the OS or debugger.", unknownString);
}
#endif
unknownOptions = nil;
diff --git a/macosx/PcsxrMemoryObject.m b/macosx/PcsxrMemoryObject.m
index ec063ec9..b5414e38 100755
--- a/macosx/PcsxrMemoryObject.m
+++ b/macosx/PcsxrMemoryObject.m
@@ -147,7 +147,7 @@ static NSString *MemLabelEndLink;
return memFlagFree;
//Xcode complains unless we do this...
- SysPrintf("Unknown flag %x\n", blockFlags);
+ NSLog(@"Unknown flag %x", blockFlags);
return memFlagFree;
}
@@ -169,7 +169,7 @@ static NSString *MemLabelEndLink;
if ([englishName isEqualToString:sjisName]) {
#if 0
if (![englishName isEqualToString:@""])
- SysPrintf("English name and sjis name are the same: %s. Replacing the sjis string with the English string.\n", [englishName UTF8String]);
+ NSLog(@"English name and sjis name are the same: %s. Replacing the sjis string with the English string.", [englishName UTF8String]);
#endif
self.sjisName = self.englishName;
}
diff --git a/macosx/PluginController.m b/macosx/PluginController.m
index a857bbbb..1d74f9cc 100755
--- a/macosx/PluginController.m
+++ b/macosx/PluginController.m
@@ -78,6 +78,7 @@
{
[plugins release];
[defaultKey release];
+
[super dealloc];
}
#endif
diff --git a/macosx/hotkeys.m b/macosx/hotkeys.m
index 97121ce3..a3fcbfa7 100755
--- a/macosx/hotkeys.m
+++ b/macosx/hotkeys.m
@@ -76,7 +76,7 @@ BOOL handleHotkey(NSString* keyCode) {
GPU_displayText((char*)[[NSString stringWithFormat:@"State Slot: %d", currentState] UTF8String]);
break;
default:
- SysPrintf("Invalid hotkey identifier %i.\n", [ident intValue]);
+ NSLog(@"Invalid hotkey identifier %li.", [ident integerValue]);
}
return YES;
diff --git a/macosx/main.m b/macosx/main.m
index 5ed5619e..7a38d431 100755
--- a/macosx/main.m
+++ b/macosx/main.m
@@ -24,36 +24,6 @@ static IOPMAssertionID powerAssertion = kIOPMNullAssertionID;
void PADhandleKey(int key);
-static void LoadEmuLog()
-{
- if (emuLog == NULL) {
-#ifdef EMU_LOG
-#ifndef LOG_STDOUT
- NSFileManager *manager = [NSFileManager defaultManager];
- NSURL *supportURL = [manager URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL];
- NSURL *logFolderURL = [supportURL URLByAppendingPathComponent:@"Logs/PCSXR"];
- if (![logFolderURL checkResourceIsReachableAndReturnError:NULL])
- [manager createDirectoryAtPath:[logFolderURL path] withIntermediateDirectories:YES attributes:nil error:NULL];
- //We use the log extension so that OS X's console app can open it by default.
- NSURL *logFileURL = [logFolderURL URLByAppendingPathComponent:@"emuLog.log"];
-
- emuLog = fopen([[logFileURL path] fileSystemRepresentation],"wb");
-#else
- emuLog = stdout;
-#endif
- setvbuf(emuLog, NULL, _IONBF, 0);
-#endif
- }
-}
-
-void CloseEmuLog()
-{
- if (emuLog != NULL) {
- fclose(emuLog);
- emuLog = NULL;
- }
-}
-
int main(int argc, const char *argv[]) {
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
char parentdir[MAXPATHLEN];
@@ -89,14 +59,27 @@ int main(int argc, const char *argv[]) {
if (getenv("DISPLAY") == NULL)
setenv("DISPLAY", ":0.0", 0); // Default to first local display
- LoadEmuLog();
-
return NSApplicationMain(argc, argv);
}
int SysInit() {
if (!sysInited) {
- LoadEmuLog();
+#ifdef EMU_LOG
+#ifndef LOG_STDOUT
+ NSFileManager *manager = [NSFileManager defaultManager];
+ NSURL *supportURL = [manager URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL];
+ NSURL *logFolderURL = [supportURL URLByAppendingPathComponent:@"Logs/PCSXR"];
+ if (![logFolderURL checkResourceIsReachableAndReturnError:NULL])
+ [manager createDirectoryAtPath:[logFolderURL path] withIntermediateDirectories:YES attributes:nil error:NULL];
+ //We use the log extension so that OS X's console app can open it by default.
+ NSURL *logFileURL = [logFolderURL URLByAppendingPathComponent:@"emuLog.log"];
+
+ emuLog = fopen([[logFileURL path] fileSystemRepresentation],"wb");
+#else
+ emuLog = stdout;
+#endif
+ setvbuf(emuLog, NULL, _IONBF, 0);
+#endif
if (EmuInit() != 0)
return -1;
@@ -112,7 +95,7 @@ int SysInit() {
IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("PSX Emu Running"), &powerAssertion);
if (success != kIOReturnSuccess) {
- SysPrintf("Unable to stop sleep, error code %d\n", success);
+ NSLog(@"Unable to stop sleep, error code %d", success);
}
attachHotkeys();
@@ -149,7 +132,7 @@ void SysPrintf(const char *fmt, ...) {
dispatch_block_t printfBlock = ^{
- if (Config.PsxOut) printf ("%s", msg);
+ if (Config.PsxOut) NSLog (@"%s", msg);
#ifdef EMU_LOG
#ifndef LOG_STDOUT
fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
@@ -167,26 +150,18 @@ void SysPrintf(const char *fmt, ...) {
void SysMessage(const char *fmt, ...) {
va_list list;
-
NSString *locFmtString = NSLocalizedString(@(fmt), nil);
-
+
va_start(list, fmt);
- NSString *msg = [[NSString alloc] initWithFormat:locFmtString arguments:list];
+ NSString *msg = [[NSString alloc] initWithFormat:locFmtString arguments:list];
va_end(list);
-
- NSDictionary *userInfo = [NSDictionary dictionaryWithObject:msg forKey:NSLocalizedFailureReasonErrorKey];
+
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:msg forKey:NSLocalizedFailureReasonErrorKey];
RELEASEOBJ(msg);
dispatch_block_t sysBlock = ^{
- if (Config.PsxOut) printf ("%s", [msg UTF8String]);
-#ifdef EMU_LOG
-#ifndef LOG_STDOUT
- fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
- [[[NSBundle mainBundle]objectForInfoDictionaryKey:@"CFBundleName"] UTF8String], [msg UTF8String]);
-#endif
-#endif
[NSApp presentError:[NSError errorWithDomain:@"Unknown Domain" code:-1 userInfo:userInfo]];
};
@@ -256,7 +231,7 @@ void SysClose() {
powerAssertion = kIOPMNullAssertionID;
}
- //CloseEmuLog();
+ if (emuLog != NULL) fclose(emuLog);
sysInited = NO;
detachHotkeys();
@@ -264,6 +239,7 @@ void SysClose() {
if (((PcsxrController *)[NSApp delegate]).endAtEmuClose) {
[NSApp stop:nil];
}
+
//Tell the memory card manager that the memory cards changed.
//The number three tells the mem card manager to update both cards 1 and 2.
[[NSNotificationCenter defaultCenter] postNotificationName:memChangeNotifier object:nil userInfo:[NSDictionary dictionaryWithObject:@3 forKey:memCardChangeNumberKey]];
@@ -271,7 +247,6 @@ void SysClose() {
void OnFile_Exit() {
SysClose();
- CloseEmuLog();
[NSApp stop:nil];
}