2006-03-19 02:42:40 -05:00
|
|
|
/* Cocoa exception handling and default image path for Mac OS X */
|
2006-02-19 22:08:08 -05:00
|
|
|
|
|
|
|
#include "../factor.h"
|
2006-03-19 02:42:40 -05:00
|
|
|
#import "Foundation/NSAutoreleasePool.h"
|
|
|
|
#import "Foundation/NSBundle.h"
|
2006-02-19 22:08:08 -05:00
|
|
|
#import "Foundation/NSException.h"
|
2006-03-19 02:42:40 -05:00
|
|
|
#import "Foundation/NSString.h"
|
2006-02-19 22:08:08 -05:00
|
|
|
|
2006-03-17 22:15:16 -05:00
|
|
|
/* 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-02-19 22:08:08 -05:00
|
|
|
void platform_run()
|
|
|
|
{
|
2006-03-17 22:15:16 -05:00
|
|
|
CELL error = F;
|
|
|
|
|
2006-02-19 22:08:08 -05:00
|
|
|
for(;;)
|
|
|
|
{
|
2006-03-17 22:15:16 -05:00
|
|
|
NS_DURING
|
2006-02-23 02:09:34 -05:00
|
|
|
SETJMP(stack_chain->toplevel);
|
2006-02-19 22:08:08 -05:00
|
|
|
handle_error();
|
2006-03-17 22:15:16 -05:00
|
|
|
|
|
|
|
if(error != F)
|
|
|
|
{
|
|
|
|
CELL e = error;
|
|
|
|
error = F;
|
2006-03-19 02:42:40 -05:00
|
|
|
general_error(ERROR_OBJECTIVE_C,e,true);
|
2006-03-17 22:15:16 -05:00
|
|
|
}
|
|
|
|
|
2006-02-23 02:09:34 -05:00
|
|
|
run();
|
2006-02-19 22:08:08 -05:00
|
|
|
NS_VOIDRETURN;
|
|
|
|
NS_HANDLER
|
2006-03-17 22:15:16 -05:00
|
|
|
error = tag_object(make_alien(F,(CELL)localException));
|
2006-02-19 22:08:08 -05:00
|
|
|
NS_ENDHANDLER
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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];
|
|
|
|
NSString *path = [bundle bundlePath];
|
2006-03-19 15:43:40 -05:00
|
|
|
NSString *image = [path stringByAppendingString:@"/Contents/Resources/factor.image"];
|
2006-03-19 02:42:40 -05:00
|
|
|
return [image cString];
|
|
|
|
}
|