From 71345d4d20e5e8a6b91e8157ab16258f8bd1eac2 Mon Sep 17 00:00:00 2001 From: rogerman Date: Wed, 6 Feb 2013 05:55:23 +0000 Subject: [PATCH] Cocoa Port: - Fix many compiler warnings. --- desmume/src/cocoa/cocoa_file.mm | 2 +- desmume/src/cocoa/cocoa_firmware.h | 2 +- desmume/src/cocoa/cocoa_firmware.mm | 2 +- desmume/src/cocoa/cocoa_globals.h | 2 +- desmume/src/cocoa/cocoa_hid.mm | 38 +++++++++---------- desmume/src/cocoa/cocoa_input.mm | 4 +- .../src/cocoa/userinterface/appDelegate.mm | 4 +- .../userinterface/cheatWindowDelegate.mm | 2 +- .../src/cocoa/userinterface/displayView.mm | 8 ++-- .../cocoa/userinterface/emuWindowDelegate.mm | 2 +- .../src/cocoa/userinterface/inputPrefsView.mm | 4 +- .../preferencesWindowDelegate.mm | 2 +- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/desmume/src/cocoa/cocoa_file.mm b/desmume/src/cocoa/cocoa_file.mm index d2ddcbcea..5ba9fa9d4 100644 --- a/desmume/src/cocoa/cocoa_file.mm +++ b/desmume/src/cocoa/cocoa_file.mm @@ -958,7 +958,7 @@ static NSMutableDictionary *_gURLDictionary = nil; } NSString *romFileName = [[romURL path] lastPathComponent]; - NSString *fileExt = [NSString stringWithFormat:@"ds%d", slotNumber]; + NSString *fileExt = [NSString stringWithFormat:@"ds%ld", (unsigned long)slotNumber]; return [[romFileName stringByDeletingPathExtension] stringByAppendingPathExtension:fileExt]; } diff --git a/desmume/src/cocoa/cocoa_firmware.h b/desmume/src/cocoa/cocoa_firmware.h index c39fb0277..ff56a3af1 100644 --- a/desmume/src/cocoa/cocoa_firmware.h +++ b/desmume/src/cocoa/cocoa_firmware.h @@ -39,7 +39,7 @@ { struct NDS_fw_config_data *data; struct NDS_fw_config_data *internalData; - NSInteger birth_year; + NSUInteger birth_year; pthread_mutex_t mutex; } diff --git a/desmume/src/cocoa/cocoa_firmware.mm b/desmume/src/cocoa/cocoa_firmware.mm index ee93898a7..6422f3393 100644 --- a/desmume/src/cocoa/cocoa_firmware.mm +++ b/desmume/src/cocoa/cocoa_firmware.mm @@ -254,7 +254,7 @@ - (NSDate *) birthday { pthread_mutex_lock(&mutex); - NSDate *theBirthday = [NSDate dateWithString:[NSString stringWithFormat:@"%d-%d-%d 12:00:00 +0000", birth_year, data->birth_month, data->birth_day]]; + NSDate *theBirthday = [NSDate dateWithString:[NSString stringWithFormat:@"%ld-%ld-%ld 12:00:00 +0000", (unsigned long)birth_year, (unsigned long)data->birth_month, (unsigned long)data->birth_day]]; pthread_mutex_unlock(&mutex); return theBirthday; diff --git a/desmume/src/cocoa/cocoa_globals.h b/desmume/src/cocoa/cocoa_globals.h index 2afe2b36b..c778fb20f 100644 --- a/desmume/src/cocoa/cocoa_globals.h +++ b/desmume/src/cocoa/cocoa_globals.h @@ -50,7 +50,7 @@ #define NSSTRING_TITLE_SHOW_STATUS_BAR NSLocalizedString(@"Show Status Bar", nil) #define NSSTRING_TITLE_SPEED_1X NSLocalizedString(@"Speed 1x", nil) #define NSSTRING_TITLE_SPEED_2X NSLocalizedString(@"Speed 2x", nil) -#define NSSTRING_TITLE_SLOT_NUMBER NSLocalizedString(@"Slot %d", nil) +#define NSSTRING_TITLE_SLOT_NUMBER NSLocalizedString(@"Slot %ld", nil) #define NSSTRING_TITLE_TECH_SUPPORT_WINDOW_TITLE NSLocalizedString(@"Support Request Form", nil) #define NSSTRING_TITLE_BUG_REPORT_WINDOW_TITLE NSLocalizedString(@"Bug Report Form", nil) diff --git a/desmume/src/cocoa/cocoa_hid.mm b/desmume/src/cocoa/cocoa_hid.mm index ce56e2c2f..5da830fce 100644 --- a/desmume/src/cocoa/cocoa_hid.mm +++ b/desmume/src/cocoa/cocoa_hid.mm @@ -219,7 +219,7 @@ static NSDictionary *hidUsageTable = nil; NSString *elementCode = nil; if (altElementCode == nil) { - elementCode = [NSString stringWithFormat:@"0x%04X/0x%04X", elementUsagePage, elementUsage]; + elementCode = [NSString stringWithFormat:@"0x%04lX/0x%04lX", (long)elementUsagePage, (long)elementUsage]; } else { @@ -235,16 +235,16 @@ static NSDictionary *hidUsageTable = nil; { if (elementUsagePage == kHIDPage_Button) { - elementName = [NSString stringWithFormat:@"Button %i", elementUsage]; + elementName = [NSString stringWithFormat:@"Button %li", (long)elementUsage]; } else if (elementUsagePage == kHIDPage_VendorDefinedStart) { - elementName = [NSString stringWithFormat:@"VendorDefined %i", elementUsage]; + elementName = [NSString stringWithFormat:@"VendorDefined %li", (long)elementUsage]; } else { - NSDictionary *elementUsagePageDict = (NSDictionary *)[hidUsageTable valueForKey:[NSString stringWithFormat:@"0x%04X", elementUsagePage]]; - elementName = (NSString *)[elementUsagePageDict valueForKey:[NSString stringWithFormat:@"0x%04X", elementUsage]]; + NSDictionary *elementUsagePageDict = (NSDictionary *)[hidUsageTable valueForKey:[NSString stringWithFormat:@"0x%04lX", (long)elementUsagePage]]; + elementName = (NSString *)[elementUsagePageDict valueForKey:[NSString stringWithFormat:@"0x%04lX", (long)elementUsage]]; } } else @@ -363,8 +363,8 @@ static NSDictionary *hidUsageTable = nil; NSInteger upperThreshold = (((logicalMax - logicalMin) * 2) / 3) + logicalMin; NSNumber *onState = [NSNumber numberWithBool:YES]; NSNumber *offState = [NSNumber numberWithBool:NO]; - NSString *elementCodeLowerThreshold = [NSString stringWithFormat:@"0x%04X/0x%04X/LowerThreshold", elementUsagePage, elementUsage]; - NSString *elementCodeUpperThreshold = [NSString stringWithFormat:@"0x%04X/0x%04X/UpperThreshold", elementUsagePage, elementUsage]; + NSString *elementCodeLowerThreshold = [NSString stringWithFormat:@"0x%04lX/0x%04lX/LowerThreshold", (long)elementUsagePage, (long)elementUsage]; + NSString *elementCodeUpperThreshold = [NSString stringWithFormat:@"0x%04lX/0x%04lX/UpperThreshold", (long)elementUsagePage, (long)elementUsage]; if (logicalValue <= lowerThreshold) { @@ -410,18 +410,18 @@ static NSDictionary *hidUsageTable = nil; NSNumber *onState = [NSNumber numberWithBool:YES]; NSNumber *offState = [NSNumber numberWithBool:NO]; - NSString *elementCodeFourWayUp = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-FourDirection", elementUsagePage, elementUsage, 0]; - NSString *elementCodeFourWayRight = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-FourDirection", elementUsagePage, elementUsage, 1]; - NSString *elementCodeFourWayDown = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-FourDirection", elementUsagePage, elementUsage, 2]; - NSString *elementCodeFourWayLeft = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-FourDirection", elementUsagePage, elementUsage, 3]; - NSString *elementCodeEightWayUp = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-EightDirection", elementUsagePage, elementUsage, 0]; - NSString *elementCodeEightWayUpRight = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-EightDirection", elementUsagePage, elementUsage, 1]; - NSString *elementCodeEightWayRight = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-EightDirection", elementUsagePage, elementUsage, 2]; - NSString *elementCodeEightWayDownRight = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-EightDirection", elementUsagePage, elementUsage, 3]; - NSString *elementCodeEightWayDown = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-EightDirection", elementUsagePage, elementUsage, 4]; - NSString *elementCodeEightWayDownLeft = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-EightDirection", elementUsagePage, elementUsage, 5]; - NSString *elementCodeEightWayLeft = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-EightDirection", elementUsagePage, elementUsage, 6]; - NSString *elementCodeEightWayUpLeft = [NSString stringWithFormat:@"0x%04X/0x%04X/%d-EightDirection", elementUsagePage, elementUsage, 7]; + NSString *elementCodeFourWayUp = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-FourDirection", (long)elementUsagePage, (long)elementUsage, 0]; + NSString *elementCodeFourWayRight = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-FourDirection", (long)elementUsagePage, (long)elementUsage, 1]; + NSString *elementCodeFourWayDown = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-FourDirection", (long)elementUsagePage, (long)elementUsage, 2]; + NSString *elementCodeFourWayLeft = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-FourDirection", (long)elementUsagePage, (long)elementUsage, 3]; + NSString *elementCodeEightWayUp = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-EightDirection", (long)elementUsagePage, (long)elementUsage, 0]; + NSString *elementCodeEightWayUpRight = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-EightDirection", (long)elementUsagePage, (long)elementUsage, 1]; + NSString *elementCodeEightWayRight = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-EightDirection", (long)elementUsagePage, (long)elementUsage, 2]; + NSString *elementCodeEightWayDownRight = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-EightDirection", (long)elementUsagePage, (long)elementUsage, 3]; + NSString *elementCodeEightWayDown = [NSString stringWithFormat:@"0x%04lXX/0x%04lX/%d-EightDirection",(long) (long)elementUsagePage, (long)elementUsage, 4]; + NSString *elementCodeEightWayDownLeft = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-EightDirection", (long)elementUsagePage, (long)elementUsage, 5]; + NSString *elementCodeEightWayLeft = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-EightDirection", (long)elementUsagePage, (long)elementUsage, 6]; + NSString *elementCodeEightWayUpLeft = [NSString stringWithFormat:@"0x%04lX/0x%04lX/%d-EightDirection", (long)elementUsagePage, (long)elementUsage, 7]; if (logicalMax == 3) { diff --git a/desmume/src/cocoa/cocoa_input.mm b/desmume/src/cocoa/cocoa_input.mm index 291abe9c9..f2a99bb6a 100644 --- a/desmume/src/cocoa/cocoa_input.mm +++ b/desmume/src/cocoa/cocoa_input.mm @@ -48,7 +48,7 @@ if (theCode == nil) { - deviceCode = [[NSString stringWithFormat:@"0x%08X", rand()] retain]; + deviceCode = [[NSString stringWithFormat:@"0x%08X", arc4random()] retain]; } else { @@ -497,7 +497,7 @@ case NSRightMouseDragged: case NSOtherMouseDragged: input = (CocoaDSInput *)[self.inputs valueForKey:@"NSEventMouse"]; - elementCode = [NSString stringWithFormat:@"%i", [event buttonNumber]]; + elementCode = [NSString stringWithFormat:@"%li", (long)[event buttonNumber]]; break; default: diff --git a/desmume/src/cocoa/userinterface/appDelegate.mm b/desmume/src/cocoa/userinterface/appDelegate.mm index 6915152b0..2b73b9e61 100644 --- a/desmume/src/cocoa/userinterface/appDelegate.mm +++ b/desmume/src/cocoa/userinterface/appDelegate.mm @@ -360,9 +360,9 @@ slotNumberKey = 0; } - NSMenuItem *mItem = [menu addItemWithTitle:[NSString stringWithFormat:NSSTRING_TITLE_SLOT_NUMBER, slotNumber] + NSMenuItem *mItem = [menu addItemWithTitle:[NSString stringWithFormat:NSSTRING_TITLE_SLOT_NUMBER, (unsigned long)slotNumber] action:nil - keyEquivalent:[NSString stringWithFormat:@"%d", slotNumberKey]]; + keyEquivalent:[NSString stringWithFormat:@"%ld", (unsigned long)slotNumberKey]]; [mItem setTarget:[mainWindow delegate]]; diff --git a/desmume/src/cocoa/userinterface/cheatWindowDelegate.mm b/desmume/src/cocoa/userinterface/cheatWindowDelegate.mm index 758741a08..fbf4d3c94 100644 --- a/desmume/src/cocoa/userinterface/cheatWindowDelegate.mm +++ b/desmume/src/cocoa/userinterface/cheatWindowDelegate.mm @@ -119,7 +119,7 @@ self.untitledCount++; if (self.untitledCount > 1) { - untitledString = [NSString stringWithFormat:@"Untitled %d", self.untitledCount]; + untitledString = [NSString stringWithFormat:@"Untitled %ld", (unsigned long)self.untitledCount]; } else { diff --git a/desmume/src/cocoa/userinterface/displayView.mm b/desmume/src/cocoa/userinterface/displayView.mm index 513abc38b..9d4b9bc97 100644 --- a/desmume/src/cocoa/userinterface/displayView.mm +++ b/desmume/src/cocoa/userinterface/displayView.mm @@ -597,7 +597,7 @@ enum OGLVertexAttributeID if (keyPressed && [theEvent window] != nil && [[[theEvent window] delegate] respondsToSelector:@selector(setStatus:)]) { - [[[theEvent window] delegate] setStatus:[NSString stringWithFormat:@"Keyboard:%i", [theEvent keyCode]]]; + [(EmuWindowDelegate *)[[theEvent window] delegate] setStatus:[NSString stringWithFormat:@"Keyboard:%i", [theEvent keyCode]]]; } isHandled = [self.cdsController setStateWithInput:inputAttributes]; @@ -619,8 +619,8 @@ enum OGLVertexAttributeID // and finally to DS touchscreen coordinates. NSPoint touchLoc = [self dsPointFromEvent:theEvent]; - NSString *elementCode = [NSString stringWithFormat:@"%i", [theEvent buttonNumber]]; - NSString *elementName = [NSString stringWithFormat:@"Button %i", [theEvent buttonNumber]]; + NSString *elementCode = [NSString stringWithFormat:@"%li", (long)[theEvent buttonNumber]]; + NSString *elementName = [NSString stringWithFormat:@"Button %li", (long)[theEvent buttonNumber]]; switch ([theEvent buttonNumber]) { @@ -652,7 +652,7 @@ enum OGLVertexAttributeID if (buttonPressed && [theEvent window] != nil && [[[theEvent window] delegate] respondsToSelector:@selector(setStatus:)]) { - [[[theEvent window] delegate] setStatus:[NSString stringWithFormat:@"Mouse:%i X:%i Y:%i", [theEvent buttonNumber], (NSInteger)(touchLoc.x), (NSInteger)(touchLoc.y)]]; + [(EmuWindowDelegate *)[[theEvent window] delegate] setStatus:[NSString stringWithFormat:@"Mouse:%li X:%li Y:%li", (long)[theEvent buttonNumber], (long)(touchLoc.x), (long)(touchLoc.y)]]; } isHandled = [self.cdsController setStateWithInput:inputAttributes]; diff --git a/desmume/src/cocoa/userinterface/emuWindowDelegate.mm b/desmume/src/cocoa/userinterface/emuWindowDelegate.mm index bc5433ae3..b67f01662 100644 --- a/desmume/src/cocoa/userinterface/emuWindowDelegate.mm +++ b/desmume/src/cocoa/userinterface/emuWindowDelegate.mm @@ -1319,7 +1319,7 @@ [cheatWindowBindings setValue:titleString forKey:@"cheatDBTitle"]; [cheatWindowBindings setValue:dateString forKey:@"cheatDBDate"]; - [cheatWindowBindings setValue:[NSString stringWithFormat:@"%d", [dbList count]] forKey:@"cheatDBItemCount"]; + [cheatWindowBindings setValue:[NSString stringWithFormat:@"%ld", (unsigned long)[dbList count]] forKey:@"cheatDBItemCount"]; } else { diff --git a/desmume/src/cocoa/userinterface/inputPrefsView.mm b/desmume/src/cocoa/userinterface/inputPrefsView.mm index 8e1d766d0..008b00060 100644 --- a/desmume/src/cocoa/userinterface/inputPrefsView.mm +++ b/desmume/src/cocoa/userinterface/inputPrefsView.mm @@ -119,8 +119,8 @@ - (BOOL) handleMouseDown:(NSEvent *)mouseEvent { BOOL isHandled = NO; - NSString *elementCode = [NSString stringWithFormat:@"%i", [mouseEvent buttonNumber]]; - NSString *elementName = [NSString stringWithFormat:@"Button %i", [mouseEvent buttonNumber]]; + NSString *elementCode = [NSString stringWithFormat:@"%li", (long)[mouseEvent buttonNumber]]; + NSString *elementName = [NSString stringWithFormat:@"Button %li", (long)[mouseEvent buttonNumber]]; switch ([mouseEvent buttonNumber]) { diff --git a/desmume/src/cocoa/userinterface/preferencesWindowDelegate.mm b/desmume/src/cocoa/userinterface/preferencesWindowDelegate.mm index ad5ce3355..7195f93fe 100644 --- a/desmume/src/cocoa/userinterface/preferencesWindowDelegate.mm +++ b/desmume/src/cocoa/userinterface/preferencesWindowDelegate.mm @@ -351,7 +351,7 @@ [cheatWindowBindings setValue:titleString forKey:@"cheatDBTitle"]; [cheatWindowBindings setValue:dateString forKey:@"cheatDBDate"]; - [cheatWindowBindings setValue:[NSString stringWithFormat:@"%d", [dbList count]] forKey:@"cheatDBItemCount"]; + [cheatWindowBindings setValue:[NSString stringWithFormat:@"%ld", (unsigned long)[dbList count]] forKey:@"cheatDBItemCount"]; } else {