diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-08-24 19:44:48 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-08-24 19:44:48 +0000 |
| commit | 2a2790470d2ab7e0e22021e9b1774536546b1b4e (patch) | |
| tree | 02de3f051dca12a63637f56ec0c60a83819b5ad6 | |
| parent | 8b64ca8414e1dcf56b1d3d3a481090e551499445 (diff) | |
| download | pcsxr-2a2790470d2ab7e0e22021e9b1774536546b1b4e.tar.gz | |
OS X:
Replace CFStringCreateByCombiningStrings with NSArray's componentsJoinedByString:.
Moving some class interfaces out of CheatController.h to CheatController.m
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@86897 e17a0e51-4ae3-4d35-97c3-1a29b211df97
| -rw-r--r-- | macosx/CheatController.h | 33 | ||||
| -rw-r--r-- | macosx/CheatController.m | 56 | ||||
| -rwxr-xr-x | macosx/PcsxrController.m | 8 |
3 files changed, 45 insertions, 52 deletions
diff --git a/macosx/CheatController.h b/macosx/CheatController.h index 5ac56e93..e581886a 100644 --- a/macosx/CheatController.h +++ b/macosx/CheatController.h @@ -5,38 +5,9 @@ #import <Cocoa/Cocoa.h> #import "ARCBridge.h" -#include "psxcommon.h" -#include "cheat.h" @class PcsxrHexadecimalFormatter; -@interface PcsxrCheatTempObject : NSObject <NSCopying> -{ - uint32_t address; - uint16_t value; -} -@property (readwrite) uint32_t address; -@property (readwrite, arcweak) NSNumber* addressNS; -@property (readwrite) uint16_t value; -@property (readwrite, arcweak) NSNumber* valueNS; - -- (id)initWithAddress:(uint32_t)add value:(uint16_t)val; -- (id)initWithCheatCode:(CheatCode *)theCheat; -@end - -@interface PcsxrCheatTemp : NSObject -{ - NSMutableArray *cheatValues; - NSString *cheatName; - BOOL enabled; -} -@property (readwrite, retain) NSMutableArray *cheatValues; -@property (readwrite, retain, nonatomic) NSString *cheatName; -@property (readwrite, getter = isEnabled) BOOL enabled; - -- (id)initWithCheat:(Cheat *)theCheat; -@end - @interface CheatController : NSWindowController <NSWindowDelegate, NSTableViewDelegate> { IBOutlet NSTableView *cheatView; @@ -48,8 +19,8 @@ NSMutableArray *tempCheatCodes; NSMutableArray *cheats; } -@property (readwrite, retain) NSMutableArray *tempCheatCodes; -@property (readwrite, retain) NSMutableArray *cheats; +@property (readwrite, arcretain) NSMutableArray *tempCheatCodes; +@property (readwrite, arcretain) NSMutableArray *cheats; - (void)refresh; diff --git a/macosx/CheatController.m b/macosx/CheatController.m index 09f1e5a5..4650459a 100644 --- a/macosx/CheatController.m +++ b/macosx/CheatController.m @@ -13,6 +13,34 @@ #define kTempCheatCodesName @"tempCheatCodes" #define kCheatsName @"cheats" + +@interface PcsxrCheatTempObject : NSObject <NSCopying> +{ + uint32_t address; + uint16_t value; +} +@property (readwrite) uint32_t address; +@property (readwrite, arcweak) NSNumber* addressNS; +@property (readwrite) uint16_t value; +@property (readwrite, arcweak) NSNumber* valueNS; + +- (id)initWithAddress:(uint32_t)add value:(uint16_t)val; +- (id)initWithCheatCode:(CheatCode *)theCheat; +@end + +@interface PcsxrCheatTemp : NSObject +{ + NSMutableArray *cheatValues; + NSString *cheatName; + BOOL enabled; +} +@property (readwrite, arcretain) NSMutableArray *cheatValues; +@property (readwrite, arcretain) NSString *cheatName; +@property (readwrite, getter = isEnabled) BOOL enabled; + +- (id)initWithCheat:(Cheat *)theCheat; +@end + @implementation PcsxrCheatTempObject @synthesize address, value; @@ -36,7 +64,7 @@ - (id)init { - return self = [self initWithAddress:0x10000000 value:0]; + return [self initWithAddress:0x10000000 value:0]; } - (id)initWithAddress:(uint32_t)add value:(uint16_t)val @@ -71,6 +99,11 @@ return NO; } +- (NSUInteger)hash +{ + return address ^ value; +} + - (id)copyWithZone:(NSZone *)zone { return [[[self class] allocWithZone:zone] initWithAddress:address value:value]; @@ -83,22 +116,6 @@ @synthesize cheatValues; @synthesize enabled; -- (void)setCheatName:(NSString *)_cheatName -{ - if ([cheatName isEqualToString:_cheatName]) { - return; - } - [self willChangeValueForKey:@"cheatName"]; -#if __has_feature(objc_arc) - cheatName = _cheatName; -#else - NSString *temp = cheatName; - cheatName = [_cheatName copy]; - [temp release]; -#endif - [self didChangeValueForKey:@"cheatName"]; -} - - (id)initWithCheat:(Cheat *)theCheat { if (self = [super init]) { @@ -112,6 +129,11 @@ return self; } +- (NSUInteger)hash +{ + return [cheatName hash] ^ [cheatValues hash]; +} + - (NSString *)description { return [NSString stringWithFormat:@"[%@%@]\n%@", enabled ? @"*" : @"", cheatName, [cheatValues componentsJoinedByString:@"\n"]]; diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m index 7f4d9eda..f00e447d 100755 --- a/macosx/PcsxrController.m +++ b/macosx/PcsxrController.m @@ -538,14 +538,14 @@ otherblock();\ NSString *appRawPath = RETAINOBJ([mutProgArgs objectAtIndex:0]); //Remove the app file path from the array [mutProgArgs removeObjectAtIndex:0]; - NSString *arg = CFBridgingRelease(CFStringCreateByCombiningStrings(kCFAllocatorDefault, BRIDGE(CFArrayRef, mutProgArgs), CFSTR(" "))); - NSString *recognizedArgs = CFBridgingRelease(CFStringCreateByCombiningStrings(kCFAllocatorDefault, BRIDGE(CFArrayRef, [argDict allKeys]), CFSTR(" "))); + NSString *arg = [mutProgArgs componentsJoinedByString:@" "]; + NSString *recognizedArgs = [[argDict allKeys] componentsJoinedByString:@" "]; NSString *tmpStr = [NSString stringWithFormat:@"A launch command wasn't found in the command line and one or more arguments that PCSX-R recognizes were: %@.\nThe following command line arguments were passed with the application launch file at %@: %@.\n\nThe valid launch commands are %@, %@, and %@.", recognizedArgs, appRawPath, arg, kPCSXRArgumentISO, kPCSXRArgumentCDROM, kPCSXRArgumentBIOS]; RELEASEOBJ(appRawPath); ParseErrorStr(tmpStr); } else if (hasParsedAnArgument){ - NSArray *argArray = [[argDict allValues] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { + NSArray *argArray = [[argDict allValues] sortedArrayWithOptions:NSSortStable usingComparator:^NSComparisonResult(id obj1, id obj2) { LaunchArg *LA1 = obj1; LaunchArg *LA2 = obj2; if (LA1.launchOrder > LA2.launchOrder) { @@ -553,7 +553,7 @@ otherblock();\ } else if (LA1.launchOrder < LA2.launchOrder) { return NSOrderedAscending; } else { - return [LA1.argument compare:LA2.argument]; + return NSOrderedSame; } }]; for (LaunchArg *arg in argArray) { |
