aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/lapi.c b/lapi.c
index 60dc19f5..eb4fe4f3 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.70 2009/02/19 17:15:13 roberto Exp roberto $ 2** $Id: lapi.c,v 2.71 2009/03/10 17:14:37 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -761,17 +761,28 @@ LUA_API int lua_setfenv (lua_State *L, int idx) {
761 api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) 761 api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
762 762
763 763
764LUA_API void lua_callcont (lua_State *L, int nargs, int nresults, 764LUA_API int lua_getctx (lua_State *L, int *ctx) {
765 lua_CFunction cont) { 765 if (L->ci->callstatus & CIST_CTX) { /* call has ctx? */
766 *ctx = L->ci->u.c.ctx;
767 return LUA_YIELD;
768 }
769 else return LUA_OK;
770}
771
772
773LUA_API void lua_callk (lua_State *L, int nargs, int nresults, int ctx,
774 lua_CFunction k) {
766 StkId func; 775 StkId func;
767 lua_lock(L); 776 lua_lock(L);
768 /* cannot use continuations inside hooks */ 777 /* cannot use continuations inside hooks */
769 api_check(L, cont == NULL || !isLua(L->ci)); 778 api_check(L, k == NULL || !isLua(L->ci));
770 api_checknelems(L, nargs+1); 779 api_checknelems(L, nargs+1);
771 checkresults(L, nargs, nresults); 780 checkresults(L, nargs, nresults);
772 func = L->top - (nargs+1); 781 func = L->top - (nargs+1);
773 if (cont) { 782 if (k != NULL) {
774 L->ci->u.c.cont = cont; 783 L->ci->u.c.k = k;
784 L->ci->u.c.ctx = ctx;
785 L->ci->callstatus |= CIST_CTX;
775 luaD_call(L, func, nresults, 1); 786 luaD_call(L, func, nresults, 1);
776 } 787 }
777 else 788 else