mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-05 22:20:59 +00:00
add support to encode/decode larger arrays
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34823 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
20b792c173
commit
3939e3928f
4 changed files with 27 additions and 20 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2012-02-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSArchiver.m:
|
||||||
|
* Source/NSUnarchiver.m:
|
||||||
|
Alter to support encoding and decoding arrays with NSUInteger counts
|
||||||
|
(ie more than 2^32 objects if on a 64bit system).
|
||||||
|
|
||||||
2012-02-26 Eric Wasylishen <ewasylishen@gmail.com>
|
2012-02-26 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Source/NSData.m: Various 64-bit compatibility fixes, mostly changing
|
* Source/NSData.m: Various 64-bit compatibility fixes, mostly changing
|
||||||
|
|
|
@ -254,9 +254,9 @@ static Class NSMutableDataMallocClass;
|
||||||
count: (NSUInteger)count
|
count: (NSUInteger)count
|
||||||
at: (const void*)buf
|
at: (const void*)buf
|
||||||
{
|
{
|
||||||
unsigned c = count;
|
NSUInteger c = count;
|
||||||
unsigned i;
|
NSUInteger i;
|
||||||
unsigned offset = 0;
|
NSUInteger offset = 0;
|
||||||
unsigned size = objc_sizeof_type(type);
|
unsigned size = objc_sizeof_type(type);
|
||||||
uchar info;
|
uchar info;
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ static Class NSMutableDataMallocClass;
|
||||||
if (_initialPass == NO)
|
if (_initialPass == NO)
|
||||||
{
|
{
|
||||||
(*_tagImp)(_dst, tagSel, _GSC_ARY_B);
|
(*_tagImp)(_dst, tagSel, _GSC_ARY_B);
|
||||||
(*_serImp)(_dst, serSel, &c, @encode(unsigned), nil);
|
(*_serImp)(_dst, serSel, &c, @encode(NSUInteger), nil);
|
||||||
}
|
}
|
||||||
for (i = 0; i < c; i++)
|
for (i = 0; i < c; i++)
|
||||||
{
|
{
|
||||||
|
@ -298,7 +298,7 @@ static Class NSMutableDataMallocClass;
|
||||||
else if (_initialPass == NO)
|
else if (_initialPass == NO)
|
||||||
{
|
{
|
||||||
(*_tagImp)(_dst, tagSel, _GSC_ARY_B);
|
(*_tagImp)(_dst, tagSel, _GSC_ARY_B);
|
||||||
(*_serImp)(_dst, serSel, &c, @encode(unsigned), nil);
|
(*_serImp)(_dst, serSel, &c, @encode(NSUInteger), nil);
|
||||||
|
|
||||||
(*_tagImp)(_dst, tagSel, info);
|
(*_tagImp)(_dst, tagSel, info);
|
||||||
for (i = 0; i < c; i++)
|
for (i = 0; i < c; i++)
|
||||||
|
@ -320,7 +320,7 @@ static Class NSMutableDataMallocClass;
|
||||||
|
|
||||||
case _C_ARY_B:
|
case _C_ARY_B:
|
||||||
{
|
{
|
||||||
unsigned count = atoi(++type);
|
NSUInteger count = atoll(++type);
|
||||||
|
|
||||||
while (isdigit(*type))
|
while (isdigit(*type))
|
||||||
{
|
{
|
||||||
|
@ -734,9 +734,9 @@ static Class NSMutableDataMallocClass;
|
||||||
|
|
||||||
- (void) encodeDataObject: (NSData*)anObject
|
- (void) encodeDataObject: (NSData*)anObject
|
||||||
{
|
{
|
||||||
unsigned l = [anObject length];
|
NSUInteger l = [anObject length];
|
||||||
|
|
||||||
(*_eValImp)(self, eValSel, @encode(unsigned int), &l);
|
(*_eValImp)(self, eValSel, @encode(NSUInteger), &l);
|
||||||
if (l)
|
if (l)
|
||||||
{
|
{
|
||||||
const void *b = [anObject bytes];
|
const void *b = [anObject bytes];
|
||||||
|
|
|
@ -1870,7 +1870,7 @@ failure:
|
||||||
|
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
NSUInteger length = [self length];
|
unsigned length = [self length];
|
||||||
void *bytes = [self mutableBytes];
|
void *bytes = [self mutableBytes];
|
||||||
|
|
||||||
if ([aCoder allowsKeyedCoding])
|
if ([aCoder allowsKeyedCoding])
|
||||||
|
@ -1881,7 +1881,7 @@ failure:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[aCoder encodeValueOfObjCType: @encode(NSUInteger)
|
[aCoder encodeValueOfObjCType: @encode(unsigned)
|
||||||
at: &length];
|
at: &length];
|
||||||
if (length)
|
if (length)
|
||||||
{
|
{
|
||||||
|
@ -1917,9 +1917,9 @@ failure:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSUInteger l;
|
unsigned l;
|
||||||
|
|
||||||
[aCoder decodeValueOfObjCType: @encode(NSUInteger) at: &l];
|
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &l];
|
||||||
if (l)
|
if (l)
|
||||||
{
|
{
|
||||||
void *b;
|
void *b;
|
||||||
|
|
|
@ -529,14 +529,14 @@ static Class NSDataMallocClass;
|
||||||
count: (NSUInteger)expected
|
count: (NSUInteger)expected
|
||||||
at: (void*)buf
|
at: (void*)buf
|
||||||
{
|
{
|
||||||
unsigned int i;
|
NSUInteger i;
|
||||||
int offset = 0;
|
NSUInteger offset = 0;
|
||||||
unsigned int size = (unsigned int)objc_sizeof_type(type);
|
NSUInteger size = (unsigned int)objc_sizeof_type(type);
|
||||||
unsigned char info;
|
unsigned char info;
|
||||||
unsigned count;
|
NSUInteger count;
|
||||||
|
|
||||||
(*tagImp)(src, tagSel, &info, 0, &cursor);
|
(*tagImp)(src, tagSel, &info, 0, &cursor);
|
||||||
(*desImp)(src, desSel, &count, @encode(unsigned), &cursor, nil);
|
(*desImp)(src, desSel, &count, @encode(NSUInteger), &cursor, nil);
|
||||||
if (info != _GSC_ARY_B)
|
if (info != _GSC_ARY_B)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
@ -545,7 +545,7 @@ static Class NSDataMallocClass;
|
||||||
if (count != expected)
|
if (count != expected)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"expected array count %u and got %u",
|
format: @"expected array count %"PRIuPTR" and got %"PRIuPTR,
|
||||||
expected, count];
|
expected, count];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1219,9 +1219,9 @@ static Class NSDataMallocClass;
|
||||||
|
|
||||||
- (NSData*) decodeDataObject
|
- (NSData*) decodeDataObject
|
||||||
{
|
{
|
||||||
unsigned l;
|
NSUInteger l;
|
||||||
|
|
||||||
(*dValImp)(self, dValSel, @encode(unsigned int), &l);
|
(*dValImp)(self, dValSel, @encode(NSUInteger), &l);
|
||||||
if (l)
|
if (l)
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
|
Loading…
Reference in a new issue