diff --git a/ChangeLog b/ChangeLog index 8b6919035..ad49d8958 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-04-26 Saso Kiselkov + + * Headers/Foundation/NSException.h: Support native exceptions. + 2006-04-26 Richard Frith-Macdonald * Source/NSCalendarDate.m: Correction to millisecond fix ... for diff --git a/Headers/Foundation/NSException.h b/Headers/Foundation/NSException.h index 67364d8d6..e366754fb 100644 --- a/Headers/Foundation/NSException.h +++ b/Headers/Foundation/NSException.h @@ -254,11 +254,22 @@ GS_EXPORT NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler; resources allocated in the routine, possibly case on the error code and perform special processing, and default to RERAISE the error to the next handler. Within the scope of the handler, a local variable - called exception holds information about the exception raised. + called "localException" holds information about the exception raised. It is illegal to exit the first block of code by any other means than NS_VALRETURN, NS_VOIDRETURN, or just falling out the bottom. */ +#ifdef _NATIVE_OBJC_EXCEPTIONS + +# define NS_DURING @try { +# define NS_HANDLER } @catch (NSException * localException) { +# define NS_ENDHANDLER } + +# define NS_VALRETURN(val) return (val) +# define NS_VALUERETURN(object, id) return (object) +# define NS_VOIDRETURN return + +#else // _NATIVE_OBJC_EXCEPTIONS /** Private support routine. Do not call directly. */ GS_EXPORT void _NSAddHandler( NSHandler *handler ); @@ -287,6 +298,8 @@ GS_EXPORT void _NSRemoveHandler( NSHandler *handler ); #define NS_VOIDRETURN do { _NSRemoveHandler(&NSLocalHandler); \ return; } while (0) +#endif // _NATIVE_OBJC_EXCEPTIONS + /* ------------------------------------------------------------------------ */ /* Assertion Handling */ /* ------------------------------------------------------------------------ */ diff --git a/Source/NSException.m b/Source/NSException.m index e99f448d7..5b844d473 100644 --- a/Source/NSException.m +++ b/Source/NSException.m @@ -141,6 +141,9 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception) - (void) raise { +#ifdef _NATIVE_OBJC_EXCEPTIONS + @throw self; +#else NSThread *thread; NSHandler *handler; @@ -185,6 +188,7 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception) thread->_exception_handler = handler->next; handler->exception = self; longjmp(handler->jumpState, 1); +#endif } - (NSString*) name