Hi,
I think I have found a problem with the new native ARM64 calling convention on Mac when a function returns a structure with all doubles. Summarizing an excerpt of a larger code base here:
struct XYPair
{
double x;
double y;
};
class IDrawFont
{
};
enum TextExtentMode
{
kTextExtentNormal
};
static XYPair IDrawFont_GetTextSize(const IDrawFont& font,const std::string& text,TextExtentMode mode)
{
XYPair pair;
pair.x=200.0;
pair.y=12.5;
return pair;
}
// registering the struct and a function that returns the struct
r = engine->RegisterObjectType("XYCoordinates", sizeof(XYPair), asOBJ_VALUE| asOBJ_POD | asGetTypeTraits<XYPair>() | asOBJ_APP_CLASS_ALLFLOATS); assert( r >= 0 );
r = engine->RegisterObjectProperty("XYCoordinates", "double x", asOFFSET(XYPair, x)); assert( r >= 0 );
r = engine->RegisterObjectProperty("XYCoordinates", "double y", asOFFSET(XYPair, y)); assert( r >= 0 );
r = engine->RegisterObjectMethod("DrawFont", "XYCoordinates GetTextSize(const string& text,TextExtentMode mode)", asFUNCTIONPR(IDrawFont_GetTextSize, (const IDrawFont&,const std::string&,TextExtentMode), XYPair), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
Calling the GetTextSize() function returns a trashed structure where both values are zero or close to 0.
If I register the XYPair object type with the additional alignment directive (which seems to be necessary since it is all doubles?):
r = engine->RegisterObjectType("XYCoordinates", sizeof(XYPair), asOBJ_VALUE| asOBJ_POD | asGetTypeTraits<XYPair>() | asOBJ_APP_CLASS_ALLFLOATS | asOBJ_APP_CLASS_ALIGN8); assert( r >= 0 );
Then it crashes when called, in CallSystemFunctionNative in ascallfuncarm64.cpp on line 407
GETHFAReturnDouble(&retQW,&retQW2,structSize);
It seems that the retQW and retQW2 do not contain the expected data anyway. structSize looks fine.
Do you have an idea of what could be wrong here? My knowledge of ARM64 calling conventions is too limited to go further :-).