summaryrefslogtreecommitdiff
path: root/include/BLua.h
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-05-28 20:02:44 -0700
committerPixel <pixel@nobis-crew.org>2009-05-28 20:02:44 -0700
commit1e0908de082c3996707c27ecf1c8f32900b0bb60 (patch)
tree2f852a7fcf6c79bf0a554afea994df70fcd06664 /include/BLua.h
parent1c012d1c72f44c65da9c43ca843b712a737900c3 (diff)
parenta7e7cf82276d96ebc7827ec09d06eaae4c5610d0 (diff)
Merge branch 'master' of ssh+git://pixel@git.grumpycoder.net/pub/repo.git/Baltisot
Diffstat (limited to 'include/BLua.h')
-rw-r--r--include/BLua.h39
1 files changed, 19 insertions, 20 deletions
diff --git a/include/BLua.h b/include/BLua.h
index fc8adb2..fe0b33b 100644
--- a/include/BLua.h
+++ b/include/BLua.h
@@ -139,6 +139,24 @@ class Lua : public Base {
void SetPrinter(LuaPrinter *);
void puts(const char * msg);
+ template<class T>
+ T * recast(int n = 1) {
+ Base * b;
+ T * r;
+
+ b = (Base *) LuaObject::getme(this, n);
+ if (!b) {
+ error("Base object required; got null.");
+ }
+
+ r = dynamic_cast<T *>(b);
+
+ if (!r) {
+ error(String("Object not compatible; expecting ") + typeid(r).name() + " but got *" + typeid(*b).name() + " instead.");
+ }
+
+ return r;
+}
protected:
virtual Lua * spawn_from_thread(lua_State *);
Lua(lua_State *);
@@ -336,26 +354,7 @@ 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;
-}
-
-
+template<class T> T * lua_recast(Lua * L, int n = 1) { return L->lua_recast(n); }
/*******************************\
|** Let's have a sample of use **|