bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFA/base] GSObjCRuntime (Part 4: Access IVar definition structures)


From: David Ayers
Subject: Re: [RFA/base] GSObjCRuntime (Part 4: Access IVar definition structures)
Date: Mon, 30 Jun 2003 19:46:31 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030507


      * Headers/gnustep/base/GSObjCRuntime.h
       Source/Additions/GSObjCRuntime.m: (GSIVar) New type.)
       (GSCGetInstanceVariableDefinition): New function.
       (GSObjCGetInstanceVariableDefinition): Ditto.

Comments?

Cheers,
David

Index: Headers/gnustep/base/GSObjCRuntime.h
===================================================================
RCS file: 
/cvsroot/gnustep/gnustep/core/base/Headers/gnustep/base/GSObjCRuntime.h,v
retrieving revision 1.18
diff -u -r1.18 GSObjCRuntime.h
--- Headers/gnustep/base/GSObjCRuntime.h        28 Jun 2003 05:25:30 -0000      
1.18
+++ Headers/gnustep/base/GSObjCRuntime.h        30 Jun 2003 17:37:38 -0000
@@ -272,11 +272,12 @@
 
 
 /*
- * 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
@@ -364,6 +365,31 @@
   extern void __objc_update_dispatch_table_for_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.<br/>
+ * It should be safe to use this function in +load implementations.<br/>
+ * 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.<br/>
+ * It is not necessarily safe to use this function
+ * in +load implementations.<br/>
+ * 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);
 
 
 /**
Index: Source/Additions/GSObjCRuntime.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/Additions/GSObjCRuntime.m,v
retrieving revision 1.20
diff -u -r1.20 GSObjCRuntime.m
--- Source/Additions/GSObjCRuntime.m    22 Jun 2003 08:45:48 -0000      1.20
+++ Source/Additions/GSObjCRuntime.m    30 Jun 2003 17:37:38 -0000
@@ -673,6 +673,33 @@
   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]);
+}
+
+
 
 /**
  * <p>A Behavior can be seen as a "Protocol with an implementation" or a

reply via email to

[Prev in Thread] Current Thread [Next in Thread]