2
0
Эх сурвалжийг харах

new API function 'lua_mainthread'

Roberto Ierusalimschy 16 жил өмнө
parent
commit
a21c89ddc8
3 өөрчлөгдсөн 12 нэмэгдсэн , 3 устгасан
  1. 6 1
      lapi.c
  2. 3 1
      ltests.c
  3. 3 1
      lua.h

+ 6 - 1
lapi.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.c,v 2.76 2009/04/17 22:00:01 roberto Exp roberto $
+** $Id: lapi.c,v 2.78 2009/06/01 19:09:26 roberto Exp roberto $
 ** Lua API
 ** Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -99,6 +99,11 @@ LUA_API int lua_checkstack (lua_State *L, int size) {
 }
 }
 
 
 
 
+LUA_API lua_State *lua_mainthread (lua_State *L) {
+  return G(L)->mainthread;
+}
+
+
 LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
 LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
   int i;
   int i;
   if (from == to) return;
   if (from == to) return;

+ 3 - 1
ltests.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltests.c,v 2.63 2009/06/01 19:09:26 roberto Exp roberto $
+** $Id: ltests.c,v 2.64 2009/06/10 16:57:53 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -698,6 +698,8 @@ static int doonnewstack (lua_State *L) {
   size_t l;
   size_t l;
   const char *s = luaL_checklstring(L, 1, &l);
   const char *s = luaL_checklstring(L, 1, &l);
   int status = luaL_loadbuffer(L1, s, l, s);
   int status = luaL_loadbuffer(L1, s, l, s);
+  lua_State *ML = lua_mainthread(L1);
+  lua_assert(L1 != L && ML != L1 && lua_mainthread(L) == ML);
   if (status == LUA_OK)
   if (status == LUA_OK)
     status = lua_pcall(L1, 0, 0, 0);
     status = lua_pcall(L1, 0, 0, 0);
   lua_pushinteger(L, status);
   lua_pushinteger(L, status);

+ 3 - 1
lua.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lua.h,v 1.236 2009/04/17 14:28:06 roberto Exp roberto $
+** $Id: lua.h,v 1.237 2009/05/21 20:06:11 roberto Exp roberto $
 ** Lua - An Extensible Extension Language
 ** Lua - An Extensible Extension Language
 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
 ** See Copyright Notice at the end of this file
 ** See Copyright Notice at the end of this file
@@ -113,6 +113,8 @@ LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
 LUA_API void       (lua_close) (lua_State *L);
 LUA_API void       (lua_close) (lua_State *L);
 LUA_API lua_State *(lua_newthread) (lua_State *L);
 LUA_API lua_State *(lua_newthread) (lua_State *L);
 
 
+LUA_API lua_State *(lua_mainthread) (lua_State *L);
+
 LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
 LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);