64bit safety fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32731 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-03-29 08:16:02 +00:00
parent 2e1b6bafcb
commit c0979f8d17
10 changed files with 121 additions and 91 deletions

View file

@ -1,3 +1,22 @@
2011-03-29 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/GNUstepBase/GSIMap.h:
* Headers/GNUstepBase/GSUnion.h:
* Source/GSAttributedString.m:
* Source/NSArchiver.m:
* Source/NSConnection.m:
* Source/NSKeyedArchiver.m:
* Source/NSNotificationCenter.m:
* Source/NSPortCoder.m:
* Source/NSSerializer.m:
Fixes for problem spotted by David Chisnall ... on a 64bit system where
the size of an integer is not the same as the size of a pointer the
union holding map keys and values will have undefined content if we
assign an integer to it and then use it as a pointer!
So, we change to use the .nsu accessor for a pointer sized integer
throughout, and we remove all the odd sized union members unless
GSUNION_DEPRECATED is defined.
2011-03-28 Riccardo Mottola <rm@gnu.org>
* Source/NSPathUtilities.m:

View file

@ -993,7 +993,7 @@ GSIMapCountByEnumeratingWithStateObjectsCount(GSIMapTable map,
* will only work with things that are id-sized, however, so don't
* try using it with non-object collections.
*/
stackbuf[i] = *(id*)(void*)&node->key.bl;
stackbuf[i] = *(id*)(void*)&node->key.addr;
}
}
/* Store the important bits of the enumerator in the caller. */

View file

@ -70,7 +70,7 @@ typedef uintptr_t NSUInteger;
#if defined(GSUNION) && defined(GSUNION_TYPES)
typedef union {
NSUInteger addr;
NSUInteger addr; /* Always present */
#if ((GSUNION_TYPES) & GSUNION_OBJ)
id obj;
NSObject *nso;
@ -81,6 +81,20 @@ typedef union {
#if ((GSUNION_TYPES) & GSUNION_SEL)
SEL sel;
#endif
#if ((GSUNION_TYPES) & GSUNION_NSINT)
NSInteger nsi;
NSUInteger nsu;
#endif
#if ((GSUNION_TYPES) & GSUNION_PTR)
void *ptr;
const void *cptr;
char *str;
const char *cstr;
#endif
/* The next group are deprecated ... define GSUNION_DEPRECATED to use them
*/
#if defined(GSUNION_DEPRECATED)
#if ((GSUNION_TYPES) & GSUNION_CHAR)
char schr;
unsigned char uchr;
@ -97,16 +111,6 @@ typedef union {
long slng;
unsigned long ulng;
#endif
#if ((GSUNION_TYPES) & GSUNION_NSINT)
NSInteger nsi;
NSUInteger nsu;
#endif
#if ((GSUNION_TYPES) & GSUNION_PTR)
void *ptr;
const void *cptr;
char *str;
const char *cstr;
#endif
#if ((GSUNION_TYPES) & GSUNION_8B)
int8_t s8;
uint8_t u8;
@ -123,10 +127,17 @@ typedef union {
int64_t s64;
uint64_t u64;
#endif
#endif
/* Warning ... if this value is declared in the union, and its type is not
* the same size as a pointer, then care must be taken in case of confusion
* caused when an assignment to a variable using one of the union's types
* causes part of the variable to ebe left with undefined content from the
* point of view of another of the union's types.
*/
#if defined(GSUNION_EXTRA)
GSUNION_EXTRA ext;
#endif
BOOL bl; /* Guaranteed present */
} GSUNION;
#endif

View file

@ -103,7 +103,7 @@ static NSDictionary *blank;
#define GSI_MAP_RELEASE_VAL(M, X)
#define GSI_MAP_EQUAL(M, X,Y) [(X).obj isEqualToDictionary: (Y).obj]
#define GSI_MAP_KTYPES GSUNION_OBJ
#define GSI_MAP_VTYPES GSUNION_INT
#define GSI_MAP_VTYPES GSUNION_NSINT
#define GSI_MAP_NOCLEAN 1
#if GS_WITH_GC
@ -148,7 +148,7 @@ cacheAttributes(NSDictionary *attrs)
}
else
{
node->value.uint++;
node->value.nsu++;
attrs = RETAIN(node->key.obj);
}
AUNLOCK();
@ -169,7 +169,7 @@ unCacheAttributes(NSDictionary *attrs)
node = GSIMapNodeForKeyInBucket(&attrMap, bucket, (GSIMapKey)((id)attrs));
if (node != 0)
{
if (--node->value.uint == 0)
if (--node->value.nsu == 0)
{
GSIMapRemoveNodeFromMap(&attrMap, bucket, node);
GSIMapFreeNode(&attrMap, node);

View file

@ -31,13 +31,13 @@
/*
* Setup for inline operation of pointer map tables.
*/
#define GSI_MAP_KTYPES GSUNION_INT | GSUNION_PTR | GSUNION_OBJ | GSUNION_CLS
#define GSI_MAP_VTYPES GSUNION_INT | GSUNION_PTR | GSUNION_OBJ
#define GSI_MAP_KTYPES GSUNION_NSINT | GSUNION_PTR | GSUNION_OBJ | GSUNION_CLS
#define GSI_MAP_VTYPES GSUNION_NSINT | GSUNION_PTR | GSUNION_OBJ
#define GSI_MAP_RETAIN_KEY(M, X)
#define GSI_MAP_RELEASE_KEY(M, X)
#define GSI_MAP_RETAIN_VAL(M, X)
#define GSI_MAP_RELEASE_VAL(M, X)
#define GSI_MAP_HASH(M, X) ((X).uint)
#define GSI_MAP_HASH(M, X) ((X).nsu)
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
#define GSI_MAP_NOCLEAN 1
#if GS_WITH_GC
@ -384,7 +384,7 @@ static Class NSMutableDataMallocClass;
(*_eValImp)(self, eValSel, type, buf);
}
}
else if (node == 0 || node->value.uint == 0)
else if (node == 0 || node->value.nsu == 0)
{
/*
* Second pass, unwritten pointer - write it.
@ -396,9 +396,9 @@ static Class NSMutableDataMallocClass;
}
else
{
node->value.uint = ++_xRefP;
node->value.nsu = ++_xRefP;
}
(*_xRefImp)(_dst, xRefSel, _GSC_PTR, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_PTR, node->value.nsu);
type++;
buf = *(char**)buf;
(*_eValImp)(self, eValSel, type, buf);
@ -409,7 +409,7 @@ static Class NSMutableDataMallocClass;
* Second pass, write a cross-reference number.
*/
(*_xRefImp)(_dst, xRefSel, _GSC_PTR|_GSC_XREF,
node->value.uint);
node->value.nsu);
}
}
return;
@ -443,7 +443,7 @@ static Class NSMutableDataMallocClass;
if (node != 0)
{
(*_xRefImp)(_dst, xRefSel, _GSC_CLASS | _GSC_XREF,
node->value.uint);
node->value.nsu);
return;
}
while (done == NO)
@ -462,7 +462,7 @@ static Class NSMutableDataMallocClass;
/*
* Encode tag and crossref number.
*/
(*_xRefImp)(_dst, xRefSel, _GSC_CLASS, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_CLASS, node->value.nsu);
/*
* Encode class, and version.
*/
@ -509,7 +509,7 @@ static Class NSMutableDataMallocClass;
{
node = GSIMapAddPair(_ptrMap,
(GSIMapKey)(void*)s, (GSIMapVal)++_xRefP);
(*_xRefImp)(_dst, xRefSel, _GSC_SEL, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_SEL, node->value.nsu);
/*
* Encode selector.
*/
@ -518,7 +518,7 @@ static Class NSMutableDataMallocClass;
else
{
(*_xRefImp)(_dst, xRefSel, _GSC_SEL|_GSC_XREF,
node->value.uint);
node->value.nsu);
}
}
return;
@ -540,13 +540,13 @@ static Class NSMutableDataMallocClass;
{
node = GSIMapAddPair(_ptrMap,
(GSIMapKey)*(char**)buf, (GSIMapVal)++_xRefP);
(*_xRefImp)(_dst, xRefSel, _GSC_CHARPTR, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_CHARPTR, node->value.nsu);
(*_serImp)(_dst, serSel, buf, type, nil);
}
else
{
(*_xRefImp)(_dst, xRefSel, _GSC_CHARPTR|_GSC_XREF,
node->value.uint);
node->value.nsu);
}
}
return;
@ -794,7 +794,7 @@ static Class NSMutableDataMallocClass;
return;
}
if (node == 0 || node->value.uint == 0)
if (node == 0 || node->value.nsu == 0)
{
Class cls;
id obj;
@ -806,7 +806,7 @@ static Class NSMutableDataMallocClass;
}
else
{
node->value.uint = ++_xRefO;
node->value.nsu = ++_xRefO;
}
obj = [anObject replacementObjectForArchiver: self];
@ -816,7 +816,7 @@ static Class NSMutableDataMallocClass;
* If the object we have been given is actually a class,
* we encode it as a special case.
*/
(*_xRefImp)(_dst, xRefSel, _GSC_CID, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_CID, node->value.nsu);
(*_eValImp)(self, eValSel, @encode(Class), &obj);
}
else
@ -833,14 +833,14 @@ static Class NSMutableDataMallocClass;
cls = (Class)n->value.ptr;
}
}
(*_xRefImp)(_dst, xRefSel, _GSC_ID, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_ID, node->value.nsu);
(*_eValImp)(self, eValSel, @encode(Class), &cls);
[obj encodeWithCoder: self];
}
}
else
{
(*_xRefImp)(_dst, xRefSel, _GSC_ID | _GSC_XREF, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_ID | _GSC_XREF, node->value.nsu);
}
}
}

View file

@ -96,13 +96,13 @@ skip_argspec(const char *ptr)
/*
* Setup for inline operation of pointer map tables.
*/
#define GSI_MAP_KTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_INT
#define GSI_MAP_KTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_NSINT
#define GSI_MAP_VTYPES GSUNION_PTR | GSUNION_OBJ
#define GSI_MAP_RETAIN_KEY(M, X)
#define GSI_MAP_RELEASE_KEY(M, X)
#define GSI_MAP_RETAIN_VAL(M, X)
#define GSI_MAP_RELEASE_VAL(M, X)
#define GSI_MAP_HASH(M, X) ((X).uint ^ ((X).uint >> 3))
#define GSI_MAP_HASH(M, X) ((X).nsu ^ ((X).nsu >> 3))
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
#define GSI_MAP_NOCLEAN 1
#if GS_WITH_GC
@ -2044,7 +2044,7 @@ static NSLock *cached_proxies_gate = nil;
* a response, we must check for it and scrap it if necessary.
*/
M_LOCK(IrefGate);
node = GSIMapNodeForKey(IreplyMap, (GSIMapKey)(id)(NSInteger)seq);
node = GSIMapNodeForKey(IreplyMap, (GSIMapKey)seq);
if (node != 0 && node->value.obj != dummyObject)
{
BOOL is_exception = NO;
@ -2058,7 +2058,7 @@ static NSLock *cached_proxies_gate = nil;
NSLog(@"Got response with %@", NSStringFromSelector(sel));
[self _doneInRmc: node->value.obj];
}
GSIMapRemoveKey(IreplyMap, (GSIMapKey)(id)(NSInteger)seq);
GSIMapRemoveKey(IreplyMap, (GSIMapKey)seq);
M_UNLOCK(IrefGate);
}
else
@ -2376,7 +2376,7 @@ static NSLock *cached_proxies_gate = nil;
break;
}
M_LOCK(GSIVar(conn, _refGate));
node = GSIMapNodeForKey(GSIVar(conn, _replyMap), (GSIMapKey)(id)(NSInteger)sequence);
node = GSIMapNodeForKey(GSIVar(conn, _replyMap), (GSIMapKey)sequence);
if (node == 0)
{
NSDebugMLLog(@"NSConnection", @"Ignoring reply RMC %d on %@",
@ -3135,7 +3135,7 @@ static NSLock *cached_proxies_gate = nil;
sn, self);
M_LOCK(IrefGate); isLocked = YES;
while (IisValid == YES
&& (node = GSIMapNodeForKey(IreplyMap, (GSIMapKey)(id)(NSInteger)sn)) != 0
&& (node = GSIMapNodeForKey(IreplyMap, (GSIMapKey)sn)) != 0
&& node->value.obj == dummyObject)
{
NSDate *limit_date;
@ -3185,7 +3185,7 @@ static NSLock *cached_proxies_gate = nil;
|| [timeout_date timeIntervalSinceNow] <= 0.0)
{
M_LOCK(IrefGate); isLocked = YES;
node = GSIMapNodeForKey(IreplyMap, (GSIMapKey)(id)(NSInteger)sn);
node = GSIMapNodeForKey(IreplyMap, (GSIMapKey)sn);
break;
}
else if (warned == NO && [start_date timeIntervalSinceNow] <= -300.0)
@ -3203,7 +3203,7 @@ static NSLock *cached_proxies_gate = nil;
else
{
rmc = node->value.obj;
GSIMapRemoveKey(IreplyMap, (GSIMapKey)(id)(NSInteger)sn);
GSIMapRemoveKey(IreplyMap, (GSIMapKey)sn);
}
M_UNLOCK(IrefGate); isLocked = NO;
TEST_RELEASE(start_date);
@ -3358,7 +3358,7 @@ static NSLock *cached_proxies_gate = nil;
*/
if (rep == YES)
{
GSIMapAddPair(IreplyMap, (GSIMapKey)(id)(NSInteger)sno, (GSIMapVal)dummyObject);
GSIMapAddPair(IreplyMap, (GSIMapKey)sno, (GSIMapVal)dummyObject);
}
/*
* Locate or create an rmc
@ -3510,14 +3510,14 @@ static NSLock *cached_proxies_gate = nil;
/*
* Record the value in the IlocalObjects map, retaining it.
*/
node = GSIMapNodeForKey(IlocalObjects, (GSIMapKey)(id)(NSInteger)object);
node = GSIMapNodeForKey(IlocalObjects, (GSIMapKey)object);
NSAssert(node == 0, NSInternalInconsistencyException);
node = GSIMapNodeForKey(IlocalTargets, (GSIMapKey)(id)(NSInteger)target);
node = GSIMapNodeForKey(IlocalTargets, (GSIMapKey)target);
NSAssert(node == 0, NSInternalInconsistencyException);
IF_NO_GC([anObj retain];)
GSIMapAddPair(IlocalObjects, (GSIMapKey)(id)(NSInteger)object, (GSIMapVal)((id)anObj));
GSIMapAddPair(IlocalTargets, (GSIMapKey)(id)(NSInteger)target, (GSIMapVal)((id)anObj));
GSIMapAddPair(IlocalObjects, (GSIMapKey)object, (GSIMapVal)((id)anObj));
GSIMapAddPair(IlocalTargets, (GSIMapKey)target, (GSIMapVal)((id)anObj));
if (debug_connection > 2)
NSLog(@"add local object (0x%x) target (0x%x) "
@ -3534,7 +3534,7 @@ static NSLock *cached_proxies_gate = nil;
/* Don't assert (IisValid); */
M_LOCK(IrefGate);
node = GSIMapNodeForKey(IlocalObjects, (GSIMapKey)(id)(NSInteger)object);
node = GSIMapNodeForKey(IlocalObjects, (GSIMapKey)object);
if (node == 0)
{
p = nil;
@ -3562,7 +3562,7 @@ static NSLock *cached_proxies_gate = nil;
M_LOCK(IrefGate);
anObj = prox->_object;
node = GSIMapNodeForKey(IlocalObjects, (GSIMapKey)(id)(NSInteger)anObj);
node = GSIMapNodeForKey(IlocalObjects, (GSIMapKey)anObj);
/*
* The NSDistantObject concerned may not belong to this connection,
@ -3605,13 +3605,13 @@ static NSLock *cached_proxies_gate = nil;
/*
* Remove the proxy from IlocalObjects and release it.
*/
GSIMapRemoveKey(IlocalObjects, (GSIMapKey)(id)(NSInteger)anObj);
GSIMapRemoveKey(IlocalObjects, (GSIMapKey)anObj);
RELEASE(prox);
/*
* Remove the target info too - no release required.
*/
GSIMapRemoveKey(IlocalTargets, (GSIMapKey)(id)(NSInteger)target);
GSIMapRemoveKey(IlocalTargets, (GSIMapKey)target);
if (debug_connection > 2)
NSLog(@"removed local object (0x%x) target (0x%x) "
@ -3669,7 +3669,7 @@ static NSLock *cached_proxies_gate = nil;
* Try a quick lookup to see if the target references a local object
* belonging to the receiver ... usually it should.
*/
node = GSIMapNodeForKey(IlocalTargets, (GSIMapKey)(id)(NSInteger)target);
node = GSIMapNodeForKey(IlocalTargets, (GSIMapKey)target);
if (node != 0)
{
proxy = node->value.obj;
@ -3720,7 +3720,7 @@ static NSLock *cached_proxies_gate = nil;
{
M_LOCK(GSIVar(c, _refGate));
node = GSIMapNodeForKey(GSIVar(c, _localTargets),
(GSIMapKey)(id)(NSInteger)target);
(GSIMapKey)target);
if (node != 0)
{
id local;
@ -3742,9 +3742,9 @@ static NSLock *cached_proxies_gate = nil;
proxy = [NSDistantObject proxyWithLocal: local
connection: self];
nTarget = proxy->_handle;
GSIMapRemoveKey(IlocalTargets, (GSIMapKey)(id)(NSInteger)nTarget);
GSIMapRemoveKey(IlocalTargets, (GSIMapKey)nTarget);
proxy->_handle = target;
GSIMapAddPair(IlocalTargets, (GSIMapKey)(id)(NSInteger)target,
GSIMapAddPair(IlocalTargets, (GSIMapKey)target,
(GSIMapVal)((id)proxy));
}
M_UNLOCK(GSIVar(c, _refGate));
@ -3778,7 +3778,7 @@ static NSLock *cached_proxies_gate = nil;
/* Don't assert (IisValid); */
M_LOCK(IrefGate);
node = GSIMapNodeForKey(IremoteProxies, (GSIMapKey)(id)(NSInteger)target);
node = GSIMapNodeForKey(IremoteProxies, (GSIMapKey)target);
if (node == 0)
{
found = nil;
@ -3839,7 +3839,7 @@ static NSLock *cached_proxies_gate = nil;
GSIMapNode node;
target = aProxy->_handle;
node = GSIMapNodeForKey(IremoteProxies, (GSIMapKey)(id)(NSInteger)target);
node = GSIMapNodeForKey(IremoteProxies, (GSIMapKey)target);
/*
* Only remove if the proxy for the target is the same as the
@ -3848,7 +3848,7 @@ static NSLock *cached_proxies_gate = nil;
if (node != 0 && node->value.obj == aProxy)
{
count = aProxy->_counter;
GSIMapRemoveKey(IremoteProxies, (GSIMapKey)(id)(NSInteger)target);
GSIMapRemoveKey(IremoteProxies, (GSIMapKey)target);
/*
* Tell the remote application that we have removed our proxy and
* it can release it's local object.
@ -3889,7 +3889,7 @@ static NSLock *cached_proxies_gate = nil;
NSParameterAssert(aProxy == nil || aTarget == aProxy->_handle);
M_LOCK(IrefGate);
node = GSIMapNodeForKey(IremoteProxies, (GSIMapKey)(id)(NSInteger)aTarget);
node = GSIMapNodeForKey(IremoteProxies, (GSIMapKey)aTarget);
if (node == 0)
{
p = nil;
@ -3902,7 +3902,7 @@ static NSLock *cached_proxies_gate = nil;
if (p == nil && aProxy != nil)
{
p = aProxy;
GSIMapAddPair(IremoteProxies, (GSIMapKey)(id)(NSInteger)aTarget, (GSIMapVal)((id)p));
GSIMapAddPair(IremoteProxies, (GSIMapKey)aTarget, (GSIMapVal)((id)p));
}
/*
* Whether this is a new proxy or an existing proxy, this method is
@ -3925,7 +3925,7 @@ static NSLock *cached_proxies_gate = nil;
/* Don't assert (IisValid); */
M_LOCK(IrefGate);
node = GSIMapNodeForKey(IlocalObjects, (GSIMapKey)(id)(NSInteger)anObj);
node = GSIMapNodeForKey(IlocalObjects, (GSIMapKey)anObj);
if (node == 0)
{
ret = nil;
@ -3945,7 +3945,7 @@ static NSLock *cached_proxies_gate = nil;
/* Don't assert (IisValid); */
M_LOCK(IrefGate);
node = GSIMapNodeForKey(IlocalTargets, (GSIMapKey)(id)(NSInteger)target);
node = GSIMapNodeForKey(IlocalTargets, (GSIMapKey)target);
if (node == 0)
{
ret = nil;

View file

@ -39,11 +39,11 @@
/*
* Setup for inline operation of pointer map tables.
*/
#define GSI_MAP_KTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_CLS | GSUNION_INT
#define GSI_MAP_VTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_INT
#define GSI_MAP_KTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_CLS | GSUNION_NSINT
#define GSI_MAP_VTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_NSINT
#define GSI_MAP_RETAIN_VAL(M, X)
#define GSI_MAP_RELEASE_VAL(M, X)
#define GSI_MAP_HASH(M, X) ((X).uint)
#define GSI_MAP_HASH(M, X) ((X).nsu)
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
#undef GSI_MAP_NOCLEAN
#if GS_WITH_GC
@ -258,7 +258,7 @@ static NSDictionary *makeReference(unsigned ref)
/*
* This object has already been conditionally encoded.
*/
ref = node->value.uint;
ref = node->value.nsu;
}
}
else
@ -296,7 +296,7 @@ static NSDictionary *makeReference(unsigned ref)
/*
* Conditionally encoded ... replace with actual value.
*/
ref = node->value.uint;
ref = node->value.nsu;
GSIMapAddPair(_uIdMap, (GSIMapKey)anObject, (GSIMapVal)ref);
GSIMapRemoveKey(_cIdMap, (GSIMapKey)anObject);
[_obj replaceObjectAtIndex: ref withObject: objectInfo];
@ -306,7 +306,7 @@ static NSDictionary *makeReference(unsigned ref)
}
else
{
ref = node->value.uint;
ref = node->value.nsu;
}
}
@ -409,7 +409,7 @@ static NSDictionary *makeReference(unsigned ref)
}
else
{
ref = node->value.uint;
ref = node->value.nsu;
}
/*

View file

@ -207,7 +207,7 @@ static void obsFree(Observation *o);
#define GSI_MAP_RETAIN_VAL(M, X)
#define GSI_MAP_RELEASE_VAL(M, X)
#define GSI_MAP_KTYPES GSUNION_OBJ|GSUNION_INT
#define GSI_MAP_KTYPES GSUNION_OBJ|GSUNION_NSINT
#define GSI_MAP_VTYPES GSUNION_PTR
#define GSI_MAP_VEXTRA Observation*
#define GSI_MAP_EXTRA void*

View file

@ -49,13 +49,13 @@
/*
* Setup for inline operation of pointer map tables.
*/
#define GSI_MAP_KTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_CLS | GSUNION_INT
#define GSI_MAP_VTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_CLS | GSUNION_INT
#define GSI_MAP_KTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_CLS | GSUNION_NSINT
#define GSI_MAP_VTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_CLS | GSUNION_NSINT
#define GSI_MAP_RETAIN_KEY(M, X)
#define GSI_MAP_RELEASE_KEY(M, X)
#define GSI_MAP_RETAIN_VAL(M, X)
#define GSI_MAP_RELEASE_VAL(M, X)
#define GSI_MAP_HASH(M, X) ((X).uint)
#define GSI_MAP_HASH(M, X) ((X).nsu)
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
#define GSI_MAP_NOCLEAN 1
@ -1298,7 +1298,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
return;
}
if (node == 0 || node->value.uint == 0)
if (node == 0 || node->value.nsu == 0)
{
Class cls;
id obj;
@ -1310,7 +1310,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
}
else
{
node->value.uint = ++_xRefO;
node->value.nsu = ++_xRefO;
}
obj = [anObject replacementObjectForPortCoder: self];
@ -1320,20 +1320,20 @@ static IMP _xRefImp; /* Serialize a crossref. */
* If the object we have been given is actually a class,
* we encode it as a special case.
*/
(*_xRefImp)(_dst, xRefSel, _GSC_CID, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_CID, node->value.nsu);
(*_eValImp)(self, eValSel, @encode(Class), &obj);
}
else
{
cls = [obj classForPortCoder];
(*_xRefImp)(_dst, xRefSel, _GSC_ID, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_ID, node->value.nsu);
(*_eValImp)(self, eValSel, @encode(Class), &cls);
[obj encodeWithCoder: self];
}
}
else
{
(*_xRefImp)(_dst, xRefSel, _GSC_ID | _GSC_XREF, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_ID | _GSC_XREF, node->value.nsu);
}
}
}
@ -1465,7 +1465,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
(*_eValImp)(self, eValSel, type, buf);
}
}
else if (node == 0 || node->value.uint == 0)
else if (node == 0 || node->value.nsu == 0)
{
/*
* Second pass, unwritten pointer - write it.
@ -1477,9 +1477,9 @@ static IMP _xRefImp; /* Serialize a crossref. */
}
else
{
node->value.uint = ++_xRefP;
node->value.nsu = ++_xRefP;
}
(*_xRefImp)(_dst, xRefSel, _GSC_PTR, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_PTR, node->value.nsu);
type++;
buf = *(char**)buf;
(*_eValImp)(self, eValSel, type, buf);
@ -1490,7 +1490,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
* Second pass, write a cross-reference number.
*/
(*_xRefImp)(_dst, xRefSel, _GSC_PTR|_GSC_XREF,
node->value.uint);
node->value.nsu);
}
}
return;
@ -1524,7 +1524,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
if (node != 0)
{
(*_xRefImp)(_dst, xRefSel, _GSC_CLASS | _GSC_XREF,
node->value.uint);
node->value.nsu);
return;
}
while (done == NO)
@ -1543,7 +1543,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
/*
* Encode tag and crossref number.
*/
(*_xRefImp)(_dst, xRefSel, _GSC_CLASS, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_CLASS, node->value.nsu);
/*
* Encode class, and version.
*/
@ -1590,7 +1590,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
{
node = GSIMapAddPair(_ptrMap,
(GSIMapKey)(void*)s, (GSIMapVal)++_xRefP);
(*_xRefImp)(_dst, xRefSel, _GSC_SEL, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_SEL, node->value.nsu);
/*
* Encode selector.
*/
@ -1599,7 +1599,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
else
{
(*_xRefImp)(_dst, xRefSel, _GSC_SEL|_GSC_XREF,
node->value.uint);
node->value.nsu);
}
}
return;
@ -1621,13 +1621,13 @@ static IMP _xRefImp; /* Serialize a crossref. */
{
node = GSIMapAddPair(_ptrMap,
(GSIMapKey)*(char**)buf, (GSIMapVal)++_xRefP);
(*_xRefImp)(_dst, xRefSel, _GSC_CHARPTR, node->value.uint);
(*_xRefImp)(_dst, xRefSel, _GSC_CHARPTR, node->value.nsu);
(*_eSerImp)(_dst, eSerSel, buf, type, nil);
}
else
{
(*_xRefImp)(_dst, xRefSel, _GSC_CHARPTR|_GSC_XREF,
node->value.uint);
node->value.nsu);
}
}
return;

View file

@ -54,7 +54,7 @@
* Setup for inline operation of string map tables.
*/
#define GSI_MAP_KTYPES GSUNION_OBJ
#define GSI_MAP_VTYPES GSUNION_INT
#define GSI_MAP_VTYPES GSUNION_NSINT
#define GSI_MAP_RETAIN_KEY(M, X)
#define GSI_MAP_RELEASE_KEY(M, X)
#define GSI_MAP_RETAIN_VAL(M, X)
@ -217,7 +217,7 @@ serializeToInfo(id object, _NSSerializerInfo* info)
else
{
(*info->appImp)(info->data, appSel, &st_xref, 1);
(*info->serImp)(info->data, serSel, node->value.uint);
(*info->serImp)(info->data, serSel, node->value.nsu);
}
}
else if (GSObjCIsKindOf(c, StringClass))
@ -261,7 +261,7 @@ serializeToInfo(id object, _NSSerializerInfo* info)
else
{
(*info->appImp)(info->data, appSel, &st_xref, 1);
(*info->serImp)(info->data, serSel, node->value.uint);
(*info->serImp)(info->data, serSel, node->value.nsu);
}
}
else if (GSObjCIsKindOf(c, ArrayClass))