diff --git a/ChangeLog b/ChangeLog index 4f3672295..f1ddd84e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-06-08 David Ayers + + * Headers/Additions/GNUstepBase/GSObjCRuntime.h + * Source/Additions/GSObjCRuntime.m + (GSGetInstanceMethod, GSGetClassMethod) + (GSGetInstanceMethodNotInherited, GSGetClassMethodNotInherited): + Deprecate. + (GSGetMethod): New function. + 2004-06-06 David Ayers * Source/Additions/GSObjCRuntime.m diff --git a/Headers/Additions/GNUstepBase/GSObjCRuntime.h b/Headers/Additions/GNUstepBase/GSObjCRuntime.h index 4bab3c38e..ff9ae7295 100644 --- a/Headers/Additions/GNUstepBase/GSObjCRuntime.h +++ b/Headers/Additions/GNUstepBase/GSObjCRuntime.h @@ -367,76 +367,23 @@ typedef struct objc_method_list *GSMethodList; typedef struct objc_ivar *GSIVar; /** - * Returns the pointer to the instance method structure - * for the selector in the specified class. This function searches - * the specified class and its superclasses.
+ * Returns the pointer to the method structure + * for the selector in the specified class. + * Depending on searchInstanceMethods, this function searches + * either instance or class methods. + * Depending on searchSuperClassesm this function searches + * either the specified class only or also its superclasses.
* To obtain the implementation pointer IMP use returnValue->method_imp * which should be safe across all runtimes.
* It should be safe to use this function in +load implementations.
- * This function should currently (June 2003) be considered WIP. - * Please follow potential changes (Name, parameters, ...) closely until - * it stabilizes. - */ -GS_STATIC_INLINE GSMethod -GSGetInstanceMethod(Class class, SEL sel) -{ - return class_get_instance_method(class, sel); -} - -/** - * Returns the pointer to the instance method structure - * for the selector in the specified class. This function searches - * the specified class and its superclasses.
- * To obtain the implementation pointer IMP use returnValue->method_imp - * which should be safe across all runtimes.
- * It should be safe to use this function in +load implementations.
- * This function should currently (June 2003) be considered WIP. - * Please follow potential changes (Name, parameters, ...) closely until - * it stabilizes. - */ -GS_STATIC_INLINE GSMethod -GSGetClassMethod(Class class, SEL sel) -{ - /* - We do not rely on the mapping supplied in objc_gnu2next.h - because we want to be explicit about the fact - that the expected parameters are different. - Therefor we refrain from simply using class_getClassMethod(). - */ -#ifdef NeXT_RUNTIME - return class_getClassMethod(class, sel); -#else - return class_get_class_method(class->class_pointer, sel); -#endif -} - -/** - * Returns the pointer to the instance method structure - * for the selector in the specified class. This function only searches - * the specified class and not its superclasses.
- * To obtain the implementation pointer IMP use returnValue->method_imp - * which should be safe across all runtimes.
- * It should be safe to use this function in +load implementations.
- * This function should currently (June 2003) be considered WIP. + * This function should currently (June 2004) be considered WIP. * Please follow potential changes (Name, parameters, ...) closely until * it stabilizes. */ GS_EXPORT GSMethod -GSGetInstanceMethodNotInherited(Class class, SEL sel); - -/** - * Returns the pointer to the class method structure - * for the selector in the specified class. This function only searches - * the specified class and not its superclasses.
- * To obtain the implementation pointer IMP use returnValue->method_imp - * which should be safe across all runtimes.
- * It should be safe to use this function in +load implementations.
- * This function should currently (June 2003) be considered WIP. - * Please follow potential changes (Name, parameters, ...) closely until - * it stabilizes. - */ -GS_EXPORT GSMethod -GSGetClassMethodNotInherited(Class class, SEL sel); +GSGetMethod(Class class, SEL sel, + BOOL searchInstanceMethods, + BOOL searchSuperClasses); /** * Flushes the cached method dispatch table for the class. @@ -756,6 +703,31 @@ GSObjCSelectorTypes(SEL this) return sel_get_type(this); } +GS_STATIC_INLINE GSMethod +GSGetInstanceMethod(Class class, SEL sel) +{ + return GSGetMethod(class, sel, YES, YES); +} + +GS_STATIC_INLINE GSMethod +GSGetClassMethod(Class class, SEL sel) +{ + return GSGetMethod(class, sel, NO, YES); +} + +GS_STATIC_INLINE GSMethod +GSGetInstanceMethodNotInherited(Class class, SEL sel) +{ + return GSGetMethod(class, sel, YES, NO); +} + +GS_STATIC_INLINE GSMethod +GSGetClassMethodNotInherited(Class class, SEL sel) +{ + return GSGetMethod(class, sel, NO, NO); +} + + #endif /* NO_DEPRECATED */ diff --git a/Source/Additions/GSObjCRuntime.m b/Source/Additions/GSObjCRuntime.m index e8dc7c3cd..20657a090 100644 --- a/Source/Additions/GSObjCRuntime.m +++ b/Source/Additions/GSObjCRuntime.m @@ -783,19 +783,50 @@ search_for_method_in_class (Class class, SEL op) #endif /* NeXT runtime */ -/* See header for documentation. */ GSMethod -GSGetInstanceMethodNotInherited (Class class, SEL sel) +GSGetMethod(Class class, SEL sel, + BOOL searchInstanceMethods, + BOOL searchSuperClasses) { - return search_for_method_in_class (class, sel); + if (class == 0 || sel == 0) + { + return 0; + } + + if (searchSuperClasses == NO) + { + if (searchInstanceMethods == NO) + { + return search_for_method_in_class(class->class_pointer, sel); + } + else + { + return search_for_method_in_class(class, sel); + } + } + else + { + if (searchInstanceMethods == NO) + { + /* + We do not rely on the mapping supplied in objc_gnu2next.h + because we want to be explicit about the fact + that the expected parameters are different. + Therefor we refrain from simply using class_getClassMethod(). + */ +#ifdef NeXT_RUNTIME + return class_getClassMethod(class, sel); +#else + return class_get_class_method(class->class_pointer, sel); +#endif + } + else + { + return class_get_instance_method(class, sel); + } + } } -/* See header for documentation. */ -GSMethod -GSGetClassMethodNotInherited (Class class, SEL sel) -{ - return search_for_method_in_class (class->class_pointer, sel); -} /* See header for documentation. */ GSMethodList