factor/vm/os-macosx.m

72 lines
1.3 KiB
Matlab
Raw Normal View History

#import <Cocoa/Cocoa.h>
#include "master.h"
static CELL error;
/* This code is convoluted because Cocoa places restrictions on longjmp and
exception handling. In particular, a longjmp can never cross an NS_DURING,
NS_HANDLER or NS_ENDHANDLER. */
2006-10-15 00:10:54 -04:00
void run()
{
error = F;
for(;;)
{
NS_DURING
stack_chain->native_stack_pointer = native_stack_pointer();
SETJMP(stack_chain->toplevel);
handle_error();
if(error != F)
{
CELL e = error;
error = F;
simple_error(ERROR_OBJECTIVE_C,e,F);
}
2006-10-15 00:10:54 -04:00
interpreter_loop();
NS_VOIDRETURN;
NS_HANDLER
2006-10-31 00:52:02 -05:00
error = allot_alien(F,(CELL)localException);
NS_ENDHANDLER
}
}
2006-10-15 00:10:54 -04:00
void run_toplevel(void)
{
run();
2006-10-15 00:10:54 -04:00
}
2006-03-19 02:42:40 -05:00
void early_init(void)
{
[[NSAutoreleasePool alloc] init];
}
const char *default_image_path(void)
{
NSBundle *bundle = [NSBundle mainBundle];
2006-08-28 04:03:09 -04:00
NSString *path = [bundle bundlePath];
NSString *image;
if([path hasSuffix:@".app"] || [path hasSuffix:@".app/"])
image = [[path stringByDeletingLastPathComponent] stringByAppendingString:@"/factor.image"];
else
image = [path stringByAppendingString:@"/factor.image"];
2006-03-19 02:42:40 -05:00
return [image cString];
}
2006-07-07 00:07:18 -04:00
void init_signals(void)
{
unix_init_signals();
mach_initialize();
}
/* Amateurs at Apple: implement this function, properly! */
Protocol *objc_getProtocol(char *name)
{
if(strcmp(name,"NSTextInput") == 0)
return @protocol(NSTextInput);
else
return nil;
}