Lua: provide instance-equal check as '==' comparator.

This deprecated explicit the "sameinstance()" method
This commit is contained in:
Robin Gareus 2017-03-16 20:08:17 +01:00
parent 6c65fd41cb
commit a2094b6831
2 changed files with 30 additions and 1 deletions

View file

@ -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)
{

View file

@ -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);