summaryrefslogtreecommitdiff
path: root/lib/BLua.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/BLua.cc')
-rw-r--r--lib/BLua.cc13
1 files changed, 9 insertions, 4 deletions
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);