old/new objc api updates

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33027 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2011-05-12 16:03:08 +00:00
parent 995276efc8
commit 5b47a4bd32
16 changed files with 62 additions and 18 deletions

View file

@ -1,6 +1,26 @@
2011-05-12 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPortCoder.m:
* Source/GSConcreteValueTemplate.m:
* Source/GSFFCallInvocation.m:
* Source/NSKeyedUnarchiver.m:
* Source/GSFFIInvocation.m:
* Source/NSUnarchiver.m:
* Source/NSCoder.m:
* Source/NSURL.m:
* Source/cifframe.m:
* Source/NSConnection.m:
* Source/NSData.m:
* Source/NSObjCRuntime.m:
* Source/GSValue.m:
* Source/NSValue.m:
* Source/NSArchiver.m:
updates for old/new objc api change.
2011-05-12 Fred Kiefer <FredKiefer@gmx.de> 2011-05-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSArray.m: Fix keyed decoding for GSMutableArray and GSPlaceholderArray. * Source/GSArray.m: Fix keyed decoding for GSMutableArray and
GSPlaceholderArray.
2011-05-09 Richard Frith-Macdonald <rfm@gnu.org> 2011-05-09 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -120,13 +120,15 @@
// Accessing Data // Accessing Data
- (void) getValue: (void *)value - (void) getValue: (void *)value
{ {
NSUInteger size;
if (!value) if (!value)
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Cannot copy value into NULL buffer"]; format: @"Cannot copy value into NULL buffer"];
/* NOT REACHED */ /* NOT REACHED */
} }
memcpy(value, &data, objc_sizeof_type([self objCType])); NSGetSizeAndAlignment([self objCType], 0, &size);
memcpy(value, &data, size);
} }
- (BOOL) isEqual: (id)other - (BOOL) isEqual: (id)other

View file

@ -22,6 +22,7 @@
Boston, MA 02111 USA. Boston, MA 02111 USA.
*/ */
#import "common.h" #import "common.h"
#import <objc/encoding.h>
#import "Foundation/NSException.h" #import "Foundation/NSException.h"
#import "Foundation/NSCoder.h" #import "Foundation/NSCoder.h"
#import "Foundation/NSDistantObject.h" #import "Foundation/NSDistantObject.h"

View file

@ -23,6 +23,7 @@
*/ */
#import "common.h" #import "common.h"
#import <objc/encoding.h>
#define EXPOSE_NSInvocation_IVARS 1 #define EXPOSE_NSInvocation_IVARS 1
#import "Foundation/NSException.h" #import "Foundation/NSException.h"
#import "Foundation/NSCoder.h" #import "Foundation/NSCoder.h"

View file

@ -66,7 +66,13 @@ typeSize(const char* type)
case _C_BFLD: case _C_BFLD:
case _C_ARY_B: case _C_ARY_B:
case _C_UNION_B: case _C_UNION_B:
case _C_STRUCT_B: return objc_sizeof_type(type); case _C_STRUCT_B:
{
NSUInteger size;
NSGetSizeAndAlignment(type, &size, 0);
return (int)size;
}
case _C_VOID: return 0; case _C_VOID: return 0;
default: return -1; default: return -1;
} }
@ -242,13 +248,15 @@ typeSize(const char* type)
- (void) encodeWithCoder: (NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{ {
NSUInteger tsize;
unsigned size; unsigned size;
NSMutableData *d; NSMutableData *d;
size = strlen(objctype)+1; size = strlen(objctype)+1;
[coder encodeValueOfObjCType: @encode(unsigned) at: &size]; [coder encodeValueOfObjCType: @encode(unsigned) at: &size];
[coder encodeArrayOfObjCType: @encode(signed char) count: size at: objctype]; [coder encodeArrayOfObjCType: @encode(signed char) count: size at: objctype];
size = objc_sizeof_type(objctype); NSGetSizeAndAlignment(objctype, 0, &tsize);
size = tsize;
d = [NSMutableData new]; d = [NSMutableData new];
[d serializeDataAt: data ofObjCType: objctype context: nil]; [d serializeDataAt: data ofObjCType: objctype context: nil];
size = [d length]; size = [d length];

View file

@ -26,6 +26,7 @@
*/ */
#import "common.h" #import "common.h"
#import <objc/encoding.h>
#define EXPOSE_NSArchiver_IVARS 1 #define EXPOSE_NSArchiver_IVARS 1
#define EXPOSE_NSUnarchiver_IVARS 1 #define EXPOSE_NSUnarchiver_IVARS 1
/* /*

View file

@ -27,6 +27,7 @@
*/ */
#import "common.h" #import "common.h"
#import <objc/encoding.h>
#define EXPOSE_NSCoder_IVARS 1 #define EXPOSE_NSCoder_IVARS 1
#import "Foundation/NSData.h" #import "Foundation/NSData.h"
#import "Foundation/NSCoder.h" #import "Foundation/NSCoder.h"

View file

@ -30,6 +30,7 @@
*/ */
#import "common.h" #import "common.h"
#import <objc/encoding.h>
#define GS_NSConnection_IVARS \ #define GS_NSConnection_IVARS \
BOOL _isValid; \ BOOL _isValid; \

View file

@ -68,6 +68,7 @@
*/ */
#import "common.h" #import "common.h"
#import <objc/encoding.h>
#import "GNUstepBase/GSObjCRuntime.h" #import "GNUstepBase/GSObjCRuntime.h"
#import "Foundation/NSByteOrder.h" #import "Foundation/NSByteOrder.h"
#import "Foundation/NSCoder.h" #import "Foundation/NSCoder.h"

View file

@ -380,7 +380,8 @@ static NSMapTable *globalClassMap = 0;
count: (NSUInteger)expected count: (NSUInteger)expected
at: (void*)buf at: (void*)buf
{ {
id o = [self decodeObject]; id o = [self decodeObject];
NSUInteger size;
if ([o isKindOfClass: [_NSKeyedCoderOldStyleArray class]] == NO) if ([o isKindOfClass: [_NSKeyedCoderOldStyleArray class]] == NO)
{ {
@ -400,7 +401,8 @@ static NSMapTable *globalClassMap = 0;
format: @"[%@ +%@]: count missmatch", format: @"[%@ +%@]: count missmatch",
NSStringFromClass([self class]), NSStringFromSelector(_cmd), o]; NSStringFromClass([self class]), NSStringFromSelector(_cmd), o];
} }
memcpy(buf, [o bytes], expected * objc_sizeof_type(type)); NSGetSizeAndAlignment(type, 0, &size);
memcpy(buf, [o bytes], expected * size);
} }
- (BOOL) decodeBoolForKey: (NSString*)aKey - (BOOL) decodeBoolForKey: (NSString*)aKey

View file

@ -26,6 +26,7 @@
*/ */
#import "common.h" #import "common.h"
#import <objc/encoding.h>
#import "Foundation/NSException.h" #import "Foundation/NSException.h"
#include <string.h> #include <string.h>

View file

@ -34,6 +34,7 @@
*/ */
#import "common.h" #import "common.h"
#import <objc/encoding.h>
#define EXPOSE_NSPortCoder_IVARS 1 #define EXPOSE_NSPortCoder_IVARS 1
#import "Foundation/NSException.h" #import "Foundation/NSException.h"
#import "Foundation/NSByteOrder.h" #import "Foundation/NSByteOrder.h"

View file

@ -574,7 +574,7 @@ static char *unescape(const char *from, char * to)
*/ */
@implementation NSURL @implementation NSURL
static unsigned urlAlign; static NSUInteger urlAlign;
/** /**
* Create and return a file URL with the supplied path.<br /> * Create and return a file URL with the supplied path.<br />
@ -591,7 +591,7 @@ static unsigned urlAlign;
{ {
if (clientsLock == nil) if (clientsLock == nil)
{ {
urlAlign = objc_alignof_type(@encode(parsedURL)); NSGetSizeAndAlignment(@encode(parsedURL), &urlAlign, 0);
clientsLock = [NSLock new]; clientsLock = [NSLock new];
} }
} }

View file

@ -26,6 +26,7 @@
*/ */
#import "common.h" #import "common.h"
#import <objc/encoding.h>
#define EXPOSE_NSUnarchiver_IVARS 1 #define EXPOSE_NSUnarchiver_IVARS 1
#include <string.h> #include <string.h>
#import "Foundation/NSDictionary.h" #import "Foundation/NSDictionary.h"

View file

@ -383,6 +383,7 @@ static NSLock *placeholderLock;
- (void) encodeWithCoder: (NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{ {
NSUInteger tsize;
unsigned size; unsigned size;
const char *data; const char *data;
const char *objctype = [self objCType]; const char *objctype = [self objCType];
@ -420,8 +421,8 @@ static NSLock *placeholderLock;
return; return;
} }
size = objc_sizeof_type(objctype); NSGetSizeAndAlignment(objctype, 0, &tsize);
data = (void *)NSZoneMalloc([self zone], size); data = (void *)NSZoneMalloc([self zone], tsize);
[self getValue: (void*)data]; [self getValue: (void*)data];
d = [NSMutableData new]; d = [NSMutableData new];
[d serializeDataAt: data ofObjCType: objctype context: nil]; [d serializeDataAt: data ofObjCType: objctype context: nil];
@ -439,6 +440,7 @@ static NSLock *placeholderLock;
const char *objctype; const char *objctype;
Class c; Class c;
id o; id o;
NSUInteger tsize;
unsigned size; unsigned size;
int ver; int ver;
@ -562,10 +564,10 @@ static NSLock *placeholderLock;
* For performance, decode small values directly onto the stack, * For performance, decode small values directly onto the stack,
* For larger values we allocate and deallocate heap space. * For larger values we allocate and deallocate heap space.
*/ */
size = objc_sizeof_type(objctype); NSGetSizeAndAlignment(objctype, 0, &tsize);
if (size <= 64) if (tsize <= 64)
{ {
unsigned char data[size]; unsigned char data[tsize];
[coder decodeValueOfObjCType: @encode(id) at: &d]; [coder decodeValueOfObjCType: @encode(id) at: &d];
[d deserializeDataAt: data [d deserializeDataAt: data
@ -579,7 +581,7 @@ static NSLock *placeholderLock;
{ {
unsigned char *data; unsigned char *data;
data = (void *)NSZoneMalloc(NSDefaultMallocZone(), size); data = (void *)NSZoneMalloc(NSDefaultMallocZone(), tsize);
[coder decodeValueOfObjCType: @encode(id) at: &d]; [coder decodeValueOfObjCType: @encode(id) at: &d];
[d deserializeDataAt: data [d deserializeDataAt: data
ofObjCType: objctype ofObjCType: objctype
@ -604,10 +606,10 @@ static NSLock *placeholderLock;
* For performance, decode small values directly onto the stack, * For performance, decode small values directly onto the stack,
* For larger values we allocate and deallocate heap space. * For larger values we allocate and deallocate heap space.
*/ */
size = objc_sizeof_type(objctype); NSGetSizeAndAlignment(objctype, 0, &tsize);
if (size <= 64) if (tsize <= 64)
{ {
unsigned char data[size]; unsigned char data[tsize];
[coder decodeValueOfObjCType: @encode(unsigned) at: &size]; [coder decodeValueOfObjCType: @encode(unsigned) at: &size];
{ {
@ -628,7 +630,7 @@ static NSLock *placeholderLock;
{ {
void *data; void *data;
data = (void *)NSZoneMalloc(NSDefaultMallocZone(), size); data = (void *)NSZoneMalloc(NSDefaultMallocZone(), tsize);
[coder decodeValueOfObjCType: @encode(unsigned) at: &size]; [coder decodeValueOfObjCType: @encode(unsigned) at: &size];
{ {
void *serialized; void *serialized;

View file

@ -24,6 +24,7 @@
*/ */
#import "common.h" #import "common.h"
#import <objc/encoding.h>
#ifdef HAVE_MALLOC_H #ifdef HAVE_MALLOC_H
#include <malloc.h> #include <malloc.h>