add lua/C++ dynamic_cast<>

This commit is contained in:
Robin Gareus 2016-06-01 13:59:31 +02:00
parent 79245a296b
commit 67083d65e4
3 changed files with 40 additions and 0 deletions

View file

@ -379,6 +379,29 @@ struct CFunc
};
template <class T, class R>
struct CastClass
{
static int f (lua_State* L)
{
T * const t = Userdata::get <T> (L, 1, false );
Stack <R*>::push (L, dynamic_cast<R*>(t));
return 1;
}
};
template <class T, class R>
struct CastConstClass
{
static int f (lua_State* L)
{
T const* const t = Userdata::get <T> (L, 1, true);
Stack <R const*>::push (L, dynamic_cast<R const*>(t));
return 1;
}
};
template <class T>
struct PtrNullCheck
{