summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2009-12-07 01:54:21 +0100
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2009-12-07 01:54:21 +0100
commitcdf245a8d0f0cea8665e51946aee69052f798e3e (patch)
tree22ceadf90521285369b4682441153cc9660020d2 /lib
parentd72f9e9e236cb35faf6ee22527fa9bf6508e46dc (diff)
Upgrading to LuaJIT 2.0.0-beta2 - changing the callwrap support.
Diffstat (limited to 'lib')
-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);