From a2094b6831edb25cf6dd1409ceee7bd0c56ece0d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 16 Mar 2017 20:08:17 +0100 Subject: Lua: provide instance-equal check as '==' comparator. This deprecated explicit the "sameinstance()" method --- libs/lua/LuaBridge/detail/CFunctions.h | 19 ++++++++++++++++++- libs/lua/LuaBridge/detail/Namespace.h | 12 ++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/libs/lua/LuaBridge/detail/CFunctions.h b/libs/lua/LuaBridge/detail/CFunctions.h index 2f1c3f635b..2f94ab90e9 100644 --- a/libs/lua/LuaBridge/detail/CFunctions.h +++ b/libs/lua/LuaBridge/detail/CFunctions.h @@ -378,7 +378,6 @@ struct CFunc } }; - template struct CastClass { @@ -461,6 +460,24 @@ struct CFunc } }; + template + struct ClassEqualCheck > + { + static int f (lua_State* L) + { + return PtrEqualCheck::f (L); + } + }; + + template + struct ClassEqualCheck > + { + static int f (lua_State* L) + { + return WPtrEqualCheck::f (L); + } + }; + template static int getPtrProperty (lua_State* L) { diff --git a/libs/lua/LuaBridge/detail/Namespace.h b/libs/lua/LuaBridge/detail/Namespace.h index 3644b9e157..b661093e2b 100644 --- a/libs/lua/LuaBridge/detail/Namespace.h +++ b/libs/lua/LuaBridge/detail/Namespace.h @@ -579,10 +579,14 @@ private: createConstTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod ); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck ::f, 0); + rawsetfield (L, -2, "__eq"); createClassTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod ); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck ::f, 0); + rawsetfield (L, -2, "__eq"); createStaticTable (name); @@ -626,10 +630,14 @@ private: createConstTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod ); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck ::f, 0); + rawsetfield (L, -2, "__eq"); createClassTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod ); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck ::f, 0); + rawsetfield (L, -2, "__eq"); createStaticTable (name); @@ -1159,10 +1167,14 @@ private: createConstTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod ); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck ::f, 0); + rawsetfield (L, -2, "__eq"); createClassTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod ); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck ::f, 0); + rawsetfield (L, -2, "__eq"); createStaticTable (name); -- cgit v1.2.3