mirror of https://github.com/rusefi/lua.git
'lua_mainthread' replaced by new preregistered value LUA_RIDX_MAINTHREAD
This commit is contained in:
parent
0e45ffb8e4
commit
67cae2854c
7
lapi.c
7
lapi.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lapi.c,v 2.88 2009/08/07 16:17:41 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 2.89 2009/08/31 14:26:28 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -102,11 +102,6 @@ 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) {
|
||||
int i;
|
||||
if (from == to) return;
|
||||
|
|
14
lstate.c
14
lstate.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lstate.c,v 2.56 2009/06/18 18:59:18 roberto Exp roberto $
|
||||
** $Id: lstate.c,v 2.57 2009/07/15 17:26:14 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -91,6 +91,16 @@ static void freestack (lua_State *L) {
|
|||
}
|
||||
|
||||
|
||||
static void init_registry (lua_State *L) {
|
||||
Table *registry = luaH_new(L);
|
||||
TValue mt;
|
||||
sethvalue(L, registry(L), registry);
|
||||
luaH_resize(L, registry, LUA_RIDX_LAST, 0);
|
||||
setthvalue(L, &mt, L);
|
||||
setobj2t(L, luaH_setint(L, registry, LUA_RIDX_MAINTHREAD), &mt);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** open parts that may cause memory-allocation errors
|
||||
*/
|
||||
|
@ -99,7 +109,7 @@ static void f_luaopen (lua_State *L, void *ud) {
|
|||
UNUSED(ud);
|
||||
stack_init(L, L); /* init stack */
|
||||
sethvalue(L, gt(L), luaH_new(L)); /* table of globals */
|
||||
sethvalue(L, registry(L), luaH_new(L)); /* registry */
|
||||
init_registry(L);
|
||||
luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */
|
||||
luaT_init(L);
|
||||
luaX_init(L);
|
||||
|
|
8
ltests.c
8
ltests.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ltests.c,v 2.70 2009/09/09 20:44:10 roberto Exp roberto $
|
||||
** $Id: ltests.c,v 2.71 2009/09/14 14:30:39 roberto Exp roberto $
|
||||
** Internal Module for Debugging of the Lua Implementation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -697,8 +697,6 @@ static int doonnewstack (lua_State *L) {
|
|||
size_t l;
|
||||
const char *s = luaL_checklstring(L, 1, &l);
|
||||
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)
|
||||
status = lua_pcall(L1, 0, 0, 0);
|
||||
lua_pushinteger(L, status);
|
||||
|
@ -973,6 +971,10 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
|
|||
else if EQ("gettable") {
|
||||
lua_gettable(L1, getindex);
|
||||
}
|
||||
else if EQ("rawgeti") {
|
||||
int t = getindex;
|
||||
lua_rawgeti(L1, t, getnum);
|
||||
}
|
||||
else if EQ("settable") {
|
||||
lua_settable(L1, getindex);
|
||||
}
|
||||
|
|
10
lua.h
10
lua.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lua.h,v 1.241 2009/07/15 17:26:14 roberto Exp roberto $
|
||||
** $Id: lua.h,v 1.242 2009/09/14 14:30:39 roberto Exp roberto $
|
||||
** Lua - An Extensible Extension Language
|
||||
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
||||
** See Copyright Notice at the end of this file
|
||||
|
@ -89,6 +89,12 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
|
|||
#define LUA_MINSTACK 20
|
||||
|
||||
|
||||
/* predefined values in the registry */
|
||||
#define LUA_RIDX_MAINTHREAD 1
|
||||
#define LUA_RIDX_LAST LUA_RIDX_MAINTHREAD
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** generic extra include file
|
||||
*/
|
||||
|
@ -113,8 +119,6 @@ LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
|
|||
LUA_API void (lua_close) (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);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue