* 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
This commit is contained in:
David Ayers 2003-03-25 14:57:08 +00:00
parent eb88d30c7c
commit ffcac98789
4 changed files with 31 additions and 8 deletions

View file

@ -7,14 +7,15 @@
2003-03-25 David Ayers <d.ayers@inode.at>
* 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 <rfm@gnu.org>

View file

@ -28,7 +28,11 @@
#ifndef NO_GNUSTEP
#ifdef NeXT_Foundation_LIBRARY
#ifndef NeXT_Foundation_LIBRARY
#include <Foundation/NSCalendarDate.h>
#include <Foundation/NSData.h>
#include <Foundation/NSString.h>
#else
#include <Foundation/Foundation.h>
#endif

View file

@ -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);

View file

@ -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 : "<NULL>");
}
}
return oImp;