* Headers/Additions/GNUstepBase/GSObjCRuntime.h

* Source/Additions/GSObjCRuntime.m: Make ObjC++ safe.
        (GSObjCSuper, GSObjCIsKindOf, GSNameFromClass)
        (GSTypesFromSelector, GSGetMethod, GSFlushMethodCacheForClass)
        (GSCGetInstanceVariableDefinition)
        (GSObjCGetInstanceVariableDefinition)
        (GSMethodListForSelector, GSAddMethodList, GSRemoveMethodList)
        (GSObjCVersion, GSObjCName, GSObjCSelectorName)
        (GSObjCSelectorTypes, GSGetInstanceMethod, GSGetClassMethod)
        (GSGetInstanceMethodNotInherited, GSGetClassMethodNotInherited)
        (search_for_method_in_class, GSObjCAddMethods): Replace class
        and this with cls or sel.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19790 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Ayers 2004-07-29 12:55:05 +00:00
parent c5849bb8dd
commit d6c274320f
3 changed files with 107 additions and 82 deletions

View file

@ -1,3 +1,19 @@
2004-07-29 Matt Rice <ratmice@yahoo.com>
David Ayers <d.ayers@inode.at>
* Headers/Additions/GNUstepBase/GSObjCRuntime.h
* Source/Additions/GSObjCRuntime.m: Make ObjC++ safe.
(GSObjCSuper, GSObjCIsKindOf, GSNameFromClass)
(GSTypesFromSelector, GSGetMethod, GSFlushMethodCacheForClass)
(GSCGetInstanceVariableDefinition)
(GSObjCGetInstanceVariableDefinition)
(GSMethodListForSelector, GSAddMethodList, GSRemoveMethodList)
(GSObjCVersion, GSObjCName, GSObjCSelectorName)
(GSObjCSelectorTypes, GSGetInstanceMethod, GSGetClassMethod)
(GSGetInstanceMethodNotInherited, GSGetClassMethodNotInherited)
(search_for_method_in_class, GSObjCAddMethods): Replace class and
this with cls or sel.
2004-07-29 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSAutoreleasePool.m: ([emptyPool]) reset _released ivar

View file

@ -31,6 +31,11 @@
#include <objc/objc.h>
#include <objc/objc-api.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#ifdef GNUSTEP_WITH_DLL
@ -157,13 +162,13 @@ GSObjCClass(id obj)
* Returns the superclass of this.
*/
GS_STATIC_INLINE Class
GSObjCSuper(Class class)
GSObjCSuper(Class cls)
{
#ifndef NeXT_RUNTIME
if (class != 0 && CLS_ISRESOLV (class) == NO)
if (cls != 0 && CLS_ISRESOLV (cls) == NO)
{
const char *name;
name = (const char *)class->super_class;
name = (const char *)cls->super_class;
if (name == NULL)
{
return 0;
@ -171,7 +176,7 @@ GSObjCSuper(Class class)
return objc_lookup_class (name);
}
#endif
return class_get_super_class(class);
return class_get_super_class(cls);
}
/**
@ -203,15 +208,15 @@ GSObjCIsClass(Class cls)
* The argument to this function must NOT be nil.
*/
GS_STATIC_INLINE BOOL
GSObjCIsKindOf(Class this, Class other)
GSObjCIsKindOf(Class cls, Class other)
{
while (this != Nil)
while (cls != Nil)
{
if (this == other)
if (cls == other)
{
return YES;
}
this = GSObjCSuper(this);
cls = GSObjCSuper(cls);
}
return NO;
}
@ -234,11 +239,11 @@ GSClassFromName(const char *name)
* was supplied.
*/
GS_STATIC_INLINE const char *
GSNameFromClass(Class this)
GSNameFromClass(Class cls)
{
if (this == 0)
if (cls == 0)
return 0;
return class_get_class_name(this);
return class_get_class_name(cls);
}
/**
@ -330,11 +335,11 @@ GSSelectorFromNameAndTypes(const char *name, const char *types)
* was not typed.
*/
GS_STATIC_INLINE const char *
GSTypesFromSelector(SEL this)
GSTypesFromSelector(SEL sel)
{
if (this == 0)
if (sel == 0)
return 0;
return sel_get_type(this);
return sel_get_type(sel);
}
/**
@ -381,7 +386,7 @@ typedef struct objc_ivar *GSIVar;
* it stabilizes.
*/
GS_EXPORT GSMethod
GSGetMethod(Class class, SEL sel,
GSGetMethod(Class cls, SEL sel,
BOOL searchInstanceMethods,
BOOL searchSuperClasses);
@ -394,10 +399,10 @@ GSGetMethod(Class class, SEL sel,
* it stabilizes.
*/
GS_STATIC_INLINE void
GSFlushMethodCacheForClass (Class class)
GSFlushMethodCacheForClass (Class cls)
{
extern void __objc_update_dispatch_table_for_class (Class);
__objc_update_dispatch_table_for_class (class);
__objc_update_dispatch_table_for_class (cls);
}
/**
@ -410,7 +415,7 @@ GSFlushMethodCacheForClass (Class class)
* it stabilizes.
*/
GS_EXPORT GSIVar
GSCGetInstanceVariableDefinition(Class class, const char *name);
GSCGetInstanceVariableDefinition(Class cls, const char *name);
/**
* Returns the pointer to the instance variable structure
@ -423,7 +428,7 @@ GSCGetInstanceVariableDefinition(Class class, const char *name);
* it stabilizes.
*/
GS_EXPORT GSIVar
GSObjCGetInstanceVariableDefinition(Class class, NSString *name);
GSObjCGetInstanceVariableDefinition(Class cls, NSString *name);
/**
* <p>Returns a pointer to objc_malloc'ed memory large enough
@ -525,7 +530,7 @@ GSRemoveMethodFromList (GSMethodList list,
* it stabilizes.</p>
*/
GSMethodList
GSMethodListForSelector(Class class,
GSMethodListForSelector(Class cls,
SEL selector,
void **iterator,
BOOL searchInstanceMethods);
@ -561,7 +566,7 @@ GSMethodFromList(GSMethodList list,
* it stabilizes.</p>
*/
void
GSAddMethodList(Class class,
GSAddMethodList(Class cls,
GSMethodList list,
BOOL toInstanceMethods);
@ -576,7 +581,7 @@ GSAddMethodList(Class class,
* it stabilizes.</p>
*/
void
GSRemoveMethodList(Class class,
GSRemoveMethodList(Class cls,
GSMethodList list,
BOOL fromInstanceMethods);
@ -585,9 +590,9 @@ GSRemoveMethodList(Class class,
* Returns the version number of this.
*/
GS_STATIC_INLINE int
GSObjCVersion(Class this)
GSObjCVersion(Class cls)
{
return class_get_version(this);
return class_get_version(cls);
}
#ifndef NeXT_Foundation_LIBRARY
@ -680,51 +685,51 @@ GSSetValue(NSObject *self, NSString *key, id val, SEL sel,
/** ## deprecated ##
*/
GS_STATIC_INLINE const char*
GSObjCName(Class this)
GSObjCName(Class cls)
{
return class_get_class_name(this);
return class_get_class_name(cls);
}
/** ## deprecated ##
*/
GS_STATIC_INLINE const char*
GSObjCSelectorName(SEL this)
GSObjCSelectorName(SEL sel)
{
if (this == 0)
if (sel == 0)
return 0;
return sel_get_name(this);
return sel_get_name(sel);
}
/** ## deprecated ##
*/
GS_STATIC_INLINE const char*
GSObjCSelectorTypes(SEL this)
GSObjCSelectorTypes(SEL sel)
{
return sel_get_type(this);
return sel_get_type(sel);
}
GS_STATIC_INLINE GSMethod
GSGetInstanceMethod(Class class, SEL sel)
GSGetInstanceMethod(Class cls, SEL sel)
{
return GSGetMethod(class, sel, YES, YES);
return GSGetMethod(cls, sel, YES, YES);
}
GS_STATIC_INLINE GSMethod
GSGetClassMethod(Class class, SEL sel)
GSGetClassMethod(Class cls, SEL sel)
{
return GSGetMethod(class, sel, NO, YES);
return GSGetMethod(cls, sel, NO, YES);
}
GS_STATIC_INLINE GSMethod
GSGetInstanceMethodNotInherited(Class class, SEL sel)
GSGetInstanceMethodNotInherited(Class cls, SEL sel)
{
return GSGetMethod(class, sel, YES, NO);
return GSGetMethod(cls, sel, YES, NO);
}
GS_STATIC_INLINE GSMethod
GSGetClassMethodNotInherited(Class class, SEL sel)
GSGetClassMethodNotInherited(Class cls, SEL sel)
{
return GSGetMethod(class, sel, NO, NO);
return GSGetMethod(cls, sel, NO, NO);
}
@ -880,4 +885,8 @@ GSGetClassMethodNotInherited(Class class, SEL sel)
#endif /* NO_GNUSTEP */
#ifdef __cplusplus
}
#endif
#endif /* __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */

View file

@ -602,10 +602,10 @@ GSObjCBehaviorDebug(int i)
#if NeXT_RUNTIME
static GSMethod search_for_method_in_class (Class class, SEL op);
static GSMethod search_for_method_in_class (Class cls, SEL op);
void
GSObjCAddMethods (Class class, GSMethodList methods)
GSObjCAddMethods (Class cls, GSMethodList methods)
{
static SEL initialize_sel = 0;
GSMethodList mlist;
@ -613,7 +613,7 @@ GSObjCAddMethods (Class class, GSMethodList methods)
if (!initialize_sel)
initialize_sel = sel_register_name ("initialize");
/* Add methods to class->dtable and class->methods */
/* Add methods to cls->dtable and cls->methods */
mlist = methods;
{
int counter;
@ -635,7 +635,7 @@ GSObjCAddMethods (Class class, GSMethodList methods)
BDBGPrintf(" processing method [%s] ... ",
GSNameFromSelector(method->method_name));
if (!search_for_method_in_class(class,method->method_name)
if (!search_for_method_in_class(cls, method->method_name)
&& !sel_eq(method->method_name, initialize_sel))
{
/* As long as the method isn't defined in the CLASS,
@ -654,7 +654,7 @@ GSObjCAddMethods (Class class, GSMethodList methods)
}
if (new_list->method_count)
{
class_add_method_list(class, new_list);
class_add_method_list(cls, new_list);
}
else
{
@ -666,7 +666,7 @@ GSObjCAddMethods (Class class, GSMethodList methods)
/* Search for the named method's method structure. Return a pointer
to the method's method structure if found. NULL otherwise. */
static GSMethod
search_for_method_in_class (Class class, SEL op)
search_for_method_in_class (Class cls, SEL op)
{
void *iterator = 0;
GSMethodList method_list;
@ -675,7 +675,7 @@ search_for_method_in_class (Class class, SEL op)
return NULL;
/* If not found then we'll search the list. */
while ( (method_list = class_nextMethodList(class, &iterator)) )
while ( (method_list = class_nextMethodList(cls, &iterator)) )
{
int i;
@ -703,10 +703,10 @@ search_for_method_in_class (Class class, SEL op)
extern Method_t search_for_method_in_list(MethodList_t list, SEL op);
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 cls, SEL op);
void
GSObjCAddMethods (Class class, GSMethodList methods)
GSObjCAddMethods (Class cls, GSMethodList methods)
{
static SEL initialize_sel = 0;
GSMethodList mlist;
@ -739,7 +739,7 @@ GSObjCAddMethods (Class class, GSMethodList methods)
BDBGPrintf(" processing method [%s] ... ", name);
if (!search_for_method_in_list(class->methods, method->method_name)
if (!search_for_method_in_list(cls->methods, method->method_name)
&& !sel_eq(method->method_name, initialize_sel))
{
/* As long as the method isn't defined in the CLASS,
@ -766,7 +766,7 @@ GSObjCAddMethods (Class class, GSMethodList methods)
}
if (new_list->method_count)
{
class_add_method_list(class, new_list);
class_add_method_list(cls, new_list);
}
else
{
@ -776,19 +776,19 @@ GSObjCAddMethods (Class class, GSMethodList methods)
}
static Method_t
search_for_method_in_class (Class class, SEL op)
search_for_method_in_class (Class cls, SEL op)
{
return class != NULL ? search_for_method_in_list(class->methods, op) : NULL;
return cls != NULL ? search_for_method_in_list(cls->methods, op) : NULL;
}
#endif /* NeXT runtime */
GSMethod
GSGetMethod(Class class, SEL sel,
GSGetMethod(Class cls, SEL sel,
BOOL searchInstanceMethods,
BOOL searchSuperClasses)
{
if (class == 0 || sel == 0)
if (cls == 0 || sel == 0)
{
return 0;
}
@ -797,11 +797,11 @@ GSGetMethod(Class class, SEL sel,
{
if (searchInstanceMethods == NO)
{
return search_for_method_in_class(class->class_pointer, sel);
return search_for_method_in_class(cls->class_pointer, sel);
}
else
{
return search_for_method_in_class(class, sel);
return search_for_method_in_class(cls, sel);
}
}
else
@ -815,14 +815,14 @@ GSGetMethod(Class class, SEL sel,
Therefor we refrain from simply using class_getClassMethod().
*/
#ifdef NeXT_RUNTIME
return class_getClassMethod(class, sel);
return class_getClassMethod(cls, sel);
#else
return class_get_class_method(class->class_pointer, sel);
return class_get_class_method(cls->class_pointer, sel);
#endif
}
else
{
return class_get_instance_method(class, sel);
return class_get_instance_method(cls, sel);
}
}
}
@ -933,21 +933,21 @@ GSRemoveMethodFromList (GSMethodList list,
/* See header for documentation. */
GSMethodList
GSMethodListForSelector(Class class,
GSMethodListForSelector(Class cls,
SEL selector,
void **iterator,
BOOL searchInstanceMethods)
{
void *local_iterator = 0;
if (class == 0 || selector == 0)
if (cls == 0 || selector == 0)
{
return 0;
}
if (searchInstanceMethods == NO)
{
class = class->class_pointer;
cls = cls->class_pointer;
}
if(sel_is_mapped(selector))
@ -956,7 +956,7 @@ GSMethodListForSelector(Class class,
GSMethodList method_list;
iterator_pointer = (iterator == 0 ? &local_iterator : iterator);
while((method_list = class_nextMethodList(class, iterator_pointer)))
while((method_list = class_nextMethodList(cls, iterator_pointer)))
{
/* Search the method in the current list. */
if (GSMethodFromList(method_list, selector, NO) != 0)
@ -1004,21 +1004,21 @@ GSMethodFromList(GSMethodList list,
/* See header for documentation. */
void
GSAddMethodList(Class class,
GSAddMethodList(Class cls,
GSMethodList list,
BOOL toInstanceMethods)
{
if (class == 0 || list == 0)
if (cls == 0 || list == 0)
{
return;
}
if (toInstanceMethods == NO)
{
class = class->class_pointer;
cls = cls->class_pointer;
}
class_add_method_list(class, list);
class_add_method_list(cls, list);
}
GS_STATIC_INLINE void
@ -1039,26 +1039,26 @@ gs_revert_selector_names_in_list(GSMethodList list)
/* See header for documentation. */
void
GSRemoveMethodList(Class class,
GSRemoveMethodList(Class cls,
GSMethodList list,
BOOL fromInstanceMethods)
{
if (class == 0 || list == 0)
if (cls == 0 || list == 0)
{
return;
}
if (fromInstanceMethods == NO)
{
class = class->class_pointer;
cls = cls->class_pointer;
}
#ifdef NeXT_RUNTIME
class_removeMethods(class, list);
class_removeMethods(cls, list);
#else
if (list == class->methods)
if (list == cls->methods)
{
class->methods = list->method_next;
cls->methods = list->method_next;
list->method_next = 0;
/*
@ -1072,7 +1072,7 @@ GSRemoveMethodList(Class class,
else
{
GSMethodList current_list;
for (current_list = class->methods;
for (current_list = cls->methods;
current_list != 0;
current_list = current_list->method_next)
{
@ -1097,32 +1097,32 @@ GSRemoveMethodList(Class class,
/* See header for documentation. */
GSIVar
GSCGetInstanceVariableDefinition(Class class, const char *name)
GSCGetInstanceVariableDefinition(Class cls, const char *name)
{
struct objc_ivar_list *list;
int i;
if (class == 0)
if (cls == 0)
return 0;
list = class->ivars;
list = cls->ivars;
for (i = 0; (list != 0) && i < list->ivar_count; i++)
{
if (strcmp (list->ivar_list[i].ivar_name, name) == 0)
return &(list->ivar_list[i]);
}
class = GSObjCSuper(class);
if (class != 0)
cls = GSObjCSuper(cls);
if (cls != 0)
{
return GSCGetInstanceVariableDefinition(class, name);
return GSCGetInstanceVariableDefinition(cls, name);
}
return 0;
}
GSIVar
GSObjCGetInstanceVariableDefinition(Class class, NSString *name)
GSObjCGetInstanceVariableDefinition(Class cls, NSString *name)
{
return GSCGetInstanceVariableDefinition(class, [name cString]);
return GSCGetInstanceVariableDefinition(cls, [name cString]);
}
typedef struct {