diff options
author | Pixel <pixel@nobis-crew.org> | 2009-05-24 20:49:10 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2009-05-24 20:49:10 -0700 |
commit | 37fb09922f93215b2be2c76080f64e754bf2c6aa (patch) | |
tree | 6196f90018b071a623fb42f06ed96c48b59da5ae /include | |
parent | e20675412a5d4aadd861517b40ca200d9b605225 (diff) |
Moving lua_recast out of LuaOCCI into BLua.h
Diffstat (limited to 'include')
-rw-r--r-- | include/BLua.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/BLua.h b/include/BLua.h index 2ca7b2a..fc8adb2 100644 --- a/include/BLua.h +++ b/include/BLua.h @@ -336,6 +336,26 @@ class LuaHelpers : public Base { } }; +template<class T> +T * lua_recast(Lua * L, int n = 1) { + Base * b; + T * r; + + b = (Base *) LuaObject::getme(L, n); + if (!b) { + L->error("Base object required; got null."); + } + + r = dynamic_cast<T *>(b); + + if (!r) { + L->error(String("Object not compatible; expecting ") + typeid(r).name() + " but got *" + typeid(*b).name() + " instead."); + } + + return r; +} + + /*******************************\ |** Let's have a sample of use **| |