OSDN Git Service

2011-02-16 Jonathan Wakely <jwakely.gcc@gmail.com>
[pf3gnuchains/gcc-fork.git] / libobjc / objects.c
index d37a95d..1c69456 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU Objective C Runtime class related functions
-   Copyright (C) 1993, 1995, 1996, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 1996, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Kresten Krab Thorup
 
 This file is part of GCC.
@@ -23,11 +23,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
 #include "objc-private/common.h"
-#include "objc/objc.h"
-#include "objc/objc-api.h"
-#include "objc-private/runtime.h"              /* the kitchen sink */
+#include "objc/runtime.h"
+#include "objc/thr.h"                   /* Required by objc-private/runtime.h.  */
+#include "objc-private/module-abi-8.h"  /* For CLS_ISCLASS and similar.  */
+#include "objc-private/runtime.h"      /* the kitchen sink */
 
-#include <string.h> /* For memcpy()  */
+#include <string.h>                     /* For memcpy()  */
 
 #if OBJC_WITH_GC
 # include <gc.h>
@@ -71,9 +72,6 @@ class_create_instance (Class class)
   return class_createInstance (class, 0);
 }
 
-/* Temporary, while we are including objc-api.h instead of runtime.h.  */
-#undef object_copy
-
 id
 object_copy (id object, size_t extraBytes)
 {
@@ -102,11 +100,31 @@ object_dispose (id object)
   return nil;
 }
 
-/*
-  Hook functions for memory allocation and disposal.  Deprecated
-  and currently unused.
-*/
+const char *
+object_getClassName (id object)
+{
+  if (object != nil)
+    return object->class_pointer->name;
+  else
+    return "Nil";
+}
+
+Class
+object_setClass (id object, Class class_)
+{
+  if (object == nil)
+    return Nil;
+  else
+    {
+      Class old_class = object->class_pointer;
+
+      object->class_pointer = class_;
+      return old_class;
+    }
+}
 
+/* Hook functions for memory allocation and disposal.  Deprecated and
+   currently unused.  */
 id (*_objc_object_alloc) (Class)   = 0;
 id (*_objc_object_dispose) (id)    = 0;
 id (*_objc_object_copy) (id)       = 0;