mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
Replace old code directly referencing class_pointer ivar with calls to the new runtime API treating objects as opaque pointers.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32243 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d32eb0e985
commit
fb08144b5e
4 changed files with 28 additions and 26 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2011-02-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSFFIInvocation.m:
|
||||||
|
* Source/NSCopyObject.m:
|
||||||
|
* Source/NSObject.m:
|
||||||
|
Replace old code directly referencing class_pointer ivar with calls
|
||||||
|
to the new runtime API treating objects as opaque pointers.
|
||||||
|
|
||||||
2011-02-20 Richard Frith-Macdonald <rfm@gnu.org>
|
2011-02-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSPortCoder.m:
|
* Source/NSPortCoder.m:
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
Boston, MA 02111 USA.
|
Boston, MA 02111 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define class_pointer isa
|
|
||||||
|
|
||||||
#import "common.h"
|
#import "common.h"
|
||||||
#define EXPOSE_NSInvocation_IVARS 1
|
#define EXPOSE_NSInvocation_IVARS 1
|
||||||
#import "Foundation/NSException.h"
|
#import "Foundation/NSException.h"
|
||||||
|
@ -266,7 +264,7 @@ static id gs_objc_proxy_lookup(id receiver, SEL op)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (class_respondsToSelector(cls->class_pointer,
|
if (class_respondsToSelector(object_getClass(cls),
|
||||||
@selector(resolveInstanceMethod:)))
|
@selector(resolveInstanceMethod:)))
|
||||||
{
|
{
|
||||||
resolved = [cls resolveInstanceMethod: op];
|
resolved = [cls resolveInstanceMethod: op];
|
||||||
|
@ -537,7 +535,7 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user)
|
||||||
obj = *(id *)args[0];
|
obj = *(id *)args[0];
|
||||||
selector = *(SEL *)args[1];
|
selector = *(SEL *)args[1];
|
||||||
|
|
||||||
if (!class_respondsToSelector(obj->class_pointer,
|
if (!class_respondsToSelector(object_getClass(obj),
|
||||||
@selector(forwardInvocation:)))
|
@selector(forwardInvocation:)))
|
||||||
{
|
{
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
|
|
@ -29,11 +29,9 @@
|
||||||
|
|
||||||
NSObject *NSCopyObject(NSObject *anObject, NSUInteger extraBytes, NSZone *zone)
|
NSObject *NSCopyObject(NSObject *anObject, NSUInteger extraBytes, NSZone *zone)
|
||||||
{
|
{
|
||||||
// Note: The cast to Class* and dereference gets the isa pointer. This is
|
Class c = object_getClass(anObject);
|
||||||
// ugly, but is required because the old GNU runtime calls this
|
id copy = NSAllocateObject(c, extraBytes, zone);
|
||||||
// class_pointer, rather than isa, just to be different.
|
|
||||||
id copy = NSAllocateObject((*(Class*)anObject), extraBytes, zone);
|
memcpy(copy, anObject, class_getInstanceSize(c) + extraBytes);
|
||||||
memcpy(copy, anObject,
|
|
||||||
class_getInstanceSize(object_getClass(anObject)) + extraBytes);
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,6 @@
|
||||||
$Date$ $Revision$
|
$Date$ $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Make sure that class_pointer in the old runtime's definition of id is
|
|
||||||
// renamed isa, and so are all uses.
|
|
||||||
#define class_pointer isa
|
|
||||||
|
|
||||||
/* On some versions of mingw we need to work around bad function declarations
|
/* On some versions of mingw we need to work around bad function declarations
|
||||||
* by defining them away and doing the declarations ourself later.
|
* by defining them away and doing the declarations ourself later.
|
||||||
*/
|
*/
|
||||||
|
@ -579,8 +575,8 @@ static void
|
||||||
GSFinalize(void* object, void* data)
|
GSFinalize(void* object, void* data)
|
||||||
{
|
{
|
||||||
[(id)object finalize];
|
[(id)object finalize];
|
||||||
AREM(((id)object)->class_pointer, (id)object);
|
AREM(object_getClass((id)object), (id)object);
|
||||||
((id)object)->class_pointer = (void*)0xdeadface;
|
object_setClass((id)object, (Classa)(void*)0xdeadface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
|
@ -622,7 +618,7 @@ NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone)
|
||||||
|
|
||||||
if (new != nil)
|
if (new != nil)
|
||||||
{
|
{
|
||||||
new->class_pointer = aClass;
|
object_setClass(new, aClass);
|
||||||
if (GSIsFinalizable(aClass))
|
if (GSIsFinalizable(aClass))
|
||||||
{
|
{
|
||||||
/* We only do allocation counting for objects that can be
|
/* We only do allocation counting for objects that can be
|
||||||
|
@ -670,7 +666,7 @@ NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone *zone)
|
||||||
memset (new, 0, size);
|
memset (new, 0, size);
|
||||||
((obj)new)->zone = zone;
|
((obj)new)->zone = zone;
|
||||||
new = (id)&((obj)new)[1];
|
new = (id)&((obj)new)[1];
|
||||||
new->class_pointer = aClass;
|
object_setClass(new, aClass);
|
||||||
AADD(aClass, new);
|
AADD(aClass, new);
|
||||||
}
|
}
|
||||||
return new;
|
return new;
|
||||||
|
@ -679,12 +675,12 @@ NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone *zone)
|
||||||
inline void
|
inline void
|
||||||
NSDeallocateObject(id anObject)
|
NSDeallocateObject(id anObject)
|
||||||
{
|
{
|
||||||
if ((anObject!=nil) && !class_isMetaClass(((id)anObject)->class_pointer))
|
if ((anObject!=nil) && !class_isMetaClass(object_getClass((id)anObject)))
|
||||||
{
|
{
|
||||||
obj o = &((obj)anObject)[-1];
|
obj o = &((obj)anObject)[-1];
|
||||||
NSZone *z = o->zone;
|
NSZone *z = o->zone;
|
||||||
|
|
||||||
AREM(((id)anObject)->class_pointer, (id)anObject);
|
AREM(object_getClass((id)anObject), (id)anObject);
|
||||||
if (NSZombieEnabled == YES)
|
if (NSZombieEnabled == YES)
|
||||||
{
|
{
|
||||||
GSMakeZombie(anObject);
|
GSMakeZombie(anObject);
|
||||||
|
@ -695,7 +691,7 @@ NSDeallocateObject(id anObject)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((id)anObject)->class_pointer = (void*) 0xdeadface;
|
object_setClass((id)anObject, (Class)(void*)0xdeadface);
|
||||||
NSZoneFree(z, o);
|
NSZoneFree(z, o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -708,19 +704,21 @@ NSDeallocateObject(id anObject)
|
||||||
void
|
void
|
||||||
GSPrivateSwizzle(id o, Class c)
|
GSPrivateSwizzle(id o, Class c)
|
||||||
{
|
{
|
||||||
if ((Class)o->class_pointer != c)
|
Class oc = object_getClass(o);
|
||||||
|
|
||||||
|
if (oc != c)
|
||||||
{
|
{
|
||||||
#if GS_WITH_GC
|
#if GS_WITH_GC
|
||||||
/* We only do allocation counting for objects that can be
|
/* We only do allocation counting for objects that can be
|
||||||
* finalised - for other objects we have no way of decrementing
|
* finalised - for other objects we have no way of decrementing
|
||||||
* the count when the object is collected.
|
* the count when the object is collected.
|
||||||
*/
|
*/
|
||||||
if (GSIsFinalizable(o->class_pointer))
|
if (GSIsFinalizable(oc))
|
||||||
{
|
{
|
||||||
/* Already finalizable, so we just need to do any allocation
|
/* Already finalizable, so we just need to do any allocation
|
||||||
* accounting.
|
* accounting.
|
||||||
*/
|
*/
|
||||||
AREM(o->class_pointer, o);
|
AREM(oc, o);
|
||||||
AADD(c, o);
|
AADD(c, o);
|
||||||
}
|
}
|
||||||
else if (GSIsFinalizable(c))
|
else if (GSIsFinalizable(c))
|
||||||
|
@ -732,10 +730,10 @@ GSPrivateSwizzle(id o, Class c)
|
||||||
GC_REGISTER_FINALIZER (o, GSFinalize, NULL, NULL, NULL);
|
GC_REGISTER_FINALIZER (o, GSFinalize, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
AREM(o->class_pointer, o);
|
AREM(oc, o);
|
||||||
AADD(c, o);
|
AADD(c, o);
|
||||||
#endif /* GS_WITH_GC */
|
#endif /* GS_WITH_GC */
|
||||||
o->class_pointer = c;
|
object_setClass(o, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue