[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: [ANNOUNCE] Lua 5.0 (beta) now available
- From: Benoit Germain <bgermain@...>
- Date: Thu, 19 Dec 2002 12:37:11 +0100
My use of coroutines and debugger makes necessary to obtain the lua_State
associated to a coroutine. The first option is to create a thread by hand,
but since what I want to do is reproduce the behaviour of what is obtained
with coroutine.wrap(), I would need to duplicate several pieces of code
found in lbaselib.c because these are static.
Another solution, much more straightforward, would be that LUA had something
equivalent to lua_pushupvalues() in its API, but instead of reading the
upvalues of the current call frame, being able to get the upvalues of a
cclosure at a given stack index.
Because I am a good person, here it is :-)
LUA_API int lua_getupvalues (lua_State *L, int index) {
Closure *func;
int n, i;
StkId t;
lua_lock(L);
t = luaA_index(L, index);
api_check(L, iscfunction(t));
func = clvalue(t);
n = func->c.nupvalues;
luaD_checkstack(L, n + LUA_MINSTACK);
for (i=0; i<n; i++) {
setobj2s(L->top, &func->c.upvalue[i]);
L->top++;
}
lua_unlock(L);
return n;
}
maybe for 5.0 final ?
please please please :-)