diff --git a/source/Base/Sphere.cpp b/source/Base/Sphere.cpp index 0b574ae6..b2fe7152 100644 --- a/source/Base/Sphere.cpp +++ b/source/Base/Sphere.cpp @@ -1,6 +1,7 @@ // ------------------------------------------------------------------------------------------------ #include "Base/Sphere.hpp" #include "Base/Shared.hpp" +#include "Base/DynArg.hpp" #include "Library/Numeric/Random.hpp" // ------------------------------------------------------------------------------------------------ @@ -559,13 +560,13 @@ void Register_Sphere(HSQUIRRELVM vm) // Core Meta-methods .Func(_SC("_tostring"), &Sphere::ToString) .SquirrelFunc(_SC("_typename"), &Sphere::Typename) - .Func(_SC("_cmp"), &Sphere::Cmp) + .SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< Sphere >, SQFloat, SQInteger, bool, std::nullptr_t, Sphere >) // Meta-methods - .Func< Sphere (Sphere::*)(const Sphere &) const >(_SC("_add"), &Sphere::operator +) - .Func< Sphere (Sphere::*)(const Sphere &) const >(_SC("_sub"), &Sphere::operator -) - .Func< Sphere (Sphere::*)(const Sphere &) const >(_SC("_mul"), &Sphere::operator *) - .Func< Sphere (Sphere::*)(const Sphere &) const >(_SC("_div"), &Sphere::operator /) - .Func< Sphere (Sphere::*)(const Sphere &) const >(_SC("_modulo"), &Sphere::operator %) + .SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< Sphere >, SQFloat, SQInteger, bool, std::nullptr_t, Sphere >) + .SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< Sphere >, SQFloat, SQInteger, bool, std::nullptr_t, Sphere >) + .SquirrelFunc(_SC("_mul"), &SqDynArgFwd< SqDynArgMulFn< Sphere >, SQFloat, SQInteger, bool, std::nullptr_t, Sphere >) + .SquirrelFunc(_SC("_div"), &SqDynArgFwd< SqDynArgDivFn< Sphere >, SQFloat, SQInteger, bool, std::nullptr_t, Sphere >) + .SquirrelFunc(_SC("_modulo"), &SqDynArgFwd< SqDynArgModFn< Sphere >, SQFloat, SQInteger, bool, std::nullptr_t, Sphere >) .Func< Sphere (Sphere::*)(void) const >(_SC("_unm"), &Sphere::operator -) // Properties .Prop(_SC("Abs"), &Sphere::Abs) diff --git a/source/Base/Sphere.hpp b/source/Base/Sphere.hpp index 99f0fe98..ec327f2c 100644 --- a/source/Base/Sphere.hpp +++ b/source/Base/Sphere.hpp @@ -306,6 +306,30 @@ struct Sphere */ Int32 Cmp(const Sphere & s) const; + /* -------------------------------------------------------------------------------------------- + * Used by the script engine to compare an instance of this type with a scalar value. + */ + Int32 Cmp(Value s) const + { + return Cmp(Sphere(s)); + } + + /* -------------------------------------------------------------------------------------------- + * Used by the script engine to compare an instance of this type with a scalar value. + */ + Int32 Cmp(Int32 s) const + { + return Cmp(Sphere(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(Sphere(static_cast< Value >(0))); + } + /* -------------------------------------------------------------------------------------------- * Used by the script engine to convert an instance of this type to a string. */