Encoding/decoding fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16417 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2003-04-10 16:26:09 +00:00
parent 898deae09b
commit 794ed2711b
4 changed files with 62 additions and 109 deletions

View file

@ -426,7 +426,7 @@ static IMP gs_objc_msg_forward (SEL sel)
forwarding_callback forwarding_callback
= alloc_callback (&GSInvocationCallback, ret_info); = alloc_callback (&GSInvocationCallback, ret_info);
GSIMapAddPairNoRetain (&ff_callback_map, GSIMapAddPairNoRetain (&ff_callback_map,
(GSIMapKey) (void *) ret_info, (GSIMapKey) (void *) ret_info,
(GSIMapVal) forwarding_callback); (GSIMapVal) forwarding_callback);
@ -450,7 +450,7 @@ static IMP gs_objc_msg_forward (SEL sel)
&returnTypeInfo [index]); &returnTypeInfo [index]);
} }
GSIMapInitWithZoneAndCapacity (&ff_callback_map, 0, 9); GSIMapInitWithZoneAndCapacity (&ff_callback_map, NSDefaultMallocZone(), 9);
__objc_msg_forward = gs_objc_msg_forward; __objc_msg_forward = gs_objc_msg_forward;
} }

View file

@ -292,34 +292,22 @@ static Class NSMutableDataMallocClass;
case _C_STRUCT_B: case _C_STRUCT_B:
{ {
int offset = 0; struct objc_struct_layout layout;
if (_initialPass == NO) if (_initialPass == NO)
{ {
(*_tagImp)(_dst, tagSel, _GSC_STRUCT_B); (*_tagImp)(_dst, tagSel, _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;

View file

@ -1185,28 +1185,21 @@ failure:
} }
case _C_STRUCT_B: case _C_STRUCT_B:
{ {
int offset = 0; struct objc_struct_layout layout;
while (*type != _C_STRUCT_E && *type++ != '='); /* skip "<name>=" */ objc_layout_structure (type, &layout);
for (;;) while (objc_layout_structure_next_member (&layout))
{ {
int offset;
int align;
const char *ftype;
objc_layout_structure_get_info (&layout, &offset, &align, &ftype);
[self deserializeDataAt: ((char*)data) + offset [self deserializeDataAt: ((char*)data) + offset
ofObjCType: type ofObjCType: ftype
atCursor: cursor atCursor: cursor
context: callback]; context: callback];
offset += objc_sizeof_type(type);
type = objc_skip_typespec(type);
if (*type != _C_STRUCT_E)
{
int align = objc_alignof_type(type);
int rem = offset % align;
if (rem != 0)
{
offset += align - rem;
}
}
else break;
} }
return; return;
} }
@ -1968,25 +1961,21 @@ failure:
} }
case _C_STRUCT_B: case _C_STRUCT_B:
{ {
int offset = 0; struct objc_struct_layout layout;
int align, rem;
while (*type != _C_STRUCT_E && *type++ != '='); /* skip "<name>=" */ objc_layout_structure (type, &layout);
for (;;) while (objc_layout_structure_next_member (&layout))
{ {
int offset;
int align;
const char *ftype;
objc_layout_structure_get_info (&layout, &offset, &align, &ftype);
[self serializeDataAt: ((char*)data) + offset [self serializeDataAt: ((char*)data) + offset
ofObjCType: type ofObjCType: ftype
context: callback]; context: callback];
offset += objc_sizeof_type(type); }
type = objc_skip_typespec(type);
if (*type != _C_STRUCT_E)
{
align = objc_alignof_type(type);
if ((rem = offset % align))
offset += align - rem;
}
else break;
}
return; return;
} }
case _C_PTR: case _C_PTR:
@ -2394,28 +2383,21 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
} }
case _C_STRUCT_B: case _C_STRUCT_B:
{ {
int offset = 0; struct objc_struct_layout layout;
while (*type != _C_STRUCT_E && *type++ != '='); /* skip "<name>=" */ objc_layout_structure (type, &layout);
for (;;) while (objc_layout_structure_next_member (&layout))
{ {
int offset;
int align;
const char *ftype;
objc_layout_structure_get_info (&layout, &offset, &align, &ftype);
[self deserializeDataAt: ((char*)data) + offset [self deserializeDataAt: ((char*)data) + offset
ofObjCType: type ofObjCType: ftype
atCursor: cursor atCursor: cursor
context: callback]; context: callback];
offset += objc_sizeof_type(type);
type = objc_skip_typespec(type);
if (*type != _C_STRUCT_E)
{
int align = objc_alignof_type(type);
int rem = offset % align;
if (rem != 0)
{
offset += align - rem;
}
}
else break;
} }
return; return;
} }
@ -3188,27 +3170,20 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
} }
case _C_STRUCT_B: case _C_STRUCT_B:
{ {
int offset = 0; struct objc_struct_layout layout;
while (*type != _C_STRUCT_E && *type++ != '='); /* skip "<name>=" */ objc_layout_structure (type, &layout);
for (;;) while (objc_layout_structure_next_member (&layout))
{ {
[self serializeDataAt: ((char*)data) + offset int offset;
ofObjCType: type int align;
context: callback]; const char *ftype;
offset += objc_sizeof_type(type);
type = objc_skip_typespec(type);
if (*type != _C_STRUCT_E)
{
unsigned align = objc_alignof_type(type);
unsigned rem = offset % align;
if (rem != 0) objc_layout_structure_get_info (&layout, &offset, &align, &ftype);
{
offset += align - rem; [self serializeDataAt: ((char*)data) + offset
} ofObjCType: ftype
} context: callback];
else break;
} }
return; return;
} }

View file

@ -746,29 +746,19 @@ static Class NSDataMallocClass;
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;
} }