In gcc/testsuite/: 2010-12-23 Nicola Pero <nicola.pero@meta-innovation.com>
[gcc.git] / libobjc / objc-private / module-abi-8.h
index 414e5e354ecb561b006d6c3529456774f4d9a060..0c9574bb49911f59fd35f82ed780eed5305a8a0a 100644 (file)
@@ -47,8 +47,17 @@ struct objc_static_instances
    categories  defined in the module.   */
 struct objc_symtab
 {
-  unsigned long sel_ref_cnt;  /* Unknown. */
-  SEL        refs;            /* Unknown. */
+  unsigned long sel_ref_cnt;  /* Unused (always set to 0). */
+  struct objc_selector *refs; /* The table of selectors referenced in
+                                 this module.  This is terminated by a
+                                 selector with NULL sel_id and NULL
+                                 sel_types.  Note that we use the type
+                                 'struct objc_selector *' and not
+                                 'SEL' (which is 'const struct
+                                 objc_selector *') because the sel_id
+                                 of these selectors is patched up by
+                                 the runtime when the module is
+                                 loaded.  */
   unsigned short cls_def_cnt; /* Number of classes compiled (defined)
                                  in the module. */
   unsigned short cat_def_cnt; /* Number of categories compiled
@@ -115,13 +124,15 @@ struct objc_ivar_list
    problem is a singly linked list of methods.  */
 struct objc_method
 {
-  SEL         method_name;  /* This variable is the method's name.  It
-                              is a char*.  The unique integer passed
-                              to objc_msg_send is a char* too.  It is
-                              compared against method_name using
-                              strcmp. */
+  SEL         method_name;  /* This variable is the method's name.
+                              The compiler puts a char* here, and
+                              it's replaced by a real SEL at runtime
+                              when the method is registered.  */
   const char* method_types; /* Description of the method's parameter
-                              list.  Useful for debuggers. */
+                              list.  Used when registering the
+                              selector with the runtime.  When that
+                              happens, method_name will contain the
+                              method's parameter list.  */
   IMP         method_imp;   /* Address of the method in the
                               executable. */
 };
@@ -139,7 +150,12 @@ struct objc_method_list
 };
 
 /* Currently defined in Protocol.m (that definition should go away
-   once we include this file).  */
+   once we include this file).  Note that a 'struct
+   objc_method_description' as embedded inside a Protocol uses the
+   same trick as a 'struct objc_method': the method_name is a 'char *'
+   according to the compiler, who puts the method name as a string in
+   there.  At runtime, the selectors need to be registered, and the
+   method_name then becomes a SEL.  */
 struct objc_method_description_list
 {
   int count;
@@ -174,7 +190,7 @@ struct objc_protocol_list
   places a string in the following member variables: super_class.
 */
 #ifndef __objc_STRUCT_OBJC_CLASS_defined
-struct objc_class {     
+struct objc_class {
   struct objc_class*  class_pointer;    /* Pointer to the class's meta
                                           class. */
   struct objc_class*  super_class;      /* Pointer to the super
@@ -227,6 +243,7 @@ struct objc_class {
 #define __CLS_INFO(cls) ((cls)->info)
 #define __CLS_ISINFO(cls, mask) ((__CLS_INFO(cls)&mask)==mask)
 #define __CLS_SETINFO(cls, mask) (__CLS_INFO(cls) |= mask)
+#define __CLS_SETNOTINFO(cls, mask) (__CLS_INFO(cls) &= ~mask)
 
 /* The structure is of type MetaClass */
 #define _CLS_META 0x2L
@@ -248,6 +265,16 @@ struct objc_class {
 #define CLS_ISINITIALIZED(cls) __CLS_ISINFO(cls, _CLS_INITIALIZED)
 #define CLS_SETINITIALIZED(cls) __CLS_SETINFO(cls, _CLS_INITIALIZED)
 
+/* The class is being constructed; it has been allocated using
+   objc_allocateClassPair(), but has not been registered yet by using
+   objc_registerClassPair().  This means it is possible to freely add
+   instance variables to the class, but it can't be used for anything
+   yet.  */
+#define _CLS_IN_CONSTRUCTION 0x10L
+#define CLS_IS_IN_CONSTRUCTION(cls) __CLS_ISINFO(cls, _CLS_IN_CONSTRUCTION)
+#define CLS_SET_IN_CONSTRUCTION(cls) __CLS_SETINFO(cls, _CLS_IN_CONSTRUCTION)
+#define CLS_SET_NOT_IN_CONSTRUCTION(cls) __CLS_SETNOTINFO(cls, _CLS_IN_CONSTRUCTION)
+
 /* The class number of this class.  This must be the same for both the
    class and its meta class object.  */
 #define CLS_GETNUMBER(cls) (__CLS_INFO(cls) >> (HOST_BITS_PER_LONG/2))