Permalink
Browse files

Migrated to ARC

  • Loading branch information...
0xe1f committed Apr 4, 2016
1 parent 97d31e5 commit 702684267d5fd279f881ac3ac3248be3813bcf56
Showing with 181 additions and 576 deletions.
  1. +6 −6 CMAppDelegate.h
  2. +1 −10 CMAppDelegate.m
  3. +0 −6 Cocoa/CMFrameCounter.h
  4. +9 −7 Cocoa/CMFrameCounter.m
  5. +2 −15 Cocoa/CMGamepad.h
  6. +14 −20 Cocoa/CMGamepad.m
  7. +0 −5 Cocoa/CMGamepadConfiguration.m
  8. +0 −3 Cocoa/CMGamepadEventData.h
  9. +0 −2 Cocoa/CMGamepadEventData.m
  10. +0 −5 Cocoa/CMGamepadManager.h
  11. +9 −9 Cocoa/CMGamepadManager.m
  12. +0 −9 Cocoa/CMInputDeviceLayout.m
  13. +0 −4 Cocoa/CMKeyEventData.h
  14. +0 −3 Cocoa/CMKeyEventData.m
  15. +0 −3 Cocoa/CMKeyboardInput.h
  16. +1 −8 Cocoa/CMKeyboardInput.m
  17. +3 −12 Cocoa/CMKeyboardManager.m
  18. +3 −26 Cocoa/CMMSXJoystick.m
  19. +3 −14 Cocoa/CMMSXKeyboard.h
  20. +11 −44 Cocoa/CMMSXKeyboard.m
  21. +1 −11 Cocoa/CMMachine.h
  22. +6 −26 Cocoa/CMMachine.m
  23. +1 −4 Cocoa/CMMachineInstallationOperation.h
  24. +2 −11 Cocoa/CMMachineInstallationOperation.m
  25. +0 −9 Cocoa/CMMixerChannel.h
  26. +6 −13 Cocoa/CMMixerChannel.m
  27. +4 −2 CocoaMSX.xcodeproj/project.pbxproj
  28. +2 −11 Controllers/CMAboutController.h
  29. +12 −20 Controllers/CMAboutController.m
  30. +1 −1 Controllers/CMConfigureJoystickController.h
  31. +1 −7 Controllers/CMConfigureJoystickController.m
  32. +5 −39 Controllers/CMEmulatorController.m
  33. +0 −22 Controllers/CMPreferenceController.h
  34. +28 −34 Controllers/CMPreferenceController.m
  35. +2 −7 Controllers/CMRepositionCassetteController.h
  36. +7 −23 Controllers/CMRepositionCassetteController.m
  37. +0 −2 Src/Cocoa/CMCocoaBuffer.m
  38. +1 −18 Src/Cocoa/CMCocoaInput.h
  39. +14 −29 Src/Cocoa/CMCocoaInput.m
  40. +0 −5 Src/Cocoa/CMCocoaMouse.m
  41. +2 −4 Src/Cocoa/CMCocoaSound.m
  42. +3 −6 Src/Cocoa/CMCocoaTimer.m
  43. +0 −7 ThirdParty/MGScopeBar/MGRecessedPopUpButtonCell.m
  44. +1 −1 ThirdParty/MGScopeBar/MGScopeBar.h
  45. +8 −24 ThirdParty/MGScopeBar/MGScopeBar.m
  46. +3 −10 UI/CMHeaderRowCell.m
  47. +1 −1 UI/CMKeyCaptureView.m
  48. +0 −3 UI/CMMachineSelectionCell.h
  49. +0 −2 UI/CMMachineSelectionCell.m
  50. +1 −1 UI/CMMsxDisplayView.h
  51. +7 −12 UI/CMMsxDisplayView.m
View
@@ -26,13 +26,13 @@
@interface CMAppDelegate : NSObject <NSApplicationDelegate>
-@property (nonatomic, retain) CMEmulatorController *emulator;
+@property (nonatomic, strong) CMEmulatorController *emulator;
-@property (nonatomic, retain) IBOutlet NSMenuItem *recentCartridgesA;
-@property (nonatomic, retain) IBOutlet NSMenuItem *recentCartridgesB;
-@property (nonatomic, retain) IBOutlet NSMenuItem *recentDisksA;
-@property (nonatomic, retain) IBOutlet NSMenuItem *recentDisksB;
-@property (nonatomic, retain) IBOutlet NSMenuItem *recentCassettes;
+@property (nonatomic, strong) IBOutlet NSMenuItem *recentCartridgesA;
+@property (nonatomic, strong) IBOutlet NSMenuItem *recentCartridgesB;
+@property (nonatomic, strong) IBOutlet NSMenuItem *recentDisksA;
+@property (nonatomic, strong) IBOutlet NSMenuItem *recentDisksB;
+@property (nonatomic, strong) IBOutlet NSMenuItem *recentCassettes;
// Apple menu
View
@@ -62,15 +62,6 @@ - (void)awakeFromNib
self->preventSleepAssertionID = kIOPMNullAssertionID;
}
-- (void)dealloc
-{
- self.emulator = nil;
- [_aboutController release];
- [_preferenceController release];
-
- [super dealloc];
-}
-
#pragma mark - NSManagedObjectContext
- (void)observeValueForKeyPath:(NSString *)keyPath
@@ -324,7 +315,7 @@ - (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
[self initializeResources];
- [self setEmulator:[[[CMEmulatorController alloc] init] autorelease]];
+ [self setEmulator:[[CMEmulatorController alloc] init]];
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification
View
@@ -23,12 +23,6 @@
#import <Foundation/Foundation.h>
@interface CMFrameCounter : NSObject
-{
- NSInteger tickIndex;
- NSInteger tickSum;
- NSInteger *tickList;
- NSDate *lastTick;
-}
- (CGFloat)update;
View
@@ -24,11 +24,17 @@
@interface CMFrameCounter ()
-- (CGFloat)average:(NSInteger)newTick;
+- (CGFloat)average:(NSInteger) newTick;
@end
@implementation CMFrameCounter
+{
+ NSInteger tickIndex;
+ NSInteger tickSum;
+ NSInteger *tickList;
+ NSDate *lastTick;
+}
#define MAX_SAMPLES 100
@@ -39,7 +45,7 @@ - (id)init
tickList = calloc(MAX_SAMPLES, sizeof(NSInteger));
tickIndex = 0;
tickSum = 0;
- lastTick = [[NSDate date] retain];
+ lastTick = [NSDate date];
}
return self;
@@ -49,8 +55,7 @@ - (CGFloat)update;
{
NSDate *now = [NSDate date];
CGFloat freq = 1.0 / [now timeIntervalSinceDate:lastTick];
- [lastTick release];
- lastTick = [now retain];
+ lastTick = now;
return [self average:(NSInteger)freq];
}
@@ -70,9 +75,6 @@ - (CGFloat)average:(NSInteger)newTick
- (void)dealloc
{
free(tickList);
- [lastTick release];
-
- [super dealloc];
}
@end
View
@@ -24,21 +24,8 @@
#import <IOKit/hid/IOHIDLib.h>
@interface CMGamepad : NSObject
-{
- id _delegate;
- NSInteger _gamepadId;
-
- BOOL registeredForEvents;
- IOHIDDeviceRef hidDevice;
-
- NSInteger _locationId;
- NSInteger _vendorId;
- NSInteger _productId;
- NSString *_name;
- NSPoint _axes;
-}
-
-@property (nonatomic, assign) id delegate;
+
+@property (nonatomic, weak) id delegate;
@property (nonatomic, assign) NSInteger gamepadId;
@property (nonatomic, readonly) NSInteger locationId;
View
@@ -39,13 +39,12 @@ - (void)didReceiveInputValue:(IOHIDValueRef)valueRef;
@end
@implementation CMGamepad
-
-@synthesize delegate = _delegate;
-@synthesize gamepadId = _gamepadId;
-@synthesize vendorId = _vendorId;
-@synthesize productId = _productId;
-@synthesize locationId = _locationId;
-@synthesize name = _name;
+{
+ BOOL registeredForEvents;
+ IOHIDDeviceRef hidDevice;
+
+ NSPoint _axes;
+}
+ (NSArray *)allGamepads
{
@@ -76,7 +75,6 @@ + (NSArray *)allGamepads
while ((hidDevice = IOIteratorNext(hidObjectIterator)))
{
CMGamepad *gamepad = [[CMGamepad alloc] initWithHidDevice:hidDevice];
- [gamepad autorelease];
if ([gamepad locationId] == 0)
continue;
@@ -104,7 +102,7 @@ - (id)initWithHidDevice:(IOHIDDeviceRef)device
_vendorId = 0;
_productId = 0;
- _axes = NSMakePoint(0, 0);
+ _axes = NSMakePoint(CGFLOAT_MIN, CGFLOAT_MIN);
CFTypeRef tCFTypeRef;
CFTypeID numericTypeId = CFNumberGetTypeID();
@@ -121,7 +119,7 @@ - (id)initWithHidDevice:(IOHIDDeviceRef)device
if (tCFTypeRef && CFGetTypeID(tCFTypeRef) == numericTypeId)
CFNumberGetValue((CFNumberRef)tCFTypeRef, kCFNumberSInt32Type, &_locationId);
- _name = [(NSString *)IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductKey)) retain];
+ _name = (__bridge NSString *)IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductKey));
}
return self;
@@ -132,18 +130,14 @@ - (void)dealloc
[self unregisterFromEvents];
IOObjectRelease(hidDevice);
-
- [_name release];
-
- [super dealloc];
}
- (void)registerForEvents
{
if (!registeredForEvents)
{
IOHIDDeviceOpen(hidDevice, kIOHIDOptionsTypeNone);
- IOHIDDeviceRegisterInputValueCallback(hidDevice, gamepadInputValueCallback, self);
+ IOHIDDeviceRegisterInputValueCallback(hidDevice, gamepadInputValueCallback, (__bridge void *)(self));
registeredForEvents = YES;
@@ -208,7 +202,7 @@ - (void)didReceiveInputValue:(IOHIDValueRef)valueRef
_axes.x = value;
if ([_delegate respondsToSelector:@selector(gamepad:xChanged:center:eventData:)])
{
- CMGamepadEventData *eventData = [[[CMGamepadEventData alloc] init] autorelease];
+ CMGamepadEventData *eventData = [[CMGamepadEventData alloc] init];
[eventData setSourceId:IOHIDElementGetCookie(element)];
[_delegate gamepad:self
@@ -233,7 +227,7 @@ - (void)didReceiveInputValue:(IOHIDValueRef)valueRef
_axes.y = value;
if ([_delegate respondsToSelector:@selector(gamepad:yChanged:center:eventData:)])
{
- CMGamepadEventData *eventData = [[[CMGamepadEventData alloc] init] autorelease];
+ CMGamepadEventData *eventData = [[CMGamepadEventData alloc] init];
[eventData setSourceId:IOHIDElementGetCookie(element)];
[_delegate gamepad:self
@@ -250,7 +244,7 @@ - (void)didReceiveInputValue:(IOHIDValueRef)valueRef
{
if ([_delegate respondsToSelector:@selector(gamepad:buttonUp:eventData:)])
{
- CMGamepadEventData *eventData = [[[CMGamepadEventData alloc] init] autorelease];
+ CMGamepadEventData *eventData = [[CMGamepadEventData alloc] init];
[eventData setSourceId:IOHIDElementGetCookie(element)];
[_delegate gamepad:self
@@ -262,7 +256,7 @@ - (void)didReceiveInputValue:(IOHIDValueRef)valueRef
{
if ([_delegate respondsToSelector:@selector(gamepad:buttonDown:eventData:)])
{
- CMGamepadEventData *eventData = [[[CMGamepadEventData alloc] init] autorelease];
+ CMGamepadEventData *eventData = [[CMGamepadEventData alloc] init];
[eventData setSourceId:IOHIDElementGetCookie(element)];
[_delegate gamepad:self
@@ -278,7 +272,7 @@ - (NSMutableDictionary *)currentAxisValues
CFArrayRef elements = IOHIDDeviceCopyMatchingElements(hidDevice, NULL, kIOHIDOptionsTypeNone);
NSArray *elementArray = (__bridge NSArray *) elements;
- NSMutableDictionary *axesAndValues = [[[NSMutableDictionary alloc] init] autorelease];
+ NSMutableDictionary *axesAndValues = [[NSMutableDictionary alloc] init];
[elementArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
{
@@ -34,11 +34,6 @@ - (id)init
return self;
}
-- (void)dealloc
-{
- [super dealloc];
-}
-
#pragma mark - Etc
- (void) clear
@@ -23,9 +23,6 @@
#import <Foundation/Foundation.h>
@interface CMGamepadEventData : NSObject
-{
- NSInteger _sourceId;
-}
@property (nonatomic, assign) NSInteger sourceId;
@@ -24,6 +24,4 @@
@implementation CMGamepadEventData
-@synthesize sourceId = _sourceId;
-
@end
View
@@ -51,11 +51,6 @@
@end
@interface CMGamepadManager : NSObject<CMGamepadEventDelegate>
-{
- IOHIDManagerRef hidManager;
- NSMutableDictionary *gamepads;
- NSMutableArray *observers;
-}
+ (CMGamepadManager *)sharedInstance;
View
@@ -38,6 +38,11 @@ - (void)deviceDidDisconnect:(IOHIDDeviceRef)device;
@end
@implementation CMGamepadManager
+{
+ IOHIDManagerRef hidManager;
+ NSMutableDictionary *gamepads;
+ NSMutableArray *observers;
+}
+ (CMGamepadManager *)sharedInstance
{
@@ -65,9 +70,9 @@ - (id)init
@(kHIDUsage_GD_Joystick), (NSString *)CFSTR(kIOHIDDeviceUsageKey),
nil];
- IOHIDManagerSetDeviceMatchingMultiple(hidManager, (CFArrayRef)[NSArray arrayWithObjects:gamepadCriterion, joystickCriterion, nil]);
- IOHIDManagerRegisterDeviceMatchingCallback(hidManager, gamepadWasAdded, (void *)self);
- IOHIDManagerRegisterDeviceRemovalCallback(hidManager, gamepadWasRemoved, (void *)self);
+ IOHIDManagerSetDeviceMatchingMultiple(hidManager, (__bridge CFArrayRef)[NSArray arrayWithObjects:gamepadCriterion, joystickCriterion, nil]);
+ IOHIDManagerRegisterDeviceMatchingCallback(hidManager, gamepadWasAdded, (__bridge void *)self);
+ IOHIDManagerRegisterDeviceRemovalCallback(hidManager, gamepadWasRemoved, (__bridge void *)self);
IOHIDManagerScheduleWithRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
}
@@ -77,18 +82,13 @@ - (id)init
- (void)dealloc
{
- [gamepads release];
- [observers release];
-
IOHIDManagerUnscheduleFromRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
CFRelease(hidManager);
-
- [super dealloc];
}
- (void)deviceDidConnect:(IOHIDDeviceRef)device
{
- CMGamepad *gamepad = [[[CMGamepad alloc] initWithHidDevice:device] autorelease];
+ CMGamepad *gamepad = [[CMGamepad alloc] initWithHidDevice:device];
[gamepad setDelegate:self];
[gamepad setGamepadId:(NSInteger)device];
@@ -36,13 +36,6 @@ - (id)init
return self;
}
-- (void)dealloc
-{
- [inputs release];
-
- [super dealloc];
-}
-
#pragma mark - NSCoding
- (id)initWithCoder:(NSCoder *)decoder
@@ -70,8 +63,6 @@ - (void)loadLayout:(CMInputDeviceLayout *)layout
{
CMInputMethod *copy = [((CMInputMethod *)obj) copy];
[inputs setObject:copy forKey:key];
-
- [copy release];
}];
}
View
@@ -23,10 +23,6 @@
#import <Foundation/Foundation.h>
@interface CMKeyEventData : NSObject
-{
- NSInteger _scanCode;
- NSInteger _keyCode;
-}
@property (nonatomic, assign) NSInteger scanCode;
@property (nonatomic, assign) NSInteger keyCode;
View
@@ -24,9 +24,6 @@
@implementation CMKeyEventData
-@synthesize scanCode = _scanCode;
-@synthesize keyCode = _keyCode;
-
- (BOOL)hasKeyCodeEquivalent
{
return _keyCode != 0xff;
View
@@ -131,9 +131,6 @@
#define CMCapsLockKeyMask NSAlphaShiftKeyMask
@interface CMKeyboardInput : CMInputMethod
-{
- NSInteger _keyCode;
-}
+ (CMKeyboardInput *)keyboardInputWithKeyCode:(NSInteger)keyCode;
Oops, something went wrong.

0 comments on commit 7026842

Please sign in to comment.