revert last change

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36877 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-07-12 09:05:50 +00:00
parent 791b709752
commit 5a42e36b4a

View file

@ -259,12 +259,8 @@ cifframe_arg_addr(cifframe_t *cframe, int index)
ffi_type * ffi_type *
cifframe_type(const char *typePtr, const char **advance) cifframe_type(const char *typePtr, const char **advance)
{ {
static ffi_type stypeNSPoint = { 0 };
static ffi_type stypeNSRange = { 0 };
static ffi_type stypeNSRect = { 0 };
static ffi_type stypeNSSize = { 0 };
const char *type; const char *type;
ffi_type *ftype = 0; ffi_type *ftype;
typePtr = objc_skip_type_qualifiers (typePtr); typePtr = objc_skip_type_qualifiers (typePtr);
type = typePtr; type = typePtr;
@ -357,9 +353,9 @@ cifframe_type(const char *typePtr, const char **advance)
if (GSSelectorTypesMatch(typePtr - 1, @encode(NSRange))) if (GSSelectorTypesMatch(typePtr - 1, @encode(NSRange)))
{ {
static ffi_type *elems[3]; static ffi_type *elems[3];
static ffi_type *ftype = &stypeNSRange; static ffi_type stype = { 0 };
if (ftype->type == 0) if (stype.type == 0)
{ {
const char *t = @encode(NSUInteger); const char *t = @encode(NSUInteger);
@ -379,41 +375,19 @@ cifframe_type(const char *typePtr, const char **advance)
} }
elems[1] = elems[0]; elems[1] = elems[0];
elems[2] = 0; elems[2] = 0;
ftype->elements = elems; stype.elements = elems;
ftype->type = FFI_TYPE_STRUCT; stype.type = FFI_TYPE_STRUCT;
}
typePtr = objc_skip_typespec (typePtr - 1);
break;
}
else if (GSSelectorTypesMatch(typePtr - 1, @encode(NSPoint)))
{
static ffi_type *elems[3];
static ffi_type *ftype = &stypeNSPoint;
if (ftype->type == 0)
{
if (*@encode(CGFloat) == _C_DBL)
{
elems[0] = &ffi_type_double;
}
else
{
elems[0] = &ffi_type_float;
}
elems[1] = elems[0];
elems[2] = 0;
ftype->elements = elems;
ftype->type = FFI_TYPE_STRUCT;
} }
ftype = &stype;
typePtr = objc_skip_typespec (typePtr - 1); typePtr = objc_skip_typespec (typePtr - 1);
break; break;
} }
else if (GSSelectorTypesMatch(typePtr - 1, @encode(NSSize))) else if (GSSelectorTypesMatch(typePtr - 1, @encode(NSSize)))
{ {
static ffi_type *elems[3]; static ffi_type *elems[3];
static ffi_type *ftype = &stypeNSSize; static ffi_type stype = { 0 };
if (ftype->type == 0) if (stype.type == 0)
{ {
if (*@encode(CGFloat) == _C_DBL) if (*@encode(CGFloat) == _C_DBL)
{ {
@ -425,28 +399,30 @@ cifframe_type(const char *typePtr, const char **advance)
} }
elems[1] = elems[0]; elems[1] = elems[0];
elems[2] = 0; elems[2] = 0;
ftype->elements = elems; stype.elements = elems;
ftype->type = FFI_TYPE_STRUCT; stype.type = FFI_TYPE_STRUCT;
} }
ftype = &stype;
typePtr = objc_skip_typespec (typePtr - 1); typePtr = objc_skip_typespec (typePtr - 1);
break; break;
} }
else if (GSSelectorTypesMatch(typePtr - 1, @encode(NSRect))) else if (GSSelectorTypesMatch(typePtr - 1, @encode(NSRect)))
{ {
static ffi_type *elems[3]; static ffi_type *elems[3];
static ffi_type *ftype = &stypeNSRect; static ffi_type stype = { 0 };
if (ftype->type == 0) if (stype.type == 0)
{ {
/* An NSRect is an NSPoint and an NSSize, but those /* An NSRect is an NSPoint and an NSSize, but those
* two structures are actually identical. * two structures are actually identical.
*/ */
elems[0] = cifframe_type(@encode(NSSize), NULL); elems[0] = cifframe_type(@encode(NSSize), NULL);
elems[1] = cifframe_type(@encode(NSPoint), NULL); elems[1] = elems[0];
elems[2] = 0; elems[2] = 0;
ftype->elements = elems; stype.elements = elems;
ftype->type = FFI_TYPE_STRUCT; stype.type = FFI_TYPE_STRUCT;
} }
ftype = &stype;
typePtr = objc_skip_typespec (typePtr - 1); typePtr = objc_skip_typespec (typePtr - 1);
break; break;
} }
@ -521,14 +497,8 @@ cifframe_type(const char *typePtr, const char **advance)
NSCAssert(typePtr, @"End of signature while parsing"); NSCAssert(typePtr, @"End of signature while parsing");
if (align > max_align) if (align > max_align)
{ {
if (ftype && ftype->type == FFI_TYPE_STRUCT if (ftype && ftype->type == FFI_TYPE_STRUCT)
&& ftype != &stypeNSPoint free(ftype);
&& ftype != &stypeNSRange
&& ftype != &stypeNSRect
&& ftype != &stypeNSSize)
{
free(ftype);
}
ftype = local; ftype = local;
max_align = align; max_align = align;
} }