From 6f1e7e3af3cd2a28b0cbf05b54d59dbe25686421 Mon Sep 17 00:00:00 2001 From: rfm Date: Thu, 1 Jul 2010 07:17:53 +0000 Subject: [PATCH] emergency fixup for broken build git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30907 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 ++ Headers/Additions/GNUstepBase/CXXException.h | 12 +-- Source/CXXException.m | 97 ++++++++++---------- 3 files changed, 62 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index aa637b737..48c5957ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-07-01 Richard Frith-Macdonald + + * Source/CXXException.m: Fixup to get base to compile again. + I think this API needs improving ... this should be an NSException + subclass or category, and catching it should be transparent to the + developer. + 2010-06-29 Richard Frith-Macdonald * Source/NSKeyedUnarchiver.m: Workaround for buggy inttypes.h on older diff --git a/Headers/Additions/GNUstepBase/CXXException.h b/Headers/Additions/GNUstepBase/CXXException.h index d0ee43d5d..3edb501fb 100644 --- a/Headers/Additions/GNUstepBase/CXXException.h +++ b/Headers/Additions/GNUstepBase/CXXException.h @@ -14,29 +14,29 @@ struct _Unwind_Exception; */ @interface CXXException : NSObject { - /** Exception object, as defined by the CodeSourcery exception ABI. */ - struct _Unwind_Exception *ex; + /** Exception object, as defined by the CodeSourcery exception ABI. */ + struct _Unwind_Exception *ex; } /** * Constructor called by the runtime. */ -+ (id)exceptionWithForeignException: (struct _Unwind_Exception*)ex; ++ (id) exceptionWithForeignException: (struct _Unwind_Exception*)ex; /** * Returns a pointer to the thrown value. When a value is thrown in C++, it is * copied into the exception structure. The real type of the pointee is the * type of the object that was thrown. */ -- (void*)thrownValue; +- (void*) thrownValue; /** * Returns a pointer to a std::type_info (C++) object defining the type of the * value pointed to by the return from -thrownValue. You may compare this with * the result of the typeinfo() operator in Objective-C++ to determine the type * of the object. */ -- (void*)cxx_type_info; +- (void*) cxx_type_info; /** * Rethrows the exception. Sending messages to this object after is has been * rethrown has undefined behaviour. */ -- (void)rethrow; +- (void) rethrow; @end diff --git a/Source/CXXException.m b/Source/CXXException.m index 21f53517e..b3a4bcd11 100644 --- a/Source/CXXException.m +++ b/Source/CXXException.m @@ -1,4 +1,5 @@ -#if defined(__has_include) && __has_include() +#if defined(__has_include) +#if __has_include() #import "Foundation/NSObject.h" #import "Additions/GNUstepBase/CXXException.h" #include @@ -9,7 +10,7 @@ typedef enum { - _URC_FOREIGN_EXCEPTION_CAUGHT = 1 + _URC_FOREIGN_EXCEPTION_CAUGHT = 1 } _Unwind_Reason_Code; struct _Unwind_Exception; @@ -18,10 +19,10 @@ typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, struct _Unwind_Exception *); struct _Unwind_Exception { - uint64_t exception_class; - _Unwind_Exception_Cleanup_Fn exception_cleanup; - unsigned long private_1; - unsigned long private_2; + uint64_t exception_class; + _Unwind_Exception_Cleanup_Fn exception_cleanup; + unsigned long private_1; + unsigned long private_2; } __attribute__((__aligned__)); _Unwind_Reason_Code _Unwind_Resume_or_Rethrow(struct _Unwind_Exception *); @@ -29,20 +30,19 @@ _Unwind_Reason_Code _Unwind_Resume_or_Rethrow(struct _Unwind_Exception *); struct __cxa_exception { - void* exceptionType; - void (*exceptionDestructor) (void *); - void (*unexpectedHandler) (void *); - void (*terminateHandler) (void *); - void * nextException; + void *exceptionType; + void (*exceptionDestructor) (void *); + void (*unexpectedHandler) (void *); + void (*terminateHandler) (void *); + void *nextException; - int handlerCount; - int handlerSwitchValue; - const char * actionRecord; - const char * languageSpecificData; - void * catchTemp; - void * adjustedPtr; - - struct _Unwind_Exception unwindHeader; + int handlerCount; + int handlerSwitchValue; + const char * actionRecord; + const char * languageSpecificData; + void * catchTemp; + void * adjustedPtr; + struct _Unwind_Exception unwindHeader; }; @implementation CXXException @@ -50,48 +50,49 @@ static Class CXXExceptionClass; // TODO: Add an API for registering other classes for other exception types static Class boxClass(int64_t foo) { - if (foo == *(int64_t*)"GNUCC++\0") - { - return CXXExceptionClass; - } - return Nil; + if (foo == *(int64_t*)"GNUCC++\0") + { + return CXXExceptionClass; + } + return Nil; } -+ (void)load ++ (void) load { - CXXExceptionClass = self; - _objc_class_for_boxing_foreign_exception = boxClass; + CXXExceptionClass = self; + _objc_class_for_boxing_foreign_exception = boxClass; } -+ (id)exceptionWithForeignException: (struct _Unwind_Exception*)ex ++ (id) exceptionWithForeignException: (struct _Unwind_Exception*)ex { - CXXException *box = [self new]; - box->ex = ex; - return [box autorelease]; + CXXException *box = [self new]; + box->ex = ex; + return [box autorelease]; } -- (void*)thrownValue +- (void*) thrownValue { - return ex+1; + return ex + 1; } -- (void*)cxx_type_info +- (void*) cxx_type_info { - char *ptr = (char*)ex; - ptr -= __builtin_offsetof(struct __cxa_exception, unwindHeader); - return ((struct __cxa_exception*)ptr)->exceptionType; + char *ptr = (char*)ex; + ptr -= __builtin_offsetof(struct __cxa_exception, unwindHeader); + return ((struct __cxa_exception*)ptr)->exceptionType; } -- (void)rethrow +- (void) rethrow { - struct _Unwind_Exception *re = ex; - // We aren't allowed to hold onto the exception if it's been rethrown. - ex = 0; - _Unwind_Resume_or_Rethrow(re); + struct _Unwind_Exception *re = ex; + // We aren't allowed to hold onto the exception if it's been rethrown. + ex = 0; + _Unwind_Resume_or_Rethrow(re); } -- (void)dealloc +- (void) dealloc { - if (0 != ex && 0 != ex->exception_cleanup) - { - ex->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, ex); - } - [super dealloc]; + if (0 != ex && 0 != ex->exception_cleanup) + { + ex->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, ex); + } + [super dealloc]; } @end #endif +#endif