Update to Angelscript 2.35.1

This commit is contained in:
2022-04-02 15:12:50 +02:00
parent badd37a7d3
commit 6734aa44ec
33 changed files with 650 additions and 316 deletions

View File

@@ -72,45 +72,27 @@ double fraction(double v)
}
#endif
template<typename T, typename F>
struct alias_cast_t
{
union
{
F raw;
T data;
};
};
// As AngelScript doesn't allow bitwise manipulation of float types we'll provide a couple of
// functions for converting float values to IEEE 754 formatted values etc. This also allow us to
// provide a platform agnostic representation to the script so the scripts don't have to worry
// about whether the CPU uses IEEE 754 floats or some other representation
float fpFromIEEE(asUINT raw)
{
// TODO: Identify CPU family to provide proper conversion
// if the CPU doesn't natively use IEEE style floats
alias_cast_t<asUINT, float> t;
t.raw = raw;
return t.data;
// TODO: Identify CPU family to provide proper conversion
// if the CPU doesn't natively use IEEE style floats
return *reinterpret_cast<float*>(&raw);
}
asUINT fpToIEEE(float fp)
{
alias_cast_t<float, asUINT> t;
t.raw = fp;
return t.data;
return *reinterpret_cast<asUINT*>(&fp);
}
double fpFromIEEE(asQWORD raw)
{
alias_cast_t<asQWORD, double> t;
t.raw = raw;
return t.data;
return *reinterpret_cast<double*>(&raw);
}
asQWORD fpToIEEE(double fp)
{
alias_cast_t<double, asQWORD> t;
t.raw = fp;
return t.data;
return *reinterpret_cast<asQWORD*>(&fp);
}
// closeTo() is used to determine if the binary representation of two numbers are
@@ -214,7 +196,6 @@ void RegisterScriptMath_Native(asIScriptEngine *engine)
r = engine->RegisterGlobalFunction("double floor(double)", asFUNCTIONPR(floor, (double), double), asCALL_CDECL); assert( r >= 0 );
r = engine->RegisterGlobalFunction("double fraction(double)", asFUNCTIONPR(fraction, (double), double), asCALL_CDECL); assert( r >= 0 );
#endif
(void)r;
}
#if AS_USE_FLOAT
@@ -351,7 +332,6 @@ void RegisterScriptMath_Generic(asIScriptEngine *engine)
r = engine->RegisterGlobalFunction("double floor(double)", asFUNCTION(floor_generic), asCALL_GENERIC); assert( r >= 0 );
r = engine->RegisterGlobalFunction("double fraction(double)", asFUNCTION(fraction_generic), asCALL_GENERIC); assert( r >= 0 );
#endif
(void)r;
}
void RegisterScriptMath(asIScriptEngine *engine)