mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-20 19:57:12 +01:00
Update the Vector4 type to use the new dynamic dispatching system for metamethods.
This commit is contained in:
parent
fd9979453b
commit
a0316092e3
@ -3,6 +3,7 @@
|
||||
#include "Base/Vector3.hpp"
|
||||
#include "Base/Quaternion.hpp"
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Base/DynArg.hpp"
|
||||
#include "Library/Numeric/Random.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -560,13 +561,13 @@ void Register_Vector4(HSQUIRRELVM vm)
|
||||
// Core Meta-methods
|
||||
.Func(_SC("_tostring"), &Vector4::ToString)
|
||||
.SquirrelFunc(_SC("_typename"), &Vector4::Typename)
|
||||
.Func(_SC("_cmp"), &Vector4::Cmp)
|
||||
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< Vector4 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector4 >)
|
||||
// Meta-methods
|
||||
.Func< Vector4 (Vector4::*)(const Vector4 &) const >(_SC("_add"), &Vector4::operator +)
|
||||
.Func< Vector4 (Vector4::*)(const Vector4 &) const >(_SC("_sub"), &Vector4::operator -)
|
||||
.Func< Vector4 (Vector4::*)(const Vector4 &) const >(_SC("_mul"), &Vector4::operator *)
|
||||
.Func< Vector4 (Vector4::*)(const Vector4 &) const >(_SC("_div"), &Vector4::operator /)
|
||||
.Func< Vector4 (Vector4::*)(const Vector4 &) const >(_SC("_modulo"), &Vector4::operator %)
|
||||
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< Vector4 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector4 >)
|
||||
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< Vector4 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector4 >)
|
||||
.SquirrelFunc(_SC("_mul"), &SqDynArgFwd< SqDynArgMulFn< Vector4 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector4 >)
|
||||
.SquirrelFunc(_SC("_div"), &SqDynArgFwd< SqDynArgDivFn< Vector4 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector4 >)
|
||||
.SquirrelFunc(_SC("_modulo"), &SqDynArgFwd< SqDynArgModFn< Vector4 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector4 >)
|
||||
.Func< Vector4 (Vector4::*)(void) const >(_SC("_unm"), &Vector4::operator -)
|
||||
// Properties
|
||||
.Prop(_SC("Abs"), &Vector4::Abs)
|
||||
|
@ -259,6 +259,30 @@ struct Vector4
|
||||
*/
|
||||
Int32 Cmp(const Vector4 & v) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to compare an instance of this type with a scalar value.
|
||||
*/
|
||||
Int32 Cmp(Value s) const
|
||||
{
|
||||
return Cmp(Vector4(s));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to compare an instance of this type with a scalar value.
|
||||
*/
|
||||
Int32 Cmp(Int32 s) const
|
||||
{
|
||||
return Cmp(Vector4(static_cast< Value >(s)));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to compare an instance of this type with a scalar value.
|
||||
*/
|
||||
Int32 Cmp(std::nullptr_t) const
|
||||
{
|
||||
return Cmp(Vector4(static_cast< Value >(0)));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to convert an instance of this type to a string.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user