summaryrefslogtreecommitdiff
path: root/lib/lua/src
diff options
context:
space:
mode:
authorpixel <pixel>2004-12-27 22:18:52 +0000
committerpixel <pixel>2004-12-27 22:18:52 +0000
commit4710572bf3f2fb202d0cb3dda95ef28c85ea1b81 (patch)
treebadd157b2b2c3f18553c793f49f1294dc0637372 /lib/lua/src
parentecb5155dfed400c50b3b54a758d546b7754bcbf1 (diff)
adding C-closure wrapping to lua, and using it.
Diffstat (limited to 'lib/lua/src')
-rw-r--r--lib/lua/src/ldebug.c12
-rw-r--r--lib/lua/src/ldo.c8
-rw-r--r--lib/lua/src/lstate.c3
3 files changed, 19 insertions, 4 deletions
diff --git a/lib/lua/src/ldebug.c b/lib/lua/src/ldebug.c
index 65114c7..b154c1b 100644
--- a/lib/lua/src/ldebug.c
+++ b/lib/lua/src/ldebug.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 1.4 2004-11-27 21:46:07 pixel Exp $
+** $Id: ldebug.c,v 1.5 2004-12-27 22:18:53 pixel Exp $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -91,6 +91,16 @@ LUA_API int lua_gethookcount (lua_State *L) {
}
+LUA_API lua_CallWrap lua_setcallwrap (lua_State *L, lua_CallWrap func) {
+ lua_CallWrap old_func;
+ lua_lock(L);
+ old_func = L->callwrap;
+ L->callwrap = func;
+ lua_unlock(L);
+ return old_func;
+}
+
+
LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
int status;
CallInfo *ci;
diff --git a/lib/lua/src/ldo.c b/lib/lua/src/ldo.c
index 082b9e6..b23f8b1 100644
--- a/lib/lua/src/ldo.c
+++ b/lib/lua/src/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 1.7 2004-12-27 19:59:05 pixel Exp $
+** $Id: ldo.c,v 1.8 2004-12-27 22:18:53 pixel Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -257,7 +257,11 @@ StkId luaD_precall (lua_State *L, StkId func) {
#ifdef LUA_COMPATUPVALUES
lua_pushupvalues(L);
#endif
- n = (*clvalue(L->base - 1)->c.f)(L); /* do the actual call */
+ if (L->callwrap) {
+ n = L->callwrap(L, clvalue(L->base - 1)->c.f); /* wrap the call */
+ } else {
+ n = (*clvalue(L->base - 1)->c.f)(L); /* do the actual call */
+ }
lua_lock(L);
return L->top - n;
}
diff --git a/lib/lua/src/lstate.c b/lib/lua/src/lstate.c
index ccd6aeb..113a69b 100644
--- a/lib/lua/src/lstate.c
+++ b/lib/lua/src/lstate.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.c,v 1.4 2004-11-27 21:46:07 pixel Exp $
+** $Id: lstate.c,v 1.5 2004-12-27 22:18:53 pixel Exp $
** Global State
** See Copyright Notice in lua.h
*/
@@ -137,6 +137,7 @@ static void preinit_state (lua_State *L) {
L->nCcalls = 0;
L->base_ci = L->ci = NULL;
L->errfunc = 0;
+ L->callwrap = 0;
setnilvalue(gt(L));
}