1 #import <Cocoa/Cocoa.h>
8 void factorvm::c_to_factor_toplevel(cell quot)
13 c_to_factor(quot,this);
16 dpush(allot_alien(F,(cell)localException));
17 quot = userenv[COCOA_EXCEPTION_ENV];
18 if(!tagged<object>(quot).type_p(QUOTATION_TYPE))
20 /* No Cocoa exception handler was registered, so
21 extra/cocoa/ is not loaded. So we pass the exception
23 [localException raise];
32 Gestalt(gestaltSystemVersion,&version);
35 printf("Factor requires Mac OS X 10.5 or later.\n");
39 [[NSAutoreleasePool alloc] init];
42 const char *vm_executable_path(void)
44 return [[[NSBundle mainBundle] executablePath] UTF8String];
47 const char *default_image_path(void)
49 NSBundle *bundle = [NSBundle mainBundle];
50 NSString *path = [bundle bundlePath];
51 NSString *executable = [[bundle executablePath] lastPathComponent];
52 NSString *image = [executable stringByAppendingString:@".image"];
56 if([path hasSuffix:@".app"] || [path hasSuffix:@".app/"])
58 NSFileManager *mgr = [NSFileManager defaultManager];
60 NSString *imageInBundle = [[path stringByAppendingPathComponent:@"Contents/Resources"] stringByAppendingPathComponent:image];
61 NSString *imageAlongBundle = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:image];
63 returnVal = ([mgr fileExistsAtPath:imageInBundle]
64 ? imageInBundle : imageAlongBundle);
67 returnVal = [path stringByAppendingPathComponent:image];
69 return [returnVal UTF8String];
72 void init_signals(void)
78 /* Amateurs at Apple: implement this function, properly! */
79 Protocol *objc_getProtocol(char *name)
81 if(strcmp(name,"NSTextInput") == 0)
82 return @protocol(NSTextInput);