1 #import <Cocoa/Cocoa.h>
3 #include <mach/mach_time.h>
9 void factor_vm::c_to_factor_toplevel(cell quot)
14 c_to_factor(quot,this);
17 dpush(allot_alien(false_object,(cell)localException));
18 quot = special_objects[OBJ_COCOA_EXCEPTION];
19 if(!tagged<object>(quot).type_p(QUOTATION_TYPE))
21 /* No Cocoa exception handler was registered, so
22 extra/cocoa/ is not loaded. So we pass the exception
24 [localException raise];
33 Gestalt(gestaltSystemVersion,&version);
36 printf("Factor requires Mac OS X 10.5 or later.\n");
40 [[NSAutoreleasePool alloc] init];
43 const char *vm_executable_path(void)
45 return [[[NSBundle mainBundle] executablePath] UTF8String];
48 const char *default_image_path(void)
50 NSBundle *bundle = [NSBundle mainBundle];
51 NSString *path = [bundle bundlePath];
52 NSString *executable = [[bundle executablePath] lastPathComponent];
53 NSString *image = [executable stringByAppendingString:@".image"];
57 if([path hasSuffix:@".app"] || [path hasSuffix:@".app/"])
59 NSFileManager *mgr = [NSFileManager defaultManager];
61 NSString *imageInBundle = [[path stringByAppendingPathComponent:@"Contents/Resources"] stringByAppendingPathComponent:image];
62 NSString *imageAlongBundle = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:image];
64 returnVal = ([mgr fileExistsAtPath:imageInBundle]
65 ? imageInBundle : imageAlongBundle);
68 returnVal = [path stringByAppendingPathComponent:image];
70 return [returnVal UTF8String];
73 void init_signals(void)
79 /* Amateurs at Apple: implement this function, properly! */
80 Protocol *objc_getProtocol(char *name)
82 if(strcmp(name,"NSTextInput") == 0)
83 return @protocol(NSTextInput);
91 mach_timebase_info_data_t info;
93 t = mach_absolute_time();
94 ret = mach_timebase_info(&info);
96 fatal_error("mach_timebase_info failed",ret);
97 return t * (info.numer/info.denom);