PageRenderTime 33ms CodeModel.GetById 24ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/src/support/darwin_support.m

http://github.com/PerlGameDev/SDL
Objective C | 60 lines | 34 code | 16 blank | 10 comment | 0 complexity | bb08ef88bf6d2a3ae31b6989a35c0b1b MD5 | raw file
 1#include <Foundation/Foundation.h>
 2#include <AppKit/AppKit.h>
 3#include <setjmp.h>
 4
 5@interface perl_SDLMain : NSObject
 6@end
 7
 8@interface SDLApplication : NSApplication
 9@end
10
11static jmp_buf jmpbuf;
12
13@implementation perl_SDLMain
14
15- (void) applicationDidFinishLaunching: (NSNotification *) note
16{
17	fprintf(stderr,"Finished launching\n");
18//	longjmp(jmpbuf,1);
19}
20
21@end
22
23extern void setApplicationMenu(void);
24extern void setupWindowMenu(void);
25
26static NSAutoreleasePool* pool = NULL;
27static perl_SDLMain* perl_sdlMain = NULL;
28
29
30void
31init_ns_application()
32{
33	// Allocate pool so Cocoa can refcount
34	pool = [[NSAutoreleasePool alloc] init];
35
36	// Create the application
37	[SDLApplication sharedApplication];
38
39	[NSApp setMainMenu: [[NSMenu alloc] init]];
40//	setApplicationMenu();
41//	setupWindowMenu();
42
43	perl_sdlMain = [[perl_SDLMain alloc] init];
44	[NSApp setDelegate: perl_sdlMain];
45
46//	fprintf(stderr,"Calling [NSapp run]\n");
47//	if (0 == setjmp(jmpbuf)) {
48		[NSApp run];
49//	} else {
50//		fprintf(stderr, "Returned from that nasty [NSApp run]");
51//	}
52}
53
54void
55quit_ns_application()
56{
57	[perl_sdlMain release];
58	[pool release];
59}
60