Fix Objective C exception handling instability

slava 2006-03-18 03:15:16 +00:00
parent 6697c6cb35
commit edfee7c3a3
1 changed files with 15 additions and 4 deletions

View File

@ -3,19 +3,30 @@
#include "../factor.h" #include "../factor.h"
#import "Foundation/NSException.h" #import "Foundation/NSException.h"
/* 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. */
void platform_run() void platform_run()
{ {
CELL error = F;
for(;;) for(;;)
{ {
NS_DURING
SETJMP(stack_chain->toplevel); SETJMP(stack_chain->toplevel);
handle_error(); handle_error();
NS_DURING
if(error != F)
{
CELL e = error;
error = F;
general_error(ERROR_OBJECTIVE_C,error,true);
}
run(); run();
NS_VOIDRETURN; NS_VOIDRETURN;
NS_HANDLER NS_HANDLER
general_error(ERROR_OBJECTIVE_C, error = tag_object(make_alien(F,(CELL)localException));
tag_object(make_alien(F,(CELL)localException)),
true);
NS_ENDHANDLER NS_ENDHANDLER
} }
} }