aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-09-15 17:39:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-09-15 17:39:42 -0300
commit2419f2bf02a9165471248f09bae57e3fa134e545 (patch)
tree9f7e387740892ee591218b8ea745d35a45aa6e41 /lapi.c
parent0e54d2be365ec77cb455e0d0f3c5c6f9efa6e04c (diff)
downloadlua-2419f2bf02a9165471248f09bae57e3fa134e545.tar.gz
lua-2419f2bf02a9165471248f09bae57e3fa134e545.tar.bz2
lua-2419f2bf02a9165471248f09bae57e3fa134e545.zip
cleaner API for coroutines
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/lapi.c b/lapi.c
index c8cf819b..26b2c3b5 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.17 2004/08/17 17:45:45 roberto Exp roberto $ 2** $Id: lapi.c,v 2.18 2004/08/30 13:44:44 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*/
@@ -97,6 +97,7 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
97 if (from == to) return; 97 if (from == to) return;
98 lua_lock(to); 98 lua_lock(to);
99 api_checknelems(from, n); 99 api_checknelems(from, n);
100 api_check(L, G(from) == G(to));
100 from->top -= n; 101 from->top -= n;
101 for (i = 0; i < n; i++) { 102 for (i = 0; i < n; i++) {
102 setobj2s(to, to->top, from->top + i); 103 setobj2s(to, to->top, from->top + i);
@@ -479,6 +480,15 @@ LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
479} 480}
480 481
481 482
483LUA_API int lua_pushthread (lua_State *L) {
484 lua_lock(L);
485 setthvalue(L, L->top, L);
486 api_incr_top(L);
487 lua_unlock(L);
488 return (G(L)->mainthread == L);
489}
490
491
482 492
483/* 493/*
484** get functions (Lua -> stack) 494** get functions (Lua -> stack)
@@ -650,7 +660,7 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
650 case LUA_TTABLE: { 660 case LUA_TTABLE: {
651 hvalue(obj)->metatable = mt; 661 hvalue(obj)->metatable = mt;
652 if (mt) 662 if (mt)
653 luaC_objbarrier(L, hvalue(obj), mt); 663 luaC_objbarriert(L, hvalue(obj), mt);
654 break; 664 break;
655 } 665 }
656 case LUA_TUSERDATA: { 666 case LUA_TUSERDATA: {
@@ -816,6 +826,11 @@ LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) {
816} 826}
817 827
818 828
829LUA_API int lua_threadstatus (lua_State *L) {
830 return L->status;
831}
832
833
819/* 834/*
820** Garbage-collection function 835** Garbage-collection function
821*/ 836*/