mirror of
https://github.com/love2d/love.git
synced 2026-08-14 01:20:56 +02:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user