From 05bf1ebf8f3a120e4ebb4ac45230222c6717a518 Mon Sep 17 00:00:00 2001 From: pixel Date: Mon, 8 Dec 2003 15:12:56 +0000 Subject: LUA everywhere! Wheee! --- lib/BLua.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/BLua.cc b/lib/BLua.cc index c3f7351..36cc566 100644 --- a/lib/BLua.cc +++ b/lib/BLua.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: BLua.cc,v 1.9 2003-12-07 05:50:41 pixel Exp $ */ +/* $Id: BLua.cc,v 1.10 2003-12-08 15:12:56 pixel Exp $ */ #include @@ -321,12 +321,6 @@ bool Lua::isuserdata(int i) { bool Lua::islightuserdata(int i) { return lua_islightuserdata(L, i); } - bool toboolean(int = -1); - lua_Number tonumber(int = -1); - String tostring(int = -1); - lua_CFunction tocfunction(int = -1); - void * touserdata(int = -1); - Lua * tothread(int = -1); bool Lua::toboolean(int i) { return lua_toboolean(L, i); @@ -484,15 +478,21 @@ void LuaObject::pushme(Lua * L, void * o) { L->settable(); } -void * LuaObject::getme(Lua * L, int i) throw (GeneralException) { +void * LuaObject::getme(Lua * L, int i) { void * r; - L->push("__obj"); - L->gettable(i); - if (!(r = L->touserdata())) { - throw GeneralException("Lua object already destroyed"); + if (L->istable(i)) { + L->push("__obj"); + L->gettable(i); + if (!(r = L->touserdata())) { + L->error("Lua object already destroyed, or table is not an object."); + } + L->pop(); + } else if (L->isnil(i)) { + r = 0; + } else { + L->error("Not an object"); } - L->pop(); return r; } @@ -500,7 +500,7 @@ void * LuaObject::getme(Lua * L, int i) throw (GeneralException) { void LuaObject::pushit(Lua * L, const String & s, lua_CFunction f) { L->push(s); L->push(f); - L->settable(); + L->settable(-3, true); } void LuaObject::pushmeta(Lua * L, const String & s, lua_CFunction f) { -- cgit v1.2.3