aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-06-15 16:51:31 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-06-15 16:51:31 -0300
commita21c89ddc8b91c9fd4888577f7a6c60c4f640795 (patch)
tree393aa5c8213338b9b72d220bab87c3bdbae20f4f
parent49b88b1c39fca21f1f55e462e0f549b8187f89d6 (diff)
downloadlua-a21c89ddc8b91c9fd4888577f7a6c60c4f640795.tar.gz
lua-a21c89ddc8b91c9fd4888577f7a6c60c4f640795.tar.bz2
lua-a21c89ddc8b91c9fd4888577f7a6c60c4f640795.zip
new API function 'lua_mainthread'
-rw-r--r--lapi.c7
-rw-r--r--ltests.c4
-rw-r--r--lua.h4
3 files changed, 12 insertions, 3 deletions
diff --git a/lapi.c b/lapi.c
index d159df84..8f07a35b 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.76 2009/04/17 22:00:01 roberto Exp roberto $ 2** $Id: lapi.c,v 2.78 2009/06/01 19:09:26 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*/
@@ -99,6 +99,11 @@ LUA_API int lua_checkstack (lua_State *L, int size) {
99} 99}
100 100
101 101
102LUA_API lua_State *lua_mainthread (lua_State *L) {
103 return G(L)->mainthread;
104}
105
106
102LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { 107LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
103 int i; 108 int i;
104 if (from == to) return; 109 if (from == to) return;
diff --git a/ltests.c b/ltests.c
index e2c15f14..cb451f98 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.63 2009/06/01 19:09:26 roberto Exp roberto $ 2** $Id: ltests.c,v 2.64 2009/06/10 16:57:53 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -698,6 +698,8 @@ static int doonnewstack (lua_State *L) {
698 size_t l; 698 size_t l;
699 const char *s = luaL_checklstring(L, 1, &l); 699 const char *s = luaL_checklstring(L, 1, &l);
700 int status = luaL_loadbuffer(L1, s, l, s); 700 int status = luaL_loadbuffer(L1, s, l, s);
701 lua_State *ML = lua_mainthread(L1);
702 lua_assert(L1 != L && ML != L1 && lua_mainthread(L) == ML);
701 if (status == LUA_OK) 703 if (status == LUA_OK)
702 status = lua_pcall(L1, 0, 0, 0); 704 status = lua_pcall(L1, 0, 0, 0);
703 lua_pushinteger(L, status); 705 lua_pushinteger(L, status);
diff --git a/lua.h b/lua.h
index 2836832b..62205158 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.236 2009/04/17 14:28:06 roberto Exp roberto $ 2** $Id: lua.h,v 1.237 2009/05/21 20:06:11 roberto Exp roberto $
3** Lua - An Extensible Extension Language 3** Lua - An Extensible Extension Language
4** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
5** See Copyright Notice at the end of this file 5** See Copyright Notice at the end of this file
@@ -113,6 +113,8 @@ LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
113LUA_API void (lua_close) (lua_State *L); 113LUA_API void (lua_close) (lua_State *L);
114LUA_API lua_State *(lua_newthread) (lua_State *L); 114LUA_API lua_State *(lua_newthread) (lua_State *L);
115 115
116LUA_API lua_State *(lua_mainthread) (lua_State *L);
117
116LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); 118LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
117 119
118 120