[lua] Add negation operation (unary -) into Point() metatable

This commit is contained in:
David Capello 2019-08-13 18:19:05 -03:00
parent ad1a39714e
commit 0812ea8224

View File

@ -86,6 +86,13 @@ int Point_tostring(lua_State* L)
return 1;
}
int Point_unm(lua_State* L)
{
const auto pt = get_obj<gfx::Point>(L, 1);
push_obj(L, -(*pt));
return 1;
}
int Point_get_x(lua_State* L)
{
const auto pt = get_obj<gfx::Point>(L, 1);
@ -118,6 +125,7 @@ const luaL_Reg Point_methods[] = {
{ "__gc", Point_gc },
{ "__eq", Point_eq },
{ "__tostring", Point_tostring },
{ "__unm", Point_unm },
{ nullptr, nullptr }
};