5 |
|
Feel free to customize this file to suit your needs |
6 |
|
*/ |
7 |
|
|
8 |
< |
#import "SDL.h" |
9 |
< |
#import "SDLMain.h" |
10 |
< |
#import <sys/param.h> /* for MAXPATHLEN */ |
11 |
< |
#import <unistd.h> |
8 |
> |
#include "SDL.h" |
9 |
> |
#include "SDLMain.h" |
10 |
> |
#include <sys/param.h> /* for MAXPATHLEN */ |
11 |
> |
#include <unistd.h> |
12 |
|
|
13 |
|
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4, |
14 |
|
but the method still is there and works. To avoid warnings, we declare |
43 |
|
|
44 |
|
static NSString *getApplicationName(void) |
45 |
|
{ |
46 |
< |
NSDictionary *dict; |
46 |
> |
const NSDictionary *dict; |
47 |
|
NSString *appName = 0; |
48 |
|
|
49 |
|
/* Determine the application name */ |
50 |
< |
dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle()); |
50 |
> |
dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle()); |
51 |
|
if (dict) |
52 |
|
appName = [dict objectForKey: @"CFBundleName"]; |
53 |
|
|
64 |
|
@end |
65 |
|
#endif |
66 |
|
|
67 |
< |
@interface SDLApplication : NSApplication |
67 |
> |
@interface NSApplication (SDLApplication) |
68 |
|
@end |
69 |
|
|
70 |
< |
@implementation SDLApplication |
70 |
> |
@implementation NSApplication (SDLApplication) |
71 |
|
/* Invoked from the Quit menu item */ |
72 |
|
- (void)terminate:(id)sender |
73 |
|
{ |
87 |
|
if (shouldChdir) |
88 |
|
{ |
89 |
|
char parentdir[MAXPATHLEN]; |
90 |
< |
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); |
91 |
< |
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); |
92 |
< |
if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) { |
93 |
< |
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */ |
94 |
< |
} |
95 |
< |
CFRelease(url); |
96 |
< |
CFRelease(url2); |
97 |
< |
} |
98 |
< |
|
90 |
> |
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); |
91 |
> |
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); |
92 |
> |
if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) { |
93 |
> |
chdir(parentdir); /* chdir to the binary app's parent */ |
94 |
> |
} |
95 |
> |
CFRelease(url); |
96 |
> |
CFRelease(url2); |
97 |
> |
} |
98 |
|
} |
99 |
|
|
100 |
|
#if SDL_USE_NIB_FILE |
119 |
|
if ([menuItem hasSubmenu]) |
120 |
|
[self fixMenu:[menuItem submenu] withAppName:appName]; |
121 |
|
} |
123 |
– |
[ aMenu sizeToFit ]; |
122 |
|
} |
123 |
|
|
124 |
|
#else |
201 |
|
SDLMain *sdlMain; |
202 |
|
|
203 |
|
/* Ensure the application object is initialised */ |
204 |
< |
[SDLApplication sharedApplication]; |
204 |
> |
[NSApplication sharedApplication]; |
205 |
|
|
206 |
|
#ifdef SDL_USE_CPS |
207 |
|
{ |
210 |
|
if (!CPSGetCurrentProcess(&PSN)) |
211 |
|
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) |
212 |
|
if (!CPSSetFrontProcess(&PSN)) |
213 |
< |
[SDLApplication sharedApplication]; |
213 |
> |
[NSApplication sharedApplication]; |
214 |
|
} |
215 |
|
#endif /* SDL_USE_CPS */ |
216 |
|
|
317 |
|
NSString *result; |
318 |
|
|
319 |
|
bufferSize = selfLen + aStringLen - aRange.length; |
320 |
< |
buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar)); |
320 |
> |
buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar)); |
321 |
|
|
322 |
|
/* Get first part into buffer */ |
323 |
|
localRange.location = 0; |
344 |
|
|
345 |
|
@end |
346 |
|
|
347 |
< |
// This is used from video_sdl.cpp. |
350 |
< |
void NSAutoReleasePool_wrap(void (*fn)(void)) |
351 |
< |
{ |
352 |
< |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
353 |
< |
fn(); |
354 |
< |
[pool release]; |
355 |
< |
} |
347 |
> |
|
348 |
|
|
349 |
|
#ifdef main |
350 |
|
# undef main |
372 |
|
} |
373 |
|
|
374 |
|
#if SDL_USE_NIB_FILE |
383 |
– |
[SDLApplication poseAsClass:[NSApplication class]]; |
375 |
|
NSApplicationMain (argc, argv); |
376 |
|
#else |
377 |
|
CustomApplicationMain (argc, argv); |