Cocoa Port:

- Actually use -Ofast and -fvectorize in the Xcode 5 project.
- Replace data type unsigned int with size_t where appropriate.
- Do some minor code cleanup.
This commit is contained in:
rogerman 2013-06-26 04:53:22 +00:00
parent 2469ecb419
commit 56130bec27
13 changed files with 46 additions and 50 deletions

View File

@ -1842,7 +1842,7 @@
LastUpgradeCheck = 0460;
ORGANIZATIONNAME = "DeSmuME Team";
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "DeSmuME (XCode 4)" */;
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "DeSmuME (Xcode 5)" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
@ -2781,7 +2781,7 @@
GCC_FAST_MATH = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
GCC_OPTIMIZATION_LEVEL = 3;
GCC_OPTIMIZATION_LEVEL = fast;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = DeSmuME_Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = NDEBUG;
@ -2797,6 +2797,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Info.plist;
LD_NO_PIE = YES;
LLVM_VECTORIZE_LOOPS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
PRODUCT_NAME = DeSmuME;
SDKROOT = macosx;
@ -2835,7 +2836,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "DeSmuME (XCode 4)" */ = {
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "DeSmuME (Xcode 5)" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C01FCF4F08A954540054247B /* Debug */,

View File

@ -424,7 +424,7 @@ static NSImage *iconCodeBreaker = nil;
- (NSString *) memAddressString
{
return [NSString stringWithFormat:@"0x%08X", self.memAddress];
return [NSString stringWithFormat:@"0x%08X", (unsigned int)self.memAddress];
}
- (void) setMemAddressString:(NSString *)addressString
@ -446,7 +446,7 @@ static NSImage *iconCodeBreaker = nil;
- (NSString *) memAddressSixDigitString
{
return [NSString stringWithFormat:@"%06X", (self.memAddress & 0x00FFFFFF)];
return [NSString stringWithFormat:@"%06X", (unsigned int)(self.memAddress & 0x00FFFFFF)];
}
- (void) setMemAddressSixDigitString:(NSString *)addressString

View File

@ -34,7 +34,7 @@ typedef struct
void *cdsController;
int state;
bool isFrameSkipEnabled;
unsigned int frameCount;
size_t frameCount;
unsigned int framesToSkip;
uint64_t timeBudgetMachAbsTime;
bool exitThread;

View File

@ -36,7 +36,7 @@
return self;
}
for (unsigned int i = 0; i < DSControllerState_StatesCount; i++)
for (size_t i = 0; i < DSControllerState_StatesCount; i++)
{
controllerState[i] = false;
}
@ -95,7 +95,7 @@
const NSInteger theMicMode = micMode;
static bool flushedStates[DSControllerState_StatesCount] = {0};
for (unsigned int i = 0; i < DSControllerState_StatesCount; i++)
for (size_t i = 0; i < DSControllerState_StatesCount; i++)
{
flushedStates[i] = controllerState[i];
}

View File

@ -37,8 +37,8 @@ typedef struct
typedef struct
{
NSInteger displayModeID;
unsigned int width; // Measured in pixels
unsigned int height; // Measured in pixels
size_t width; // Measured in pixels
size_t height; // Measured in pixels
} DisplaySrcPixelAttributes;
@interface CocoaDSOutput : CocoaDSThread

View File

@ -556,7 +556,7 @@
gpuData = [[NSData alloc] initWithBytes:GPU_screen length:GPU_SCREEN_SIZE_BYTES * 2];
}
DisplaySrcPixelAttributes attr = {displayModeID, (unsigned int)displayFrameSize.width, (unsigned int)displayFrameSize.height};
DisplaySrcPixelAttributes attr = {displayModeID, (size_t)displayFrameSize.width, (size_t)displayFrameSize.height};
NSData *attributesData = [[NSData alloc] initWithBytes:&attr length:sizeof(DisplaySrcPixelAttributes)];
NSArray *messageComponents = [[NSArray alloc] initWithObjects:gpuData, attributesData, nil];
@ -665,15 +665,9 @@
- (void) fillVideoFrameWithColor:(UInt16)colorValue
{
NSData *gpuData = nil;
NSInteger displayModeID = [self displayMode];
NSSize displayFrameSize = [self frameSize];
size_t numberBytes = GPU_SCREEN_SIZE_BYTES * 2;
if (displayModeID == DS_DISPLAY_TYPE_MAIN || displayModeID == DS_DISPLAY_TYPE_TOUCH)
{
numberBytes = GPU_SCREEN_SIZE_BYTES;
}
const NSInteger displayModeID = [self displayMode];
const NSSize displayFrameSize = [self frameSize];
const size_t numberBytes = (displayModeID == DS_DISPLAY_TYPE_COMBO) ? GPU_SCREEN_SIZE_BYTES * 2 : GPU_SCREEN_SIZE_BYTES;
UInt16 *gpuBytes = (UInt16 *)malloc(numberBytes);
if (gpuBytes == NULL)
@ -683,15 +677,16 @@
const UInt16 colorValuePattern[] = {colorValue, colorValue, colorValue, colorValue, colorValue, colorValue, colorValue, colorValue};
memset_pattern16(gpuBytes, colorValuePattern, numberBytes);
gpuData = [[[NSData alloc] initWithBytes:gpuBytes length:numberBytes] autorelease];
NSData *gpuData = [[NSData alloc] initWithBytes:gpuBytes length:numberBytes];
free(gpuBytes);
gpuBytes = nil;
DisplaySrcPixelAttributes attr = {displayModeID, (unsigned int)displayFrameSize.width, (unsigned int)displayFrameSize.height};
DisplaySrcPixelAttributes attr = {displayModeID, (size_t)displayFrameSize.width, (size_t)displayFrameSize.height};
NSData *attributesData = [[[NSData alloc] initWithBytes:&attr length:sizeof(DisplaySrcPixelAttributes)] autorelease];
[self handleEmuFrameProcessed:gpuData attributes:attributesData];
[gpuData release];
}
- (NSImage *) image

View File

@ -53,7 +53,7 @@
- (NSString *) internalName;
- (NSString *) serial;
- (NSString *) developerName;
- (NSString *) developerNameWithCode;
- (NSString *) developerNameAndCode;
- (NSImage *) icon;
- (void) handleAdvansceneDatabaseInfo;

View File

@ -45,7 +45,7 @@
return self;
}
vf = new VideoFilter((unsigned int)theSize.width, (unsigned int)theSize.height, typeID, numThreads);
vf = new VideoFilter((size_t)theSize.width, (size_t)theSize.height, typeID, numThreads);
currentFilterType = typeID;
return self;
@ -61,7 +61,7 @@
{
BOOL result = NO;
bool cResult = vf->SetSourceSize((unsigned int)theSize.width, (unsigned int)theSize.height);
bool cResult = vf->SetSourceSize((size_t)theSize.width, (size_t)theSize.height);
if (cResult)
{
result = YES;

View File

@ -127,7 +127,7 @@ InputAttributes InputAttributesOfHIDValue(IOHIDValueRef hidValueRef, const char
InputAttributesList InputListFromHIDValue(IOHIDValueRef hidValueRef);
InputAttributesList InputListFromHatSwitchValue(IOHIDValueRef hidValueRef, bool useEightDirection);
unsigned int ClearHIDQueue(const IOHIDQueueRef hidQueue);
size_t ClearHIDQueue(const IOHIDQueueRef hidQueue);
void HandleQueueValueAvailableCallback(void *inContext, IOReturn inResult, void *inSender);
#pragma mark -

View File

@ -407,9 +407,9 @@ InputAttributesList InputListFromHatSwitchValue(IOHIDValueRef hidValueRef, bool
bool offState = false;
char elementCodeFourWay[4][256];
for (unsigned int i = 0; i < 4; i++)
for (size_t i = 0; i < 4; i++)
{
snprintf(elementCodeFourWay[i], 256, "0x%04lX/0x%04lX/%d-FourDirection", (long)elementUsagePage, (long)elementUsage, i);
snprintf(elementCodeFourWay[i], 256, "0x%04lX/0x%04lX/%d-FourDirection", (long)elementUsagePage, (long)elementUsage, (unsigned int)i);
}
const char *elementNameFourWay[4] = {
@ -419,9 +419,9 @@ InputAttributesList InputListFromHatSwitchValue(IOHIDValueRef hidValueRef, bool
"Hatswitch - Left" };
char elementCodeEightWay[8][256];
for (unsigned int i = 0; i < 8; i++)
for (size_t i = 0; i < 8; i++)
{
snprintf(elementCodeEightWay[i], 256, "0x%04lX/0x%04lX/%d-EightDirection", (long)elementUsagePage, (long)elementUsage, i);
snprintf(elementCodeEightWay[i], 256, "0x%04lX/0x%04lX/%d-EightDirection", (long)elementUsagePage, (long)elementUsage, (unsigned int)i);
}
const char *elementNameEightWay[8] = {
@ -436,18 +436,18 @@ InputAttributesList InputListFromHatSwitchValue(IOHIDValueRef hidValueRef, bool
if (logicalMax == 3)
{
for (unsigned int i = 0; i <= (unsigned int)logicalMax; i++)
for (size_t i = 0; i <= (size_t)logicalMax; i++)
{
inputList.push_back(InputAttributesOfHIDValue(hidValueRef, elementCodeFourWay[i], elementNameFourWay[i], (i == (unsigned int)logicalValue) ? &onState : &offState));
inputList.push_back(InputAttributesOfHIDValue(hidValueRef, elementCodeFourWay[i], elementNameFourWay[i], (i == (size_t)logicalValue) ? &onState : &offState));
}
}
else if (logicalMax == 7)
{
if (useEightDirection)
{
for (unsigned int i = 0; i <= (unsigned int)logicalMax; i++)
for (size_t i = 0; i <= (size_t)logicalMax; i++)
{
inputList.push_back(InputAttributesOfHIDValue(hidValueRef, elementCodeEightWay[i], elementNameEightWay[i], (i == (unsigned int)logicalValue) ? &onState : &offState));
inputList.push_back(InputAttributesOfHIDValue(hidValueRef, elementCodeEightWay[i], elementNameEightWay[i], (i == (size_t)logicalValue) ? &onState : &offState));
}
}
else
@ -596,9 +596,9 @@ BOOL GetOnStateFromHIDValueRef(IOHIDValueRef hidValueRef)
return onState;
}
unsigned int ClearHIDQueue(const IOHIDQueueRef hidQueue)
size_t ClearHIDQueue(const IOHIDQueueRef hidQueue)
{
unsigned int hidInputClearCount = 0;
size_t hidInputClearCount = 0;
if (hidQueue == nil)
{
@ -1105,7 +1105,7 @@ static std::tr1::unordered_map<unsigned short, std::string> keyboardNameTable; /
const size_t inputCount = inputList->size();
for (unsigned int i = 0; i < inputCount; i++)
for (size_t i = 0; i < inputCount; i++)
{
const InputAttributes &inputAttr = (*inputList)[i];
if (inputAttr.state != INPUT_ATTRIBUTE_STATE_ON)
@ -1201,9 +1201,9 @@ static std::tr1::unordered_map<unsigned short, std::string> keyboardNameTable; /
- (CommandAttributesList) generateCommandListUsingInputList:(const InputAttributesList *)inputList
{
CommandAttributesList cmdList;
size_t inputCount = inputList->size();
const size_t inputCount = inputList->size();
for (unsigned int i = 0; i < inputCount; i++)
for (size_t i = 0; i < inputCount; i++)
{
const InputAttributes &inputAttr = (*inputList)[i];
@ -1790,8 +1790,8 @@ InputAttributesList InputManagerEncodeHIDQueue(const IOHIDQueueRef hidQueue)
hidInputList = InputListFromHIDValue(hidValueRef);
}
size_t hidInputCount = hidInputList.size();
for (unsigned int i = 0; i < hidInputCount; i++)
const size_t hidInputCount = hidInputList.size();
for (size_t i = 0; i < hidInputCount; i++)
{
if (hidInputList[i].deviceCode[0] == '\0' || hidInputList[i].elementCode[0] == '\0')
{

View File

@ -427,7 +427,7 @@
InputAttributesList inputList = InputManagerEncodeHIDQueue(hidQueue);
const size_t inputCount = inputList.size();
for (unsigned int i = 0; i < inputCount; i++)
for (size_t i = 0; i < inputCount; i++)
{
const InputAttributes &inputAttr = inputList[i];
char inputKey[INPUT_HANDLER_STRING_LENGTH*2];

View File

@ -171,7 +171,7 @@ inline uint32_t RGBA8888ForceOpaque(const uint32_t color32)
destBuffer - Pointer to the destination 32-bit RGBA8888 pixel buffer.
numberPixels - The number of pixels to copy.
pixelCount - The number of pixels to copy.
Returns:
Nothing.
@ -181,9 +181,9 @@ inline uint32_t RGBA8888ForceOpaque(const uint32_t color32)
Also, it is the caller's responsibility to ensure that the source and destination
buffers are large enough to accomodate the requested number of pixels.
********************************************************************************************/
void RGB555ToRGBA8888Buffer(const uint16_t *__restrict__ srcBuffer, uint32_t *__restrict__ destBuffer, unsigned int numberPixels)
void RGB555ToRGBA8888Buffer(const uint16_t *__restrict__ srcBuffer, uint32_t *__restrict__ destBuffer, size_t pixelCount)
{
const uint32_t *__restrict__ destBufferEnd = destBuffer + numberPixels;
const uint32_t *__restrict__ destBufferEnd = destBuffer + pixelCount;
while (destBuffer < destBufferEnd)
{
@ -202,7 +202,7 @@ void RGB555ToRGBA8888Buffer(const uint16_t *__restrict__ srcBuffer, uint32_t *__
destBuffer - Pointer to the destination 32-bit RGBA8888 pixel buffer.
numberPixels - The number of pixels to copy.
pixelCount - The number of pixels to copy.
Returns:
Nothing.
@ -212,9 +212,9 @@ void RGB555ToRGBA8888Buffer(const uint16_t *__restrict__ srcBuffer, uint32_t *__
Also, it is the caller's responsibility to ensure that the source and destination
buffers are large enough to accomodate the requested number of pixels.
********************************************************************************************/
void RGBA8888ForceOpaqueBuffer(const uint32_t *__restrict__ srcBuffer, uint32_t *__restrict__ destBuffer, unsigned int numberPixels)
void RGBA8888ForceOpaqueBuffer(const uint32_t *__restrict__ srcBuffer, uint32_t *__restrict__ destBuffer, size_t pixelCount)
{
const uint32_t *__restrict__ destBufferEnd = destBuffer + numberPixels;
const uint32_t *__restrict__ destBufferEnd = destBuffer + pixelCount;
while (destBuffer < destBufferEnd)
{

View File

@ -31,8 +31,8 @@ bool IsOSXVersionSupported(const unsigned int major, const unsigned int minor, c
uint32_t RGB555ToRGBA8888(const uint16_t color16);
uint32_t RGBA8888ForceOpaque(const uint32_t color32);
void RGB555ToRGBA8888Buffer(const uint16_t *__restrict__ srcBuffer, uint32_t *__restrict__ destBuffer, unsigned int numberPixels);
void RGBA8888ForceOpaqueBuffer(const uint32_t *__restrict__ srcBuffer, uint32_t *__restrict__ destBuffer, unsigned int numberPixels);
void RGB555ToRGBA8888Buffer(const uint16_t *__restrict__ srcBuffer, uint32_t *__restrict__ destBuffer, size_t pixelCount);
void RGBA8888ForceOpaqueBuffer(const uint32_t *__restrict__ srcBuffer, uint32_t *__restrict__ destBuffer, size_t pixelCount);
CGSize GetTransformedBounds(const double normalBoundsWidth, const double normalBoundsHeight,
const double scalar,