Author: mlytwyn
Date: Mon Jan 11 20:15:05 2016
New Revision: 39264

URL: http://svn.gna.org/viewcvs/gnustep?rev=39264&view=rev
Log:
Initial core attempt captured (but commented out) to utilize libobjc2 class 
alloc/free mechanism

Modified:
    libs/base/branches/gnustep_testplant_branch/Source/NSCopyObject.m
    libs/base/branches/gnustep_testplant_branch/Source/NSObject.m

Modified: libs/base/branches/gnustep_testplant_branch/Source/NSCopyObject.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Source/NSCopyObject.m?rev=39264&r1=39263&r2=39264&view=diff
==============================================================================
--- libs/base/branches/gnustep_testplant_branch/Source/NSCopyObject.m   
(original)
+++ libs/base/branches/gnustep_testplant_branch/Source/NSCopyObject.m   Mon Jan 
11 20:15:05 2016
@@ -27,11 +27,30 @@
 
 #import "common.h"
 
+#ifdef __GNUSTEP_RUNTIME__
+#include <objc/capabilities.h>
+#if defined(OBJC_CAP_ARC)
+//#define USE_USE_OBJC_CAP_ARC
+#endif
+#endif
+
 NSObject *NSCopyObject(NSObject *anObject, NSUInteger extraBytes, NSZone *zone)
 {
   Class        c = object_getClass(anObject);
+#if defined(USE_USE_OBJC_CAP_ARC)
+  id copy = object_copy(anObject, class_getInstanceSize(c) + extraBytes);
+#else
   id copy = NSAllocateObject(c, extraBytes, zone);
-
   memcpy(copy, anObject, class_getInstanceSize(c) + extraBytes);
+#endif
+  
   return copy;
 }
+
+NSObject *NSCopyObject_TP(NSObject *anObject, NSUInteger extraBytes, NSZone 
*zone)
+{
+  Class        c = object_getClass(anObject);
+  id copy = NSAllocateObject(c, extraBytes, zone);
+  memcpy(((char*)copy + sizeof(id)), ((char*)anObject + sizeof(id)), 
class_getInstanceSize(c) - sizeof(id));
+  return copy;
+}

Modified: libs/base/branches/gnustep_testplant_branch/Source/NSObject.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Source/NSObject.m?rev=39264&r1=39263&r2=39264&view=diff
==============================================================================
--- libs/base/branches/gnustep_testplant_branch/Source/NSObject.m       
(original)
+++ libs/base/branches/gnustep_testplant_branch/Source/NSObject.m       Mon Jan 
11 20:15:05 2016
@@ -76,7 +76,9 @@
 #include <objc/capabilities.h>
 #include <objc/hooks.h>
 #ifdef OBJC_CAP_ARC
+//#define USE_OBJC_CAP_ARC
 #include <objc/objc-arc.h>
+#include <objc/runtime.h>
 #endif
 #endif
 
@@ -796,6 +798,9 @@
     {
       zone = NSDefaultMallocZone();
     }
+#if defined(USE_OBJC_CAP_ARC)
+  new = class_createInstance(aClass, extraBytes);
+#else
   new = NSZoneMalloc(zone, size);
   if (new != nil)
     {
@@ -804,6 +809,7 @@
       object_setClass(new, aClass);
       AADD(aClass, new);
     }
+#endif
 
   /* Don't bother doing this in a thread-safe way, because the cost of locking
    * will be a lot more than the cost of doing the same call in two threads.
@@ -837,6 +843,9 @@
 NSDeallocateObject(id anObject)
 #endif
 {
+#if defined(USE_OBJC_CAP_ARC)
+  object_dispose(anObject);
+#else
   Class aClass = object_getClass(anObject);
 
   if ((anObject != nil) && !class_isMetaClass(aClass))
@@ -863,6 +872,7 @@
          NSZoneFree(z, o);
        }
     }
+#endif
   return;
 }
 


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to