mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fix portability of [un]signed char encodings
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9921 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ee7eb89ab9
commit
ab97cd08af
9 changed files with 41 additions and 13 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2001-05-11 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/NSArchiver.m ([NSArchiver -encodeValueOfObjCType:at:]): Use
|
||||
signed char to encode _C_CHR.
|
||||
* Source/NSPortCoder.m ([NSPortCoder -decodeValueOfObjCType:at:]):
|
||||
Be lenient about decoding [un]signed chars.
|
||||
* Source/NSUnarchiver.m: Likewise.
|
||||
* Source/GSTemplateValue.m (-encodeWithCoder:): Use signed char to
|
||||
encode/decode type info.
|
||||
* Source/GSValue.m: Likewise.
|
||||
* Source/NSConcreteNumber.m: Likewise.
|
||||
* Source/NSNumber.m: Likewise.
|
||||
* Source/NSValue.m: Likewise.
|
||||
|
||||
2001-05-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSConnection.m: Use respondsToSelector rather than respondsTo
|
||||
|
|
|
@ -255,7 +255,7 @@
|
|||
const char *objctype = @encode(TYPE_NAME);
|
||||
unsigned size = strlen(objctype)+1;
|
||||
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||
[coder encodeArrayOfObjCType: @encode(char) count: size at: objctype];
|
||||
[coder encodeArrayOfObjCType: @encode(signed char) count: size at: objctype];
|
||||
[coder encodeValueOfObjCType: @encode(TYPE_NAME) at: &data];
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ typeSize(const char* type)
|
|||
|
||||
size = strlen(objctype)+1;
|
||||
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||
[coder encodeArrayOfObjCType: @encode(char) count: size at: objctype];
|
||||
[coder encodeArrayOfObjCType: @encode(signed char) count: size at: objctype];
|
||||
size = (unsigned)typeSize(objctype);
|
||||
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||
[coder encodeArrayOfObjCType: @encode(unsigned char) count: size at: data];
|
||||
|
@ -260,7 +260,7 @@ typeSize(const char* type)
|
|||
|
||||
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||
objctype = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
||||
[coder decodeArrayOfObjCType: @encode(char) count: size at: objctype];
|
||||
[coder decodeArrayOfObjCType: @encode(signed char) count: size at: objctype];
|
||||
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||
data = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
||||
[coder decodeArrayOfObjCType: @encode(unsigned char) count: size at: data];
|
||||
|
|
|
@ -518,7 +518,7 @@ static Class NSMutableDataMallocClass;
|
|||
|
||||
case _C_CHR:
|
||||
(*_tagImp)(_dst, tagSel, _GSC_CHR);
|
||||
(*_serImp)(_dst, serSel, (void*)buf, @encode(char), nil);
|
||||
(*_serImp)(_dst, serSel, (void*)buf, @encode(signed char), nil);
|
||||
return;
|
||||
|
||||
case _C_UCHR:
|
||||
|
|
|
@ -447,7 +447,7 @@
|
|||
{
|
||||
const char *t = @encode(TYPE_TYPE);
|
||||
|
||||
[coder encodeValueOfObjCType: @encode(char) at: t];
|
||||
[coder encodeValueOfObjCType: @encode(signed char) at: t];
|
||||
[coder encodeValueOfObjCType: t at: &data];
|
||||
}
|
||||
|
||||
|
|
|
@ -2274,7 +2274,7 @@ static Class doubleNumberClass;
|
|||
{
|
||||
const char *t = [self objCType];
|
||||
|
||||
[coder encodeValueOfObjCType: @encode(char) at: t];
|
||||
[coder encodeValueOfObjCType: @encode(signed char) at: t];
|
||||
[coder encodeValueOfObjCType: t at: [self pointerValue]];
|
||||
}
|
||||
|
||||
|
@ -2296,7 +2296,7 @@ static Class doubleNumberClass;
|
|||
double d;
|
||||
} data;
|
||||
|
||||
[coder decodeValueOfObjCType: @encode(char) at: t];
|
||||
[coder decodeValueOfObjCType: @encode(signed char) at: t];
|
||||
t[1] = '\0';
|
||||
[coder decodeValueOfObjCType: t at: &data];
|
||||
switch (*t)
|
||||
|
|
|
@ -835,7 +835,14 @@ static IMP _xRefImp; /* Serialize a crossref. */
|
|||
|
||||
case _GSC_CHR:
|
||||
case _GSC_UCHR:
|
||||
typeCheck(*type, info & _GSC_MASK);
|
||||
/* Encoding of chars is not consistant across platforms, so we
|
||||
loosen the type checking a little */
|
||||
if (*type != type_map[_GSC_CHR] && *type != type_map[_GSC_UCHR])
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"expected %s and got %s",
|
||||
typeToName1(*type), typeToName2(info)];
|
||||
}
|
||||
(*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil);
|
||||
return;
|
||||
|
||||
|
@ -1559,7 +1566,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
|
|||
|
||||
case _C_CHR:
|
||||
(*_eTagImp)(_dst, eTagSel, _GSC_CHR);
|
||||
(*_eSerImp)(_dst, eSerSel, (void*)buf, @encode(char), nil);
|
||||
(*_eSerImp)(_dst, eSerSel, (void*)buf, @encode(signed char), nil);
|
||||
return;
|
||||
|
||||
case _C_UCHR:
|
||||
|
|
|
@ -795,7 +795,14 @@ static Class NSDataMallocClass;
|
|||
|
||||
case _GSC_CHR:
|
||||
case _GSC_UCHR:
|
||||
typeCheck(*type, info & _GSC_MASK);
|
||||
/* Encoding of chars is not consistant across platforms, so we
|
||||
loosen the type checking a little */
|
||||
if (*type != type_map[_GSC_CHR] && *type != type_map[_GSC_UCHR])
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"expected %s and got %s",
|
||||
typeToName1(*type), typeToName2(info)];
|
||||
}
|
||||
(*desImp)(src, desSel, address, type, &cursor, nil);
|
||||
return;
|
||||
|
||||
|
|
|
@ -366,7 +366,7 @@ static NSLock *placeholderLock;
|
|||
|
||||
size = strlen(objctype)+1;
|
||||
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||
[coder encodeArrayOfObjCType: @encode(char) count: size at: objctype];
|
||||
[coder encodeArrayOfObjCType: @encode(signed char) count: size at: objctype];
|
||||
size = objc_sizeof_type(objctype);
|
||||
data = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
||||
[self getValue: (void*)data];
|
||||
|
@ -384,7 +384,7 @@ static NSLock *placeholderLock;
|
|||
|
||||
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||
objctype = (void*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
||||
[coder decodeArrayOfObjCType: @encode(char) count: size at: (void*)objctype];
|
||||
[coder decodeArrayOfObjCType: @encode(signed char) count: size at: (void*)objctype];
|
||||
c = [abstractClass valueClassWithObjCType: objctype];
|
||||
o = [c alloc];
|
||||
/*
|
||||
|
@ -445,7 +445,7 @@ static NSLock *placeholderLock;
|
|||
|
||||
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||
objctype = (void*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
||||
[coder decodeArrayOfObjCType: @encode(char) count: size at: (void*)objctype];
|
||||
[coder decodeArrayOfObjCType: @encode(signed char) count: size at: (void*)objctype];
|
||||
c = [abstractClass valueClassWithObjCType: objctype];
|
||||
o = [c alloc];
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue