(GSObjCMethodNames, search_for_method_in_class, GSObjCAddMethods)

(search_for_method_in_class, GSObjCAddClassBehavior): Use
	GSMethod and GSMethodList types instead of pointers to runtime
	structures.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19466 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ayers 2004-06-05 21:11:00 +00:00
parent a53541a76b
commit 70e3d2d11c
2 changed files with 28 additions and 25 deletions

View file

@ -6,6 +6,9 @@
(GSAllocMethodList, GSAppendMethodToList, GSRemoveMethodFromList) (GSAllocMethodList, GSAppendMethodToList, GSRemoveMethodFromList)
(GSMethodListForSelector, GSMethodFromList) (GSMethodListForSelector, GSMethodFromList)
(GSAddMethodList, GSRemoveMethodList): New functions. (GSAddMethodList, GSRemoveMethodList): New functions.
(GSObjCMethodNames, search_for_method_in_class, GSObjCAddMethods)
(search_for_method_in_class, GSObjCAddClassBehavior): Use GSMethod
and GSMethodList types instead of pointers to runtime structures.
* Testing/GNUmakefile * Testing/GNUmakefile
* Testing/gsbehavior.m: New tests. * Testing/gsbehavior.m: New tests.

View file

@ -185,10 +185,10 @@ GSObjCFindVariable(id obj, const char *name,
NSArray * NSArray *
GSObjCMethodNames(id obj) GSObjCMethodNames(id obj)
{ {
NSMutableSet *set; NSMutableSet *set;
NSArray *array; NSArray *array;
Class class; Class class;
struct objc_method_list *methods; GSMethodList methods;
if (obj == nil) if (obj == nil)
{ {
@ -213,7 +213,7 @@ GSObjCMethodNames(id obj)
for (i = 0; i < methods->method_count; i++) for (i = 0; i < methods->method_count; i++)
{ {
struct objc_method *method = &methods->method_list[i]; GSMethod method = &methods->method_list[i];
if (method->method_name != 0) if (method->method_name != 0)
{ {
@ -620,13 +620,13 @@ GSObjCBehaviorDebug(int i)
#if NeXT_RUNTIME #if NeXT_RUNTIME
static struct objc_method *search_for_method_in_class (Class class, SEL op); static GSMethod search_for_method_in_class (Class class, SEL op);
void void
GSObjCAddMethods (Class class, struct objc_method_list *methods) GSObjCAddMethods (Class class, GSMethodList methods)
{ {
static SEL initialize_sel = 0; static SEL initialize_sel = 0;
struct objc_method_list *mlist; GSMethodList mlist;
if (!initialize_sel) if (!initialize_sel)
initialize_sel = sel_register_name ("initialize"); initialize_sel = sel_register_name ("initialize");
@ -635,20 +635,20 @@ GSObjCAddMethods (Class class, struct objc_method_list *methods)
mlist = methods; mlist = methods;
{ {
int counter; int counter;
struct objc_method_list *new_list; GSMethodList new_list;
counter = mlist->method_count ? mlist->method_count - 1 : 1; counter = mlist->method_count ? mlist->method_count - 1 : 1;
/* This is a little wasteful of memory, since not necessarily /* This is a little wasteful of memory, since not necessarily
all methods will go in here. */ all methods will go in here. */
new_list = (struct objc_method_list *) new_list = (GSMethodList)
objc_malloc (sizeof(struct objc_method_list) + objc_malloc (sizeof(struct objc_method_list) +
sizeof(struct objc_method[counter+1])); sizeof(struct objc_method[counter+1]));
new_list->method_count = 0; new_list->method_count = 0;
while (counter >= 0) while (counter >= 0)
{ {
struct objc_method *method = &(mlist->method_list[counter]); GSMethod method = &(mlist->method_list[counter]);
BDBGPrintf(" processing method [%s] ... ", BDBGPrintf(" processing method [%s] ... ",
GSNameFromSelector(method->method_name)); GSNameFromSelector(method->method_name));
@ -683,11 +683,11 @@ GSObjCAddMethods (Class class, struct objc_method_list *methods)
/* Search for the named method's method structure. Return a pointer /* Search for the named method's method structure. Return a pointer
to the method's method structure if found. NULL otherwise. */ to the method's method structure if found. NULL otherwise. */
static struct objc_method * static GSMethod
search_for_method_in_class (Class class, SEL op) search_for_method_in_class (Class class, SEL op)
{ {
void *iterator = 0; void *iterator = 0;
struct objc_method_list *method_list; GSMethodList method_list;
if (! sel_is_mapped (op)) if (! sel_is_mapped (op))
return NULL; return NULL;
@ -700,7 +700,7 @@ search_for_method_in_class (Class class, SEL op)
/* Search the method list. */ /* Search the method list. */
for (i = 0; i < method_list->method_count; ++i) for (i = 0; i < method_list->method_count; ++i)
{ {
struct objc_method *method = &method_list->method_list[i]; GSMethod method = &method_list->method_list[i];
if (method->method_name) if (method->method_name)
{ {
@ -724,10 +724,10 @@ extern void class_add_method_list(Class, MethodList_t);
static Method_t search_for_method_in_class (Class class, SEL op); static Method_t search_for_method_in_class (Class class, SEL op);
void void
GSObjCAddMethods (Class class, struct objc_method_list *methods) GSObjCAddMethods (Class class, GSMethodList methods)
{ {
static SEL initialize_sel = 0; static SEL initialize_sel = 0;
struct objc_method_list *mlist; GSMethodList mlist;
if (initialize_sel == 0) if (initialize_sel == 0)
{ {
@ -737,14 +737,14 @@ GSObjCAddMethods (Class class, struct objc_method_list *methods)
/* Add methods to class->dtable and class->methods */ /* Add methods to class->dtable and class->methods */
for (mlist = methods; mlist; mlist = mlist->method_next) for (mlist = methods; mlist; mlist = mlist->method_next)
{ {
int counter; int counter;
struct objc_method_list *new_list; GSMethodList new_list;
counter = mlist->method_count ? mlist->method_count - 1 : 1; counter = mlist->method_count ? mlist->method_count - 1 : 1;
/* This is a little wasteful of memory, since not necessarily /* This is a little wasteful of memory, since not necessarily
all methods will go in here. */ all methods will go in here. */
new_list = (struct objc_method_list *) new_list = (GSMethodList)
objc_malloc (sizeof(struct objc_method_list) + objc_malloc (sizeof(struct objc_method_list) +
sizeof(struct objc_method[counter+1])); sizeof(struct objc_method[counter+1]));
new_list->method_count = 0; new_list->method_count = 0;
@ -752,8 +752,8 @@ GSObjCAddMethods (Class class, struct objc_method_list *methods)
while (counter >= 0) while (counter >= 0)
{ {
struct objc_method *method = &(mlist->method_list[counter]); GSMethod method = &(mlist->method_list[counter]);
const char *name = GSNameFromSelector(method->method_name); const char *name = GSNameFromSelector(method->method_name);
BDBGPrintf(" processing method [%s] ... ", name); BDBGPrintf(" processing method [%s] ... ", name);
@ -1334,8 +1334,8 @@ GSObjCAddClassBehavior(Class receiver, Class behavior)
/* Add instance methods */ /* Add instance methods */
#if NeXT_RUNTIME #if NeXT_RUNTIME
{ {
void *iterator = 0; void *iterator = 0;
struct objc_method_list *method_list; GSMethodList method_list;
method_list = class_nextMethodList(behavior, &iterator); method_list = class_nextMethodList(behavior, &iterator);
while (method_list != 0) while (method_list != 0)
@ -1353,8 +1353,8 @@ GSObjCAddClassBehavior(Class receiver, Class behavior)
behavior->class_pointer->name); behavior->class_pointer->name);
#if NeXT_RUNTIME #if NeXT_RUNTIME
{ {
void *iterator = 0; void *iterator = 0;
struct objc_method_list *method_list; GSMethodList method_list;
method_list = class_nextMethodList(behavior->class_pointer, &iterator); method_list = class_nextMethodList(behavior->class_pointer, &iterator);
while (method_list != 0) while (method_list != 0)