1 #import <Cocoa/Cocoa.h>
3 #include <mach/mach_time.h>
9 void factor_vm::c_to_factor_toplevel(cell quot)
17 Gestalt(gestaltSystemVersion,&version);
20 std::cout << "Factor requires Mac OS X 10.5 or later.\n";
24 [[NSAutoreleasePool alloc] init];
27 const char *vm_executable_path(void)
29 return [[[NSBundle mainBundle] executablePath] UTF8String];
32 const char *default_image_path(void)
34 NSBundle *bundle = [NSBundle mainBundle];
35 NSString *path = [bundle bundlePath];
36 NSString *executable = [[bundle executablePath] lastPathComponent];
37 NSString *image = [executable stringByAppendingString:@".image"];
41 if([path hasSuffix:@".app"] || [path hasSuffix:@".app/"])
43 NSFileManager *mgr = [NSFileManager defaultManager];
45 NSString *imageInBundle = [[path stringByAppendingPathComponent:@"Contents/Resources"] stringByAppendingPathComponent:image];
46 NSString *imageAlongBundle = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:image];
48 returnVal = ([mgr fileExistsAtPath:imageInBundle]
49 ? imageInBundle : imageAlongBundle);
52 returnVal = [path stringByAppendingPathComponent:image];
54 return [returnVal UTF8String];
57 void factor_vm::init_signals(void)
63 /* Amateurs at Apple: implement this function, properly! */
64 Protocol *objc_getProtocol(char *name)
66 if(strcmp(name,"NSTextInput") == 0)
67 return @protocol(NSTextInput);
74 u64 time = mach_absolute_time();
76 static u64 scaling_factor = 0;
79 mach_timebase_info_data_t info;
80 kern_return_t ret = mach_timebase_info(&info);
82 fatal_error("mach_timebase_info failed",ret);
83 scaling_factor = info.numer/info.denom;
86 return time * scaling_factor;