From 2419f2bf02a9165471248f09bae57e3fa134e545 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 15 Sep 2004 17:39:42 -0300 Subject: cleaner API for coroutines --- lapi.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lapi.c') diff --git a/lapi.c b/lapi.c index c8cf819b..26b2c3b5 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.17 2004/08/17 17:45:45 roberto Exp roberto $ +** $Id: lapi.c,v 2.18 2004/08/30 13:44:44 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -97,6 +97,7 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { if (from == to) return; lua_lock(to); api_checknelems(from, n); + api_check(L, G(from) == G(to)); from->top -= n; for (i = 0; i < n; i++) { setobj2s(to, to->top, from->top + i); @@ -479,6 +480,15 @@ LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { } +LUA_API int lua_pushthread (lua_State *L) { + lua_lock(L); + setthvalue(L, L->top, L); + api_incr_top(L); + lua_unlock(L); + return (G(L)->mainthread == L); +} + + /* ** get functions (Lua -> stack) @@ -650,7 +660,7 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { case LUA_TTABLE: { hvalue(obj)->metatable = mt; if (mt) - luaC_objbarrier(L, hvalue(obj), mt); + luaC_objbarriert(L, hvalue(obj), mt); break; } case LUA_TUSERDATA: { @@ -816,6 +826,11 @@ LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { } +LUA_API int lua_threadstatus (lua_State *L) { + return L->status; +} + + /* ** Garbage-collection function */ -- cgit v1.2.3-55-g6feb