diff --git a/ChangeLog b/ChangeLog index 0f01dc62c..8ca782c5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-07-07 David Ayers + + * Headers/gnustep/base/GSObjCRuntime.h: + * Source/Additions/GSObjCRuntime.m: + Added typedef for GSIVar. + (GSCGetInstanceVariableDefinition): New function. + (GSObjCGetInstanceVariableDefinition): Ditto. + 2003-07-07 Richard Frith-Macdonald * Source/Source/GSFFCallInvocation.m: gs_objc_msg_forward() trust the diff --git a/Headers/gnustep/base/GSObjCRuntime.h b/Headers/gnustep/base/GSObjCRuntime.h index 365fb70d7..a7fc69117 100644 --- a/Headers/gnustep/base/GSObjCRuntime.h +++ b/Headers/gnustep/base/GSObjCRuntime.h @@ -272,11 +272,12 @@ GSTypesFromSelector(SEL this) /* - * Unfortunately the definition of the symbol 'Method' + * Unfortunately the definition of the symbol 'Method' "IVar(_t)" * is incompatible between the GNU and NeXT/Apple runtimes. - * We introduce GSMethod to allow portability. + * We introduce GSMethod and GSIVar to allow portability. */ typedef struct objc_method *GSMethod; +typedef struct objc_ivar *GSIVar; /** * Returns the pointer to the instance method structure @@ -365,6 +366,31 @@ GSFlushMethodCacheForClass (Class class) __objc_update_dispatch_table_for_class (class); } +/** + * Returns the pointer to the instance variable structure + * for the instance variable name in the specified class. + * This function searches the specified class and its superclasses.
+ * 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 GSIVar +GSCGetInstanceVariableDefinition(Class class, const char *name); + +/** + * Returns the pointer to the instance variable structure + * for the instance variable name in the specified class. + * This function searches the specified class and its superclasses.
+ * It is not necessarily 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 GSIVar +GSObjCGetInstanceVariableDefinition(Class class, NSString *name); + /** * Returns the superclass of this. diff --git a/Source/Additions/GSObjCRuntime.m b/Source/Additions/GSObjCRuntime.m index a023bb17d..fa7b8144a 100644 --- a/Source/Additions/GSObjCRuntime.m +++ b/Source/Additions/GSObjCRuntime.m @@ -676,6 +676,33 @@ GSGetClassMethodNotInhertited (Class class, SEL sel) return search_for_method_in_class (class->class_pointer, sel); } +/* See header for documentation. */ +GSIVar +GSCGetInstanceVariableDefinition(Class class, const char *name) +{ + struct objc_ivar_list *list; + int i; + list = class->ivars; + for (i = 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) + { + return GSCGetInstanceVariableDefinition(class, name); + } + return 0; +} + +GSIVar +GSObjCGetInstanceVariableDefinition(Class class, NSString *name) +{ + return GSCGetInstanceVariableDefinition(class, [name cString]); +} + + /** *

A Behavior can be seen as a "Protocol with an implementation" or a