From cdf245a8d0f0cea8665e51946aee69052f798e3e Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Mon, 7 Dec 2009 01:54:21 +0100 Subject: Upgrading to LuaJIT 2.0.0-beta2 - changing the callwrap support. --- lib/BLua.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/BLua.cc') diff --git a/lib/BLua.cc b/lib/BLua.cc index 175f420..e9a3e85 100644 --- a/lib/BLua.cc +++ b/lib/BLua.cc @@ -413,10 +413,9 @@ int LuaStatics::print(lua_State * _L) { int LuaStatics::callwrap(lua_State * __L, lua_CFunction func) { Lua * L = Lua::find(__L); - int n; try { - n = func(__L); + return func(__L); } catch (LuaException e) { L->error(String("LuaException: ") + e.GetMsg()); @@ -425,7 +424,7 @@ int LuaStatics::callwrap(lua_State * __L, lua_CFunction func) { L->error(String("GeneralException: ") + e.GetMsg()); } - return n; + return 0; } int LuaStatics::collector(lua_State * __L) { @@ -472,10 +471,16 @@ void LuaStatics::destroyhook(lua_State * __L, lua_State * L1) { delete L; } +void Lua::setcallwrap(lua_CallWrapper wrapper) { + push((void *) wrapper); + luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC|LUAJIT_MODE_ON); + pop(); +} + void Lua::setup_state(lua_State *) { lualist[L] = this; lua_atpanic(L, LuaStatics::luapanic); - lua_setcallwrap(L, LuaStatics::callwrap); + setcallwrap(LuaStatics::callwrap); lua_setcreatehook(L, LuaStatics::createhook); lua_setdestroyhook(L, LuaStatics::destroyhook); -- cgit v1.2.3