Add __eq metamethod to all objects (checks to see if the Proxy data they represent are equal)

--HG--
branch : box2d-update
This commit is contained in:
Bill Meltsner
2011-09-24 11:58:24 -04:00
parent 2e1b941bd6
commit d35dbaa28b
+12
View File
@@ -74,6 +74,14 @@ namespace love
luax_pushboolean(L, p->flags[t]);
return 1;
}
static int w__eq(lua_State * L)
{
Proxy * p1 = (Proxy *)lua_touserdata(L, 1);
Proxy * p2 = (Proxy *)lua_touserdata(L, 2);
luax_pushboolean(L, p1->data == p2->data);
return 1;
}
Reference * luax_refif(lua_State * L, int type)
{
@@ -197,6 +205,10 @@ namespace love
// setup gc
lua_pushcfunction(L, w__gc);
lua_setfield(L, -2, "__gc");
// Add equality
lua_pushcfunction(L, w__eq);
lua_setfield(L, -2, "__eq");
// Add tostring function.
lua_pushstring(L, tname);