From 4cefcbc51279f6a8831fa8503c455120e00d7948 Mon Sep 17 00:00:00 2001 From: Mauro Iazzi Date: Tue, 29 Sep 2009 13:37:00 +0200 Subject: [PATCH] added pcall callback handler --- common/lqt_common.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/common/lqt_common.cpp b/common/lqt_common.cpp index 0f7970b..7a7ea20 100644 --- a/common/lqt_common.cpp +++ b/common/lqt_common.cpp @@ -25,6 +25,7 @@ */ #include "lqt_common.hpp" +#include #include #include @@ -612,6 +613,26 @@ int lqtL_touintarray (lua_State *L) { return 1; } +int lqtL_pcall_debug_default (lua_State *L, int narg, int nres, int err) { + int status = 0; + std::cerr << "entering a pcall" << std::endl; + status = lua_pcall(L, narg, nres, err); + std::cerr << "pcall finished with status " << status << std::endl; + return status; +} + +int lqtL_pcall_debug (lua_State *L, int narg, int nres, int err) { + int status = 0; + lua_getfield(L, LUA_REGISTRYINDEX, LQT_PCALL); + lqt_PCallPtr pcall = (lqt_PCallPtr)lua_touserdata(L, -1); + lua_pop(L, 1); + if (pcall) { + status = pcall(L, narg, nres, err); + } else { + status = lqtL_pcall_debug_default(L, narg, nres, err); + } + return status; +} -- 2.11.4.GIT