Structure coding fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16420 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2003-04-10 17:35:11 +00:00
parent 798ab2339e
commit 304550f4e2
2 changed files with 19 additions and 40 deletions

View file

@ -8,6 +8,7 @@
* Source/GSFFCallInvocation.m: minor tidy up. * Source/GSFFCallInvocation.m: minor tidy up.
* Source/NSArchiver.m: Structure encoding/decoding fixes. * Source/NSArchiver.m: Structure encoding/decoding fixes.
* Source/NSData.m: Structure encoding/decoding fixes. * Source/NSData.m: Structure encoding/decoding fixes.
* Source/NSPortCoder.m: Structure encoding/decoding fixes.
* Source/NSUnarchiver.m: Structure encoding/decoding fixes. * Source/NSUnarchiver.m: Structure encoding/decoding fixes.
2003-04-09 Richard Frith-Macdonald <rfm@gnu.org> 2003-04-09 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -736,29 +736,19 @@ static IMP _xRefImp; /* Serialize a crossref. */
case _GSC_STRUCT_B: case _GSC_STRUCT_B:
{ {
int offset = 0; struct objc_struct_layout layout;
typeCheck(*type, _GSC_STRUCT_B); typeCheck(*type, _GSC_STRUCT_B);
while (*type != _C_STRUCT_E && *type++ != '='); /* skip "<name>=" */ objc_layout_structure (type, &layout);
for (;;) while (objc_layout_structure_next_member (&layout))
{ {
(*_dValImp)(self, dValSel, type, (char*)address + offset); int offset;
offset += objc_sizeof_type(type); int align;
type = objc_skip_typespec(type); const char *ftype;
if (*type == _C_STRUCT_E)
{
break;
}
else
{
int align = objc_alignof_type(type);
int rem = offset % align;
if (rem != 0) objc_layout_structure_get_info (&layout, &offset, &align, &ftype);
{
offset += align - rem; (*_dValImp)(self, dValSel, ftype, (char*)address + offset);
}
}
} }
return; return;
} }
@ -1344,34 +1334,22 @@ static IMP _xRefImp; /* Serialize a crossref. */
case _C_STRUCT_B: case _C_STRUCT_B:
{ {
int offset = 0; struct objc_struct_layout layout;
if (_initialPass == NO) if (_initialPass == NO)
{ {
(*_eTagImp)(_dst, eTagSel, _GSC_STRUCT_B); (*_eTagImp)(_dst, eTagSel, _GSC_STRUCT_B);
} }
objc_layout_structure (type, &layout);
while (*type != _C_STRUCT_E && *type++ != '='); /* skip "<name>=" */ while (objc_layout_structure_next_member (&layout))
for (;;)
{ {
(*_eValImp)(self, eValSel, type, (char*)buf + offset); int offset;
offset += objc_sizeof_type(type); int align;
type = objc_skip_typespec(type); const char *ftype;
if (*type == _C_STRUCT_E)
{
break;
}
else
{
int align = objc_alignof_type(type);
int rem = offset % align;
if (rem != 0) objc_layout_structure_get_info (&layout, &offset, &align, &ftype);
{
offset += align - rem; (*_eValImp)(self, eValSel, ftype, (char*)buf + offset);
}
}
} }
} }
return; return;