Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -57,14 +57,10 @@ AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl") AC_CHECK_HEADER(objc/runtime.h, [AC_DEFINE(HAVE_OBJC_RUNTIME_H, 1, [Whether we have objc/runtime.h])]) -AC_CHECK_LIB(objc, sel_get_name, - [AC_DEFINE(HAVE_SEL_GET_NAME, 1, [Whether we have sel_get_name])]) -AC_CHECK_LIB(objc, sel_getName, - [AC_DEFINE(HAVE_SEL_GETNAME, 1, [Whether we have sel_getName])]) AC_CHECK_FUNC(asprintf, [ have_asprintf="yes" AC_DEFINE(HAVE_ASPRINTF, 1, "Whether we have asprintf")], [ have_asprintf="no" Index: src/OFExceptions.h ================================================================== --- src/OFExceptions.h +++ src/OFExceptions.h @@ -111,10 +111,37 @@ * \return A pointer to the memory which is not part of the object */ - (void*)pointer; @end +/** + * An OFException indicating that a method or part of it is not implemented. + */ +@interface OFNotImplementedException: OFException +{ + SEL selector; +} + +/** + * \param class The class of the object which caused the exception + * \param selector The selector which is not or not fully implemented + * \return A new not implemented exception + */ ++ newWithClass: (Class)class + andSelector: (SEL)selector; + +/** + * Initializes an already allocated not implemented exception. + * + * \param class The class of the object which caused the exception + * \param selector The selector which is not or not fully implemented + * \return An initialized not implemented exception + */ +- initWithClass: (Class)class + andSelector: (SEL)selector; +@end + /** * An OFException indicating the given value is out of range. */ @interface OFOutOfRangeException: OFException {} @end Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -29,24 +29,19 @@ #define ERRFMT "Error code was: %d" #define ERRPARAM err #endif #import -#ifdef HAVE_OBJC_RUNTIME_H +#ifdef __objc_INCLUDE_GNU +#define SEL_NAME(x) sel_get_name(x) +#else #import +#define SEL_NAME(x) sel_getName(x) #endif #import "OFExceptions.h" -#if defined(HAVE_SEL_GET_NAME) -#define SEL_NAME(x) sel_get_name(x) -#elif defined(HAVE_SEL_GETNAME) -#define SEL_NAME(x) sel_getName(x) -#else -#error "You need either sel_get_name() or sel_getName()!" -#endif - #ifndef HAVE_ASPRINTF #import "asprintf.h" #endif @implementation OFException @@ -151,10 +146,39 @@ - (void*)pointer { return pointer; } @end + +@implementation OFNotImplementedException ++ newWithClass: (Class)class_ + andSelector: (SEL)selector_ +{ + return [[self alloc] initWithClass: class_ + andSelector: selector_]; +} + +- initWithClass: (Class)class_ + andSelector: (SEL)selector_ +{ + if ((self = [super initWithClass: class_])) + selector = selector_; + + return self; +} + +- (const char*)cString +{ + if (string != NULL) + return string; + + asprintf(&string, "The method %s of class %s is not or not fully " + "implemented!", SEL_NAME(selector), [class name]); + + return string; +} +@end @implementation OFOutOfRangeException - (const char*)cString { if (string != NULL)