diff options
author | Robin Gareus <robin@gareus.org> | 2017-03-16 20:08:17 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-03-16 20:08:17 +0100 |
commit | a2094b6831edb25cf6dd1409ceee7bd0c56ece0d (patch) | |
tree | e6d674f2fbd80c2b82b65630554e407dbc340ba9 /libs/lua | |
parent | 6c65fd41cb49cb34371f6091e54a4c507e6ba453 (diff) |
Lua: provide instance-equal check as '==' comparator.
This deprecated explicit the "sameinstance()" method
Diffstat (limited to 'libs/lua')
-rw-r--r-- | libs/lua/LuaBridge/detail/CFunctions.h | 19 | ||||
-rw-r--r-- | libs/lua/LuaBridge/detail/Namespace.h | 12 |
2 files changed, 30 insertions, 1 deletions
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 <class T, class R> struct CastClass { @@ -461,6 +460,24 @@ struct CFunc } }; + template <class T> + struct ClassEqualCheck<boost::shared_ptr<T> > + { + static int f (lua_State* L) + { + return PtrEqualCheck<T>::f (L); + } + }; + + template <class T> + struct ClassEqualCheck<boost::weak_ptr<T> > + { + static int f (lua_State* L) + { + return WPtrEqualCheck<T>::f (L); + } + }; + template <class C, typename T> 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 <T>); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck <T>::f, 0); + rawsetfield (L, -2, "__eq"); createClassTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod <T>); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck <T>::f, 0); + rawsetfield (L, -2, "__eq"); createStaticTable (name); @@ -626,10 +630,14 @@ private: createConstTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod <T>); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck <T>::f, 0); + rawsetfield (L, -2, "__eq"); createClassTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod <T>); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck <T>::f, 0); + rawsetfield (L, -2, "__eq"); createStaticTable (name); @@ -1159,10 +1167,14 @@ private: createConstTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod <T>); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck <T>::f, 0); + rawsetfield (L, -2, "__eq"); createClassTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod <T>); rawsetfield (L, -2, "__gc"); + lua_pushcclosure (L, &CFunc::ClassEqualCheck <T>::f, 0); + rawsetfield (L, -2, "__eq"); createStaticTable (name); |