mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Additions ot last change
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40209 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f5b4336181
commit
07e0609e42
1 changed files with 167 additions and 86 deletions
|
@ -603,15 +603,6 @@ scalarSize(char type)
|
|||
{
|
||||
unsigned xref;
|
||||
unsigned char info;
|
||||
#if GS_HAVE_I128
|
||||
gsu128 bigval;
|
||||
#else
|
||||
#if GS_HAVE_I64
|
||||
uint64_t bigval;
|
||||
#else
|
||||
uint32_t bigval;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
(*_dTagImp)(_src, dTagSel, &info, &xref, &_cursor);
|
||||
|
||||
|
@ -1065,100 +1056,190 @@ scalarSize(char type)
|
|||
* whose natural size on this system is not the same as on the
|
||||
* machine on which the archive was created.
|
||||
*/
|
||||
{
|
||||
uint8_t size;
|
||||
|
||||
/*
|
||||
* We fall through to here only when we have to decode a value
|
||||
* whose natural size on this system is not the same as on the
|
||||
* machine on which the archive was created.
|
||||
*/
|
||||
|
||||
switch (*type)
|
||||
{
|
||||
case _C_SHT:
|
||||
case _C_USHT: size = sizeof(short); break;
|
||||
case _C_INT:
|
||||
case _C_UINT: size = sizeof(int); break;
|
||||
case _C_LNG:
|
||||
case _C_ULNG: size = sizeof(long); break;
|
||||
case _C_LNG_LNG:
|
||||
case _C_ULNG_LNG: size = sizeof(long long); break;
|
||||
default: size = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* First, we read the data and convert it to the largest size
|
||||
* this system can support.
|
||||
*/
|
||||
switch (info & _GSC_SIZE)
|
||||
if (*type == _C_SHT
|
||||
|| *type == _C_INT
|
||||
|| *type == _C_LNG
|
||||
|| *type == _C_LNG_LNG)
|
||||
{
|
||||
case _GSC_I16: /* Encoded as 16-bit */
|
||||
{
|
||||
uint16_t val;
|
||||
int64_t big;
|
||||
|
||||
(*_dDesImp)(_src, dDesSel, &val, @encode(uint16_t), &_cursor, nil);
|
||||
bigval = val;
|
||||
break;
|
||||
}
|
||||
switch (info & _GSC_SIZE)
|
||||
{
|
||||
case _GSC_I16: /* Encoded as 16-bit */
|
||||
{
|
||||
int16_t val;
|
||||
|
||||
case _GSC_I32: /* Encoded as 32-bit */
|
||||
{
|
||||
uint32_t val;
|
||||
(*_dDesImp)(_src, dDesSel, &val, @encode(int16_t), &_cursor, nil);
|
||||
big = val;
|
||||
break;
|
||||
}
|
||||
|
||||
(*_dDesImp)(_src, dDesSel, &val, @encode(uint32_t), &_cursor, nil);
|
||||
bigval = val;
|
||||
break;
|
||||
}
|
||||
case _GSC_I32: /* Encoded as 32-bit */
|
||||
{
|
||||
int32_t val;
|
||||
|
||||
case _GSC_I64: /* Encoded as 64-bit */
|
||||
{
|
||||
uint64_t val;
|
||||
(*_dDesImp)(_src, dDesSel, &val, @encode(int32_t), &_cursor, nil);
|
||||
big = val;
|
||||
break;
|
||||
}
|
||||
|
||||
(*_dDesImp)(_src, dDesSel, &val, @encode(uint64_t), &_cursor, nil);
|
||||
#if GS_HAVE_I64
|
||||
bigval = val;
|
||||
#else
|
||||
bigval = GSSwapBigI64ToHost(val);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case _GSC_I64: /* Encoded as 64-bit */
|
||||
{
|
||||
(*_dDesImp)(_src, dDesSel, &big, @encode(int64_t), &_cursor, nil);
|
||||
break;
|
||||
}
|
||||
|
||||
default: /* A 128-bit value */
|
||||
{
|
||||
gsu128 val;
|
||||
|
||||
(*_dDesImp)(_src, dDesSel, &val, @encode(gsu128), &_cursor, nil);
|
||||
#if GS_HAVE_I128
|
||||
bigval = val;
|
||||
#else
|
||||
val = GSSwapBigI128ToHost(val);
|
||||
#if GS_HAVE_I64
|
||||
bigval = *(uint64_t*)(void*)&val;
|
||||
#else
|
||||
bigval = *(uint32_t*)&val;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default: /* A 128-bit value */
|
||||
{
|
||||
big = 0;
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Archiving of 128bit integer not allowed"];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Now we copy from the big value to the destination location.
|
||||
*/
|
||||
switch (size)
|
||||
{
|
||||
case 1:
|
||||
*(int8_t*)address = (int8_t)big;
|
||||
if (big & ~0xff)
|
||||
{
|
||||
if ((int8_t)big >= 0 || (big & ~0xff) != ~0xff)
|
||||
{
|
||||
NSLog(@"Loss of information converting decoded value to int8_t");
|
||||
}
|
||||
}
|
||||
return;
|
||||
case 2:
|
||||
*(int16_t*)address = (int16_t)big;
|
||||
if (big & ~0xffff)
|
||||
{
|
||||
if ((int16_t)big >= 0 || (big & ~0xffff) != ~0xffff)
|
||||
{
|
||||
NSLog(@"Loss of information converting decoded value to int16_t");
|
||||
}
|
||||
}
|
||||
return;
|
||||
case 4:
|
||||
*(int32_t*)address = (int32_t)big;
|
||||
if (big & ~0xffffffff)
|
||||
{
|
||||
if ((int32_t)big >= 0 || (big & ~0xffffffff) != ~0xffffffff)
|
||||
{
|
||||
NSLog(@"Loss of information converting decoded value to int32_t");
|
||||
}
|
||||
}
|
||||
return;
|
||||
case 8:
|
||||
*(int64_t*)address = big;
|
||||
return;
|
||||
default:
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"type/size information error"];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now we copy from the 'bigval' to the destination location.
|
||||
*/
|
||||
switch (info & _GSC_MASK)
|
||||
else
|
||||
{
|
||||
case _GSC_SHT:
|
||||
*(short*)address = (short)bigval;
|
||||
return;
|
||||
case _GSC_USHT:
|
||||
*(unsigned short*)address = (unsigned short)bigval;
|
||||
return;
|
||||
case _GSC_INT:
|
||||
*(int*)address = (int)bigval;
|
||||
return;
|
||||
case _GSC_UINT:
|
||||
*(unsigned int*)address = (unsigned int)bigval;
|
||||
return;
|
||||
case _GSC_LNG:
|
||||
*(long*)address = (long)bigval;
|
||||
return;
|
||||
case _GSC_ULNG:
|
||||
*(unsigned long*)address = (unsigned long)bigval;
|
||||
return;
|
||||
#ifdef _C_LNG_LNG
|
||||
case _GSC_LNG_LNG:
|
||||
*(long long*)address = (long long)bigval;
|
||||
return;
|
||||
case _GSC_ULNG_LNG:
|
||||
*(unsigned long long*)address = (unsigned long long)bigval;
|
||||
return;
|
||||
#endif
|
||||
default:
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"type/size information error"];
|
||||
uint64_t big;
|
||||
|
||||
switch (info & _GSC_SIZE)
|
||||
{
|
||||
case _GSC_I16: /* Encoded as 16-bit */
|
||||
{
|
||||
uint16_t val;
|
||||
|
||||
(*_dDesImp)(_src, dDesSel, &val, @encode(uint16_t), &_cursor, nil);
|
||||
big = val;
|
||||
break;
|
||||
}
|
||||
|
||||
case _GSC_I32: /* Encoded as 32-bit */
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
(*_dDesImp)(_src, dDesSel, &val, @encode(uint32_t), &_cursor, nil);
|
||||
big = val;
|
||||
break;
|
||||
}
|
||||
|
||||
case _GSC_I64: /* Encoded as 64-bit */
|
||||
{
|
||||
(*_dDesImp)(_src, dDesSel, &big, @encode(uint64_t), &_cursor, nil);
|
||||
break;
|
||||
}
|
||||
|
||||
default: /* A 128-bit value */
|
||||
{
|
||||
big = 0;
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Archiving of 128bit integer not allowed"];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Now we copy from the big value to the destination location.
|
||||
*/
|
||||
switch (size)
|
||||
{
|
||||
case 1:
|
||||
if (big & ~0xff)
|
||||
{
|
||||
NSLog(@"Loss of information converting decoded value to uint8_t");
|
||||
}
|
||||
*(uint8_t*)address = (uint8_t)big;
|
||||
return;
|
||||
case 2:
|
||||
if (big & ~0xffff)
|
||||
{
|
||||
NSLog(@"Loss of information converting decoded value to uint16_t");
|
||||
}
|
||||
*(uint16_t*)address = (uint16_t)big;
|
||||
return;
|
||||
case 4:
|
||||
if (big & ~0xffffffff)
|
||||
{
|
||||
NSLog(@"Loss of information converting decoded value to uint32_t");
|
||||
}
|
||||
*(uint32_t*)address = (uint32_t)big;
|
||||
return;
|
||||
case 8:
|
||||
*(uint64_t*)address = big;
|
||||
return;
|
||||
default:
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"type/size information error"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void) dispatch
|
||||
{
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue