Patchwork libobjc: remove unused code (patch 1)

login
register
mail settings
Submitter Nicola Pero
Date June 7, 2011, 9:20 p.m.
Message ID <1307481635.299726377@www2.webmail.us>
Download mbox | patch
Permalink /patch/99330/
State New
Headers show

Comments

Nicola Pero - June 7, 2011, 9:20 p.m.
This patch removes some obsolete code (which used to be used by the Traditional API)
and that is no longer used anywhere.

Committed to trunk.

Thanks

Patch

Index: class.c
===================================================================
--- class.c     (revision 174766)
+++ class.c     (working copy)
@@ -203,41 +203,6 @@  class_table_insert (const char *class_name, Class
   objc_mutex_unlock (__class_table_lock);
 }
 
-/* Replace a class in the table (used only by poseAs:).  */
-static void 
-class_table_replace (Class old_class_pointer, Class new_class_pointer)
-{
-  int hash;
-  class_node_ptr node;
-
-  objc_mutex_lock (__class_table_lock);
-  
-  hash = 0;
-  node = class_table_array[hash];
-  
-  while (hash < CLASS_TABLE_SIZE)
-    {
-      if (node == NULL)
-        {
-          hash++;
-          if (hash < CLASS_TABLE_SIZE)
-           node = class_table_array[hash];
-        }
-      else
-        {
-          Class class1 = node->pointer;
-
-          if (class1 == old_class_pointer)
-           node->pointer = new_class_pointer;
-
-          node = node->next;
-        }
-    }
-
-  objc_mutex_unlock (__class_table_lock);
-}
-
-
 /* Get a class from the table.  This does not need mutex protection.
    Currently, this function is called each time you call a static
    method, this is why it must be very fast.  */
@@ -760,16 +725,6 @@  objc_disposeClassPair (Class class_)
   objc_free (class_);
 }
 
-/* Traditional GNU Objective-C Runtime API.  */
-/* Get the class object for the class named NAME.  If NAME does not
-   identify a known class, the hook _objc_lookup_class is called.  If
-   this fails, nil is returned.  */
-Class
-objc_lookup_class (const char *name)
-{
-  return objc_getClass (name);
-}
-
 /* Traditional GNU Objective-C Runtime API.  Important: this method is
    called automatically by the compiler while messaging (if using the
    traditional ABI), so it is worth keeping it fast; don't make it
@@ -802,38 +757,13 @@  objc_get_class (const char *name)
   return 0;
 }
 
+/* This is used by the compiler too.  */
 Class
 objc_get_meta_class (const char *name)
 {
   return objc_get_class (name)->class_pointer;
 }
 
-/* This function provides a way to enumerate all the classes in the
-   executable.  Pass *ENUM_STATE == NULL to start the enumeration.  The
-   function will return 0 when there are no more classes.  
-   For example: 
-       id class; 
-       void *es = NULL;
-       while ((class = objc_next_class (&es)))
-         ... do something with class; 
-*/
-Class
-objc_next_class (void **enum_state)
-{
-  Class class;
-
-  objc_mutex_lock (__objc_runtime_mutex);
-  
-  /* Make sure the table is there.  */
-  assert (__class_table_lock);
-
-  class = class_table_next ((struct class_table_enumerator **) enum_state);
-
-  objc_mutex_unlock (__objc_runtime_mutex);
-  
-  return class;
-}
-
 /* This is used when the implementation of a method changes.  It goes
    through all classes, looking for the ones that have these methods
    (either method_a or method_b; method_b can be NULL), and reloads
@@ -1035,83 +965,3 @@  class_getInstanceSize (Class class_)
   return class_->instance_size;
 }
 
-#define CLASSOF(c) ((c)->class_pointer)
-
-Class
-class_pose_as (Class impostor, Class super_class)
-{
-  if (! CLS_ISRESOLV (impostor))
-    __objc_resolve_class_links ();
-
-  /* Preconditions */
-  assert (impostor);
-  assert (super_class);
-  assert (impostor->super_class == super_class);
-  assert (CLS_ISCLASS (impostor));
-  assert (CLS_ISCLASS (super_class));
-  assert (impostor->instance_size == super_class->instance_size);
-
-  {
-    Class *subclass = &(super_class->subclass_list);
-
-    /* Move subclasses of super_class to impostor.  */
-    while (*subclass)
-      {
-        Class nextSub = (*subclass)->sibling_class;
-
-        if (*subclass != impostor)
-          {
-            Class sub = *subclass;
-
-            /* Classes */
-            sub->sibling_class = impostor->subclass_list;
-            sub->super_class = impostor;
-            impostor->subclass_list = sub;
-
-            /* It will happen that SUB is not a class object if it is
-               the top of the meta class hierarchy chain (root
-               meta-class objects inherit their class object).  If
-               that is the case... don't mess with the meta-meta
-               class.  */
-            if (CLS_ISCLASS (sub))
-              {
-                /* Meta classes */
-                CLASSOF (sub)->sibling_class = 
-                  CLASSOF (impostor)->subclass_list;
-                CLASSOF (sub)->super_class = CLASSOF (impostor);
-                CLASSOF (impostor)->subclass_list = CLASSOF (sub);
-              }
-          }
-
-        *subclass = nextSub;
-      }
-
-    /* Set subclasses of superclass to be impostor only.  */
-    super_class->subclass_list = impostor;
-    CLASSOF (super_class)->subclass_list = CLASSOF (impostor);
-    
-    /* Set impostor to have no sibling classes.  */
-    impostor->sibling_class = 0;
-    CLASSOF (impostor)->sibling_class = 0;
-  }
-  
-  /* Check relationship of impostor and super_class is kept.  */
-  assert (impostor->super_class == super_class);
-  assert (CLASSOF (impostor)->super_class == CLASSOF (super_class));
-
-  /* This is how to update the lookup table.  Regardless of what the
-     keys of the hashtable is, change all values that are superclass
-     into impostor.  */
-
-  objc_mutex_lock (__objc_runtime_mutex);
-
-  class_table_replace (super_class, impostor);
-
-  objc_mutex_unlock (__objc_runtime_mutex);
-
-  /* Next, we update the dispatch tables...  */
-  __objc_update_dispatch_table_for_class (CLASSOF (impostor));
-  __objc_update_dispatch_table_for_class (impostor);
-
-  return impostor;
-}
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 174766)
+++ ChangeLog   (working copy)
@@ -1,5 +1,13 @@ 
 2011-06-07  Nicola Pero  <nicola.pero@meta-innovation.com>
 
+       * class.c (objc_next_class): Removed.
+       (class_pose_as): Removed.
+       (CLASSOF): Removed.
+       (class_table_replace): Removed.
+       (objc_lookup_class): Removed.
+
+2011-06-07  Nicola Pero  <nicola.pero@meta-innovation.com>
+
        Removed the Traditional Objective-C runtime public API.
        * Makefile.in (OBJC_DEPRECATED_H): Variable removed.
        (install-headers): Do not create the objc/deprecated directory and