Skip to content

Commit

Permalink
Quiet some deprecated warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddTheSane committed Jul 31, 2020
1 parent 4248ba8 commit 1e5063d
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Cocoa/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

-(uint8_t) readMemory:(uint16_t) addr;
-(void) writeMemory:(uint16_t) addr value:(uint8_t)value;
-(void) performAtomicBlock: (void (^)())block;
-(void) performAtomicBlock: (void (^ NS_NOESCAPE)(void))block;

@end

68 changes: 34 additions & 34 deletions Cocoa/Document.m
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ - (void) updateBorderMode

- (void) updateRumbleMode
{
GB_set_rumble_mode(&gb, [[NSUserDefaults standardUserDefaults] integerForKey:@"GBRumbleMode"]);
GB_set_rumble_mode(&gb, (GB_rumble_mode_t)[[NSUserDefaults standardUserDefaults] integerForKey:@"GBRumbleMode"]);
}

- (void) initCommon
Expand Down Expand Up @@ -282,7 +282,7 @@ - (void) vblank
GB_set_pixels_output(&gb, self.view.pixels);
if (self.vramWindow.isVisible) {
dispatch_async(dispatch_get_main_queue(), ^{
self.view.mouseHidingEnabled = (self.mainWindow.styleMask & NSFullScreenWindowMask) != 0;
self.view.mouseHidingEnabled = (self.mainWindow.styleMask & NSWindowStyleMaskFullScreen) != 0;
[self reloadVRAMData: nil];
});
}
Expand Down Expand Up @@ -330,29 +330,29 @@ - (void) run
GB_set_pixels_output(&gb, self.view.pixels);
GB_set_sample_rate(&gb, 96000);
self.audioClient = [[GBAudioClient alloc] initWithRendererBlock:^(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer) {
[audioLock lock];
[self->audioLock lock];

if (audioBufferPosition < nFrames) {
audioBufferNeeded = nFrames;
[audioLock wait];
if (self->audioBufferPosition < nFrames) {
self->audioBufferNeeded = nFrames;
[self->audioLock wait];
}

if (stopping) {
if (self->stopping) {
memset(buffer, 0, nFrames * sizeof(*buffer));
[audioLock unlock];
[self->audioLock unlock];
return;
}

if (audioBufferPosition >= nFrames && audioBufferPosition < nFrames + 4800) {
memcpy(buffer, audioBuffer, nFrames * sizeof(*buffer));
memmove(audioBuffer, audioBuffer + nFrames, (audioBufferPosition - nFrames) * sizeof(*buffer));
audioBufferPosition = audioBufferPosition - nFrames;
if (self->audioBufferPosition >= nFrames && self->audioBufferPosition < nFrames + 4800) {
memcpy(buffer, self->audioBuffer, nFrames * sizeof(*buffer));
memmove(self->audioBuffer, self->audioBuffer + nFrames, (self->audioBufferPosition - nFrames) * sizeof(*buffer));
self->audioBufferPosition = self->audioBufferPosition - nFrames;
}
else {
memcpy(buffer, audioBuffer + (audioBufferPosition - nFrames), nFrames * sizeof(*buffer));
audioBufferPosition = 0;
memcpy(buffer, self->audioBuffer + (self->audioBufferPosition - nFrames), nFrames * sizeof(*buffer));
self->audioBufferPosition = 0;
}
[audioLock unlock];
[self->audioLock unlock];
} andSampleRate:96000];
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"Mute"]) {
[self.audioClient start];
Expand Down Expand Up @@ -399,13 +399,13 @@ - (void) run
[self.audioClient stop];
self.audioClient = nil;
self.view.mouseHidingEnabled = NO;
GB_save_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sav"] UTF8String]);
GB_save_cheats(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"cht"] UTF8String]);
GB_save_battery(&gb, [[[self.fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sav"] fileSystemRepresentation]);
GB_save_cheats(&gb, [[[self.fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"cht"] fileSystemRepresentation]);
unsigned time_to_alarm = GB_time_to_alarm(&gb);

if (time_to_alarm) {
NSUserNotification *notification = [[NSUserNotification alloc] init];
NSString *friendlyName = [[self.fileName lastPathComponent] stringByDeletingPathExtension];
NSString *friendlyName = [[self.fileURL lastPathComponent] stringByDeletingPathExtension];
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\([^)]+\\)|\\[[^\\]]+\\]" options:0 error:nil];
friendlyName = [regex stringByReplacingMatchesInString:friendlyName options:0 range:NSMakeRange(0, [friendlyName length]) withTemplate:@""];
friendlyName = [friendlyName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
Expand All @@ -425,7 +425,7 @@ - (void) run
- (void) start
{
if (running) return;
self.view.mouseHidingEnabled = (self.mainWindow.styleMask & NSFullScreenWindowMask) != 0;
self.view.mouseHidingEnabled = (self.mainWindow.styleMask & NSWindowStyleMaskFullScreen) != 0;
[[[NSThread alloc] initWithTarget:self selector:@selector(run) object:nil] start];
}

Expand Down Expand Up @@ -705,18 +705,18 @@ - (void) loadROM
NSString *rom_warnings = [self captureOutputForBlock:^{
GB_debugger_clear_symbols(&gb);
if ([[self.fileType pathExtension] isEqualToString:@"isx"]) {
GB_load_isx(&gb, [self.fileName UTF8String]);
GB_load_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"ram"] UTF8String]);
GB_load_isx(&gb, [self.fileURL fileSystemRepresentation]);
GB_load_battery(&gb, [[[self.fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"ram"] fileSystemRepresentation]);

}
else {
GB_load_rom(&gb, [self.fileName UTF8String]);
GB_load_rom(&gb, [self.fileURL fileSystemRepresentation]);
}
GB_load_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sav"] UTF8String]);
GB_load_cheats(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"cht"] UTF8String]);
GB_load_battery(&gb, [[[self.fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sav"] fileSystemRepresentation]);
GB_load_cheats(&gb, [[[self.fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"cht"] fileSystemRepresentation]);
[self.cheatWindowController cheatsUpdated];
GB_debugger_load_symbol_file(&gb, [[[NSBundle mainBundle] pathForResource:@"registers" ofType:@"sym"] UTF8String]);
GB_debugger_load_symbol_file(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sym"] UTF8String]);
GB_debugger_load_symbol_file(&gb, [[[NSBundle mainBundle] URLForResource:@"registers" withExtension:@"sym"] fileSystemRepresentation]);
GB_debugger_load_symbol_file(&gb, [[[self.fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sym"] fileSystemRepresentation]);
}];
if (rom_warnings && !rom_warning_issued) {
rom_warning_issued = true;
Expand Down Expand Up @@ -1013,7 +1013,7 @@ - (IBAction)saveState:(id)sender
{
bool __block success = false;
[self performAtomicBlock:^{
success = GB_save_state(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:[NSString stringWithFormat:@"s%ld", (long)[sender tag] ]] UTF8String]) == 0;
success = GB_save_state(&gb, [[[self.fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:[NSString stringWithFormat:@"s%ld", (long)[sender tag] ]] fileSystemRepresentation]) == 0;
}];

if (!success) {
Expand All @@ -1027,7 +1027,7 @@ - (IBAction)loadState:(id)sender
bool __block success = false;
NSString *error =
[self captureOutputForBlock:^{
success = GB_load_state(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:[NSString stringWithFormat:@"s%ld", (long)[sender tag] ]] UTF8String]) == 0;
success = GB_load_state(&gb, [[[self.fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:[NSString stringWithFormat:@"s%ld", (long)[sender tag] ]] fileSystemRepresentation]) == 0;
}];

if (!success) {
Expand Down Expand Up @@ -1060,7 +1060,7 @@ - (void) writeMemory:(uint16_t)addr value:(uint8_t)value
GB_write_memory(&gb, addr, value);
}

- (void) performAtomicBlock: (void (^)())block
- (void) performAtomicBlock: (void (^ NS_NOESCAPE)(void))block
{
while (!GB_is_inited(&gb));
bool was_running = running && !GB_debugger_is_stopped(&gb);
Expand All @@ -1073,7 +1073,7 @@ - (void) performAtomicBlock: (void (^)())block
}
}

- (NSString *) captureOutputForBlock: (void (^)())block
- (NSString *) captureOutputForBlock: (void (^ NS_NOESCAPE)(void))block
{
capturedOutput = [[NSMutableString alloc] init];
[self performAtomicBlock:block];
Expand Down Expand Up @@ -1624,9 +1624,9 @@ - (void) printImage:(uint32_t *)imageBytes height:(unsigned) height
[currentPrinterImageData appendBytes:paddedImage length:sizeof(paddedImage)];
/* UI related code must run on main thread. */
dispatch_async(dispatch_get_main_queue(), ^{
self.feedImageView.image = [Document imageFromData:currentPrinterImageData
self.feedImageView.image = [Document imageFromData:self->currentPrinterImageData
width:160
height:currentPrinterImageData.length / 160 / sizeof(imageBytes[0])
height:self->currentPrinterImageData.length / 160 / sizeof(imageBytes[0])
scale:2.0];
NSRect frame = self.printerFeedWindow.frame;
frame.size = self.feedImageView.image.size;
Expand Down Expand Up @@ -1655,14 +1655,14 @@ - (IBAction)savePrinterFeed:(id)sender
NSSavePanel * savePanel = [NSSavePanel savePanel];
[savePanel setAllowedFileTypes:@[@"png"]];
[savePanel beginSheetModalForWindow:self.printerFeedWindow completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) {
if (result == NSModalResponseOK) {
[savePanel orderOut:self];
CGImageRef cgRef = [self.feedImageView.image CGImageForProposedRect:NULL
context:nil
hints:nil];
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgRef];
[imageRep setSize:(NSSize){160, self.feedImageView.image.size.height / 2}];
NSData *data = [imageRep representationUsingType:NSPNGFileType properties:@{}];
NSData *data = [imageRep representationUsingType:NSBitmapImageFileTypePNG properties:@{}];
[data writeToURL:savePanel.URL atomically:NO];
[self.printerFeedWindow setIsVisible:NO];
}
Expand Down
4 changes: 2 additions & 2 deletions Cocoa/GBCheatWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ - (void)tableViewSelectionDidChange:(NSNotification *)notification

size_t cheatCount;
const GB_cheat_t *const *cheats = GB_get_cheats(gb, &cheatCount);
unsigned row = self.cheatsTable.selectedRow;
NSInteger row = self.cheatsTable.selectedRow;
const GB_cheat_t *cheat = NULL;
if (row >= cheatCount) {
static const GB_cheat_t template = {
Expand Down Expand Up @@ -203,7 +203,7 @@ - (IBAction)updateCheat:(id)sender

size_t cheatCount;
const GB_cheat_t *const *cheats = GB_get_cheats(gb, &cheatCount);
unsigned row = self.cheatsTable.selectedRow;
NSInteger row = self.cheatsTable.selectedRow;

[self.document performAtomicBlock:^{
if (row >= cheatCount) {
Expand Down
2 changes: 1 addition & 1 deletion Cocoa/GBImageCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@implementation GBImageCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextRef context = [[NSGraphicsContext currentContext] CGContext];
CGContextSetInterpolationQuality(context, kCGInterpolationNone);
[super drawWithFrame:cellFrame inView:controlView];
}
Expand Down
8 changes: 4 additions & 4 deletions Cocoa/GBImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ @implementation GBImageView
}
- (void)drawRect:(NSRect)dirtyRect
{
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextRef context = [[NSGraphicsContext currentContext] CGContext];
CGContextSetInterpolationQuality(context, kCGInterpolationNone);
[super drawRect:dirtyRect];
CGFloat y_ratio = self.frame.size.height / self.image.size.height;
Expand Down Expand Up @@ -76,19 +76,19 @@ - (void)drawRect:(NSRect)dirtyRect
- (void)setHorizontalGrids:(NSArray *)horizontalGrids
{
self->_horizontalGrids = horizontalGrids;
[self setNeedsDisplay];
[self setNeedsDisplay:YES];
}

- (void)setVerticalGrids:(NSArray *)verticalGrids
{
self->_verticalGrids = verticalGrids;
[self setNeedsDisplay];
[self setNeedsDisplay:YES];
}

- (void)setDisplayScrollRect:(bool)displayScrollRect
{
self->_displayScrollRect = displayScrollRect;
[self setNeedsDisplay];
[self setNeedsDisplay:YES];
}

- (void)updateTrackingAreas
Expand Down
4 changes: 2 additions & 2 deletions Cocoa/GBPreferencesWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,13 @@ - (IBAction)highpassFilterChanged:(id)sender

- (IBAction)changeAnalogControls:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] == NSOnState
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] == NSControlStateValueOn
forKey:@"GBAnalogControls"];
}

- (IBAction)changeAspectRatio:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] != NSOnState
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] != NSControlStateValueOn
forKey:@"GBAspectRatioUnkept"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBAspectChanged" object:nil];
}
Expand Down
2 changes: 1 addition & 1 deletion Cocoa/GBViewMetal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#import "GBView.h"

@interface GBViewMetal : GBView<MTKViewDelegate>
+ (bool) isSupported;
+ (BOOL) isSupported;
@end
4 changes: 2 additions & 2 deletions Cocoa/GBViewMetal.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ @implementation GBViewMetal
vector_float2 output_resolution;
}

+ (bool)isSupported
+ (BOOL)isSupported
{
if (MTLCopyAllDevices) {
return [MTLCopyAllDevices() count];
return [MTLCopyAllDevices() count] != 0;
}
return false;
}
Expand Down

0 comments on commit 1e5063d

Please sign in to comment.