Fix more stuff, make things build and run on 64-bit!

This commit is contained in:
Nate Weaver 2012-07-04 16:00:27 -05:00
parent d699ed31f5
commit 26fff1be9a
8 changed files with 59 additions and 49 deletions

View File

@ -21,7 +21,7 @@
}
- (id)firstObjectReturningValue:(id)value forKey:(id)key
{
int index = [[self valueForKey:key] indexOfObject:value];
NSUInteger index = [[self valueForKey:key] indexOfObject:value];
if(index != NSNotFound)
return [self objectAtIndex:index];
else return nil;
@ -211,7 +211,7 @@
NSMutableArray *items = [NSMutableArray array];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
NSIndexSet *indicies = [self selectedRowIndexes];
unsigned int rowIndex = [indicies firstIndex];
NSUInteger rowIndex = [indicies firstIndex];
while (rowIndex != NSNotFound)
{
[items addObject:[self itemAtRow:rowIndex]];
@ -272,10 +272,13 @@
/* CGLContext access for pre-10.3 */
@implementation NSOpenGLContext (CGLContextAccess)
- (CGLContextObj)cglContext;
- (CGLContextObj)cglContext
{
#if !__LP64__
if(NSAppKitVersionNumber < 700.0)
return _contextAuxiliary;
else return (CGLContextObj) [self CGLContextObj];
else
#endif
return (CGLContextObj) [self CGLContextObj];
}
@end

View File

@ -61,7 +61,7 @@ extern NSString *RKResourcePboardType;
BOOL succeeded = NO;
OSStatus error = noErr;
FSRef *fileRef = (FSRef *) NewPtrClear(sizeof(FSRef));
SInt16 fileRefNum = 0;
ResFileRefNum fileRefNum = 0;
OpenPanelDelegate *openPanelDelegate = [(ApplicationDelegate *)[NSApp delegate] openPanelDelegate];
// bug: need to handle error better here
@ -157,7 +157,7 @@ extern NSString *RKResourcePboardType;
// get creator and type
FSCatalogInfo info;
error = FSGetCatalogInfo(fileRef, kFSCatInfoFinderInfo, &info, nil, nil, nil);
error = FSGetCatalogInfo(fileRef, kFSCatInfoFinderInfo, &info, NULL, NULL, NULL);
if(!error)
{
[self setType:[NSData dataWithBytes:&((FileInfo *)info.finderInfo)->fileType length:4]];
@ -173,7 +173,7 @@ extern NSString *RKResourcePboardType;
NSString *forkName;
NSEnumerator *forkEnumerator = [forks objectEnumerator];
NSString *selectedFork = [NSString stringWithCharacters:fork->unicode length:fork->length];
while(forkName = [[forkEnumerator nextObject] objectForKey:@"forkname"])
while((forkName = [[forkEnumerator nextObject] objectForKey:@"forkname"]))
{
// check current fork is not the fork we're going to parse
if(![forkName isEqualToString:selectedFork])
@ -182,7 +182,7 @@ extern NSString *RKResourcePboardType;
// tidy up loose ends
if(fileRefNum) FSCloseFork(fileRefNum);
DisposePtr((Ptr) fileRef);
//DisposePtr((Ptr) fileRef);
return succeeded;
}
@ -217,7 +217,7 @@ extern NSString *RKResourcePboardType;
if(!buffer) return NO;
// read fork contents into buffer, bug: assumes no errors
SInt16 forkRefNum;
FSIORefNum forkRefNum;
FSOpenFork(fileRef, uniForkName.length, uniForkName.unicode, fsRdPerm, &forkRefNum);
FSReadFork(forkRefNum, fsFromStart, 0, forkLength, buffer, &forkLength);
FSCloseFork(forkRefNum);
@ -352,7 +352,7 @@ extern NSString *RKResourcePboardType;
else error = FSOpenResourceFile(fileRef, 0, NULL, fsWrPerm, &fileRefNum);
}
// else NSLog(@"error creating resource fork. (error=%d, spec=%d, ref=%d, parent=%d)", error, fileSpec, fileRef, parentRef);
else NSLog(@"error creating resource fork. (error=%d, ref=%d)", error, fileRef);
else NSLog(@"error creating resource fork. (error=%d, ref=%p)", error, fileRef);
// write resource array to file
if(fileRefNum && !error)
@ -438,7 +438,7 @@ extern NSString *RKResourcePboardType;
// convert unicode name to pascal string
nameStr[0] = [[resource name] lengthOfBytesUsingEncoding:NSMacOSRomanStringEncoding];
BlockMoveData([[resource name] cStringUsingEncoding:NSMacOSRomanStringEncoding], &nameStr[1], nameStr[0]);
memmove(&nameStr[1], [[resource name] cStringUsingEncoding:NSMacOSRomanStringEncoding], nameStr[0]);
// convert type string to ResType
[[resource type] getCString:resTypeStr maxLength:4];
@ -479,30 +479,24 @@ extern NSString *RKResourcePboardType;
- (void)setTypeCreatorAfterSave:(id)userInfo
{
FInfo finderInfo;
FSRef *fileRef = (FSRef *) NewPtrClear(sizeof(FSRef));
FSSpec *fileSpec = (FSSpec *) NewPtrClear(sizeof(FSSpec));
OSStatus error = FSPathMakeRef((const UInt8 *)[[self fileName] UTF8String], fileRef, nil);
if(!error)
{
error = FSGetCatalogInfo(fileRef, kFSCatInfoNone, NULL, NULL, fileSpec, NULL);
FSCatalogInfo info;
error = FSGetCatalogInfo(fileRef, kFSCatInfoFinderInfo, &info, NULL, NULL, NULL);
if(!error)
{
error = FSpGetFInfo(fileSpec, &finderInfo);
if(!error)
{
[[self type] getBytes:&finderInfo.fdType length:4];
[[self creator] getBytes:&finderInfo.fdCreator length:4];
// NSLog(@"setting finder info to type: %X; creator: %X", finderInfo.fdType, finderInfo.fdCreator);
error = FSpSetFInfo(fileSpec, &finderInfo);
FSpGetFInfo(fileSpec, &finderInfo);
// NSLog(@"finder info got set to type: %X; creator: %X", finderInfo.fdType, finderInfo.fdCreator);
}
else NSLog(@"error getting Finder info. (error=%d, spec=%d, ref=%d)", error, fileSpec, fileRef);
FInfo *finderInfo = (FInfo *)(info.finderInfo);
[[self type] getBytes:&finderInfo->fdType length:4];
[[self creator] getBytes:&finderInfo->fdCreator length:4];
// NSLog(@"setting finder info to type: %X; creator: %X", finderInfo.fdType, finderInfo.fdCreator);
FSSetCatalogInfo(fileRef, kFSCatInfoFinderInfo, &info);
// NSLog(@"finder info got set to type: %X; creator: %X", finderInfo.fdType, finderInfo.fdCreator);
}
else NSLog(@"error converting fsref to fsspec. (error=%d, spec=%d, ref=%d)", error, fileSpec, fileRef);
else NSLog(@"error getting Finder info. (error=%d, ref=%p)", error, fileRef);
}
else NSLog(@"error making fsref from file path. (error=%d, ref=%d, path=%@)", error, fileRef, [self fileName]);
else NSLog(@"error making fsref from file path. (error=%d, ref=%p, path=%@)", error, fileRef, [self fileName]);
}
#pragma mark -
@ -1030,8 +1024,9 @@ static NSString *RKExportItemIdentifier = @"com.nickshanks.resknife.toolbar.exp
if(data && [data length] != 0)
{
// plays sound synchronously, thread exits when sound is done playing
SndListPtr sndPtr = (SndListPtr) [data bytes];
SndPlay(nil, &sndPtr, false);
//SndListPtr sndPtr = (SndListPtr) [data bytes];
//SndPlay(nil, &sndPtr, false);
[[[[NSSound alloc] initWithData:data] autorelease] play];
}
else NSBeep();
[pool release];

View File

@ -72,7 +72,7 @@
</object>
<object class="NSDrawer" id="939552876">
<nil key="NSNextResponder"/>
<string key="NSContentSize">{200, 186}</string>
<string key="NSContentSize">{200, 207}</string>
<string key="NSMinContentSize">{58, 50}</string>
<string key="NSMaxContentSize">{58, 0}</string>
<int key="NSPreferredEdge">0</int>
@ -82,7 +82,7 @@
<nil key="NSDelegate"/>
</object>
<object class="NSCustomView" id="842202587">
<nil key="NSNextResponder"/>
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSScrollView" id="837390482">
@ -98,6 +98,8 @@
<int key="NSvFlags">8448</int>
<string key="NSFrameSize">{56, 205}</string>
<reference key="NSSuperview" ref="333315727"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="NSEnabled">YES</bool>
<object class="_NSCornerView" key="NSCornerView">
<nil key="NSNextResponder"/>
@ -184,6 +186,7 @@
</array>
<string key="NSFrame">{{1, 1}, {56, 205}}</string>
<reference key="NSSuperview" ref="837390482"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="362189248"/>
<reference key="NSDocView" ref="362189248"/>
<object class="NSColor" key="NSBGColor" id="549723558">
@ -202,6 +205,8 @@
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{-22, 1}, {11, 186}}</string>
<reference key="NSSuperview" ref="837390482"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="333315727"/>
<int key="NSsFlags">256</int>
<reference key="NSTarget" ref="837390482"/>
<string key="NSAction">_doScroller:</string>
@ -212,6 +217,8 @@
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{-100, -100}, {75, 11}}</string>
<reference key="NSSuperview" ref="837390482"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1029464843"/>
<int key="NSsFlags">257</int>
<reference key="NSTarget" ref="837390482"/>
<string key="NSAction">_doScroller:</string>
@ -220,7 +227,8 @@
</array>
<string key="NSFrameSize">{58, 207}</string>
<reference key="NSSuperview" ref="842202587"/>
<reference key="NSNextKeyView" ref="333315727"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="722969521"/>
<int key="NSsFlags">133650</int>
<reference key="NSVScroller" ref="1029464843"/>
<reference key="NSHScroller" ref="722969521"/>
@ -229,6 +237,9 @@
</object>
</array>
<string key="NSFrameSize">{58, 207}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="837390482"/>
<object class="NSMutableString" key="NSClassName">
<characters key="NS.bytes">NSView</characters>
</object>

View File

@ -80,7 +80,7 @@ UInt32 TableChecksum(UInt32 *table, UInt32 length)
if(![[resource name] isEqualToString:@""])
{
[[self window] setTitle:[resource name]];
SetWindowAlternateTitle((WindowRef) [[self window] windowRef], (CFStringRef) [NSString stringWithFormat:NSLocalizedString(@"%@ %@: '%@'", nil), [resource type], [resource resID], [resource name]]);
//SetWindowAlternateTitle((WindowRef) [[self window] windowRef], (CFStringRef) [NSString stringWithFormat:NSLocalizedString(@"%@ %@: '%@'", nil), [resource type], [resource resID], [resource name]]);
}
// we don't want this notification until we have a window! (Only register for notifications on the resource we're editing)

View File

@ -2,8 +2,8 @@
#import <Carbon/Carbon.h>
#pragma options align=mac68k
//#pragma options align=packed // TODO: This doesn't compile in PB (but it does in xCode).
//#pragma options align=mac68k
#pragma options align=packed // TODO: This doesn't compile in PB (but it does in xCode).
// see http://developer.apple.com/techpubs/macosx/DeveloperTools/MachORuntime/2rt_powerpc_abi/PowerPC_Data_Alignment.html
// align=reset is at the bottom of the file.

View File

@ -569,10 +569,10 @@
charRec->startDay = [date dayOfMonth];
charRec->startMonth = [date monthOfYear];
charRec->startYear = [date yearOfCommonEra];
BlockZero( charRec->Prefix, 16 );
BlockMoveData( [prefix cString], charRec->Prefix, [prefix cStringLength] <= 15? [prefix cStringLength]+1:16 );
BlockZero( charRec->Suffix, 16 );
BlockMoveData( [suffix cString], charRec->Suffix, [suffix cStringLength] <= 15? [suffix cStringLength]+1:16 );
bzero( charRec->Prefix, 16 );
memmove( charRec->Prefix, [prefix cString], [prefix cStringLength] <= 15? [prefix cStringLength]+1:16 );
bzero( charRec->Suffix, 16 );
memmove( charRec->Suffix, [suffix cString], [suffix cStringLength] <= 15? [suffix cStringLength]+1:16 );
charRec->startSystem[0] = [start1 shortValue];
charRec->startSystem[1] = [start2 shortValue];
charRec->startSystem[2] = [start3 shortValue];
@ -594,9 +594,9 @@
charRec->introPictDelay[1] = [introDelay2 shortValue];
charRec->introPictDelay[2] = [introDelay3 shortValue];
charRec->introPictDelay[3] = [introDelay4 shortValue];
BlockZero( charRec->OnStart, 256 );
BlockMoveData( [onStart cString], charRec->OnStart, [onStart cStringLength] <= 255? [onStart cStringLength]+1:256 );
BlockZero( charRec->UnusedA, 8*sizeof(short) );
bzero( charRec->OnStart, 256 );
memmove( charRec->OnStart, [onStart cString], [onStart cStringLength] <= 255? [onStart cStringLength]+1:256 );
bzero( charRec->UnusedA, 8*sizeof(short) );
// verify values are valid
if(charRec->startDay < 1 || charRec->startDay > 31 )

View File

@ -2331,7 +2331,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
@ -2344,7 +2343,6 @@
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
@ -2362,14 +2360,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PNG Editor/PNG Editor-Prefix.pch";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
@ -2781,7 +2777,10 @@
E13F7F0608F0411100E2A5CB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_VERSION = 4.0;
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
GCC_VERSION = "";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_SIGN_COMPARE = YES;
SDKROOT = macosx;
};
name = Debug;
@ -2789,8 +2788,10 @@
E13F7F0708F0411100E2A5CB /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_VERSION = 4.0;
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_VERSION = "";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_SIGN_COMPARE = YES;
SDKROOT = macosx;
};
name = Release;