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"
#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()
{
CELL error = F;
for(;;)
{
NS_DURING
SETJMP(stack_chain->toplevel);
handle_error();
NS_DURING
if(error != F)
{
CELL e = error;
error = F;
general_error(ERROR_OBJECTIVE_C,error,true);
}
run();
NS_VOIDRETURN;
NS_HANDLER
general_error(ERROR_OBJECTIVE_C,
tag_object(make_alien(F,(CELL)localException)),
true);
error = tag_object(make_alien(F,(CELL)localException));
NS_ENDHANDLER
}
}