1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-20 19:57:12 +01:00

Update the Color4 type to use the new dynamic dispatching system for metamethods.

This commit is contained in:
Sandu Liviu Catalin 2016-08-24 23:17:18 +03:00
parent 778b6ea59d
commit b05b6409b8
2 changed files with 31 additions and 6 deletions

View File

@ -2,6 +2,7 @@
#include "Base/Color4.hpp"
#include "Base/Color3.hpp"
#include "Base/Shared.hpp"
#include "Base/DynArg.hpp"
#include "Library/Numeric/Random.hpp"
// ------------------------------------------------------------------------------------------------
@ -779,13 +780,13 @@ void Register_Color4(HSQUIRRELVM vm)
// Core Meta-methods
.Func(_SC("_tostring"), &Color4::ToString)
.SquirrelFunc(_SC("_typename"), &Color4::Typename)
.Func(_SC("_cmp"), &Color4::Cmp)
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< Color4 >, SQFloat, SQInteger, bool, std::nullptr_t, Color4 >)
// Meta-methods
.Func< Color4 (Color4::*)(const Color4 &) const >(_SC("_add"), &Color4::operator +)
.Func< Color4 (Color4::*)(const Color4 &) const >(_SC("_sub"), &Color4::operator -)
.Func< Color4 (Color4::*)(const Color4 &) const >(_SC("_mul"), &Color4::operator *)
.Func< Color4 (Color4::*)(const Color4 &) const >(_SC("_div"), &Color4::operator /)
.Func< Color4 (Color4::*)(const Color4 &) const >(_SC("_modulo"), &Color4::operator %)
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< Color4 >, SQFloat, SQInteger, bool, std::nullptr_t, Color4 >)
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< Color4 >, SQFloat, SQInteger, bool, std::nullptr_t, Color4 >)
.SquirrelFunc(_SC("_mul"), &SqDynArgFwd< SqDynArgMulFn< Color4 >, SQFloat, SQInteger, bool, std::nullptr_t, Color4 >)
.SquirrelFunc(_SC("_div"), &SqDynArgFwd< SqDynArgDivFn< Color4 >, SQFloat, SQInteger, bool, std::nullptr_t, Color4 >)
.SquirrelFunc(_SC("_modulo"), &SqDynArgFwd< SqDynArgModFn< Color4 >, SQFloat, SQInteger, bool, std::nullptr_t, Color4 >)
.Func< Color4 (Color4::*)(void) const >(_SC("_unm"), &Color4::operator -)
// Properties
.Prop(_SC("RGB"), &Color4::GetRGB, &Color4::SetRGB)

View File

@ -369,6 +369,30 @@ struct Color4
*/
Int32 Cmp(const Color4 & c) const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to compare an instance of this type with a scalar value.
*/
Int32 Cmp(Int32 s) const
{
return Cmp(Color4(static_cast< Value >(s)));
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to compare an instance of this type with a scalar value.
*/
Int32 Cmp(Float32 s) const
{
return Cmp(Color4(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(Color4(static_cast< Value >(0)));
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/