From c6868d601ef1b8a9eb803ac0dc7015d3eb323cbe Mon Sep 17 00:00:00 2001 From: ayers Date: Tue, 25 Mar 2003 14:57:08 +0000 Subject: [PATCH] * Rename GSObjCReplaceImplementation to GSObjCReplaceMethod. * Added GSObjCGetMethod. * Added sanity checks in GSObjCRuntime.m * Added includes to GSCategories.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16257 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 ++++--- Headers/gnustep/base/GSCategories.h | 6 +++++- Headers/gnustep/base/GSObjCRuntime.h | 3 ++- Source/Additions/GSObjCRuntime.m | 23 ++++++++++++++++++++--- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e420bc69..a7fdf97c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,14 +7,15 @@ 2003-03-25 David Ayers * Headers/gnustep/base/GSObjCRuntime.h - * Source/Additions/GSObjCRuntime.m (GSObjCReplaceImplementation): - Added new function. + * Source/Additions/GSObjCRuntime.m (GSObjCGetMethod), + (GSObjCReplaceMethod): Added new functions. * Source/Additions/GSObjCRuntime.m (search_for_method_in_class): Renamed static function for NeXT runtime to better reflect reality. (GSObjCAddMethods): Updated usage. (search_for_method_in_class): New static function for GNU runtime. - (flush_method_cache_for_class): New function. + (flush_method_cache_for_class): New static function. + * Headers/gnustep/base/GSCategories.h: Included necessary headers. 2003-03-23 Richard Frith-Macdonald diff --git a/Headers/gnustep/base/GSCategories.h b/Headers/gnustep/base/GSCategories.h index 0963bff80..643f71065 100644 --- a/Headers/gnustep/base/GSCategories.h +++ b/Headers/gnustep/base/GSCategories.h @@ -28,7 +28,11 @@ #ifndef NO_GNUSTEP -#ifdef NeXT_Foundation_LIBRARY +#ifndef NeXT_Foundation_LIBRARY +#include +#include +#include +#else #include #endif diff --git a/Headers/gnustep/base/GSObjCRuntime.h b/Headers/gnustep/base/GSObjCRuntime.h index 0b89ebdc0..694c22ae8 100644 --- a/Headers/gnustep/base/GSObjCRuntime.h +++ b/Headers/gnustep/base/GSObjCRuntime.h @@ -83,7 +83,8 @@ GS_EXPORT NSArray* GSObjCMethodNames(id obj); GS_EXPORT NSArray* GSObjCVariableNames(id obj); GS_EXPORT void GSObjCAddClassBehavior(Class receiver, Class behavior); -GS_EXPORT IMP GSObjCReplaceImplementation(Class class, SEL sel, IMP imp); +GS_EXPORT IMP GSObjCGetMethod(Class class, SEL sel); +GS_EXPORT IMP GSObjCReplaceMethod(Class class, SEL sel, IMP imp); GS_EXPORT NSValue* GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars); diff --git a/Source/Additions/GSObjCRuntime.m b/Source/Additions/GSObjCRuntime.m index 98a94bdc1..be5b192d2 100644 --- a/Source/Additions/GSObjCRuntime.m +++ b/Source/Additions/GSObjCRuntime.m @@ -653,7 +653,7 @@ GSObjCAddMethods (Class class, struct objc_method_list *methods) static Method_t search_for_method_in_class (Class class, SEL op) { - return search_for_method_in_list(class->methods, op); + return class != NULL ? search_for_method_in_list(class->methods, op) : NULL; } #endif /* NeXT runtime */ @@ -671,7 +671,24 @@ flush_method_cache_for_class (Class class) } IMP -GSObjCReplaceImplementation (Class class, SEL sel, IMP imp) +GSObjCGetMethod (Class class, SEL sel) +{ + struct objc_method *method; + IMP imp; + + imp = NULL; + method = search_for_method_in_class (class, sel); + + if (method != NULL) + { + imp = method->method_imp; + } + + return imp; +} + +IMP +GSObjCReplaceMethod (Class class, SEL sel, IMP imp) { struct objc_method *method; IMP oImp; @@ -694,7 +711,7 @@ GSObjCReplaceImplementation (Class class, SEL sel, IMP imp) if (behavior_debug) { fprintf(stderr, "could not replaced implementation for %s in %s.\n", - sel_get_name(sel), class->name); + sel_get_name(sel), class != NULL ? class->name : ""); } } return oImp;