diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-09-17 15:04:21 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-09-17 15:04:21 -0300 |
commit | 67cae2854cd2f90ff0cd91d641ab0b76417a1302 (patch) | |
tree | 74e1c888e6cd0b80e98a2a7adc26fd1bbab97844 | |
parent | 0e45ffb8e41fa8f6b156bdaff0685e1ddfdfbd2a (diff) | |
download | lua-67cae2854cd2f90ff0cd91d641ab0b76417a1302.tar.gz lua-67cae2854cd2f90ff0cd91d641ab0b76417a1302.tar.bz2 lua-67cae2854cd2f90ff0cd91d641ab0b76417a1302.zip |
'lua_mainthread' replaced by new preregistered value LUA_RIDX_MAINTHREAD
-rw-r--r-- | lapi.c | 7 | ||||
-rw-r--r-- | lstate.c | 14 | ||||
-rw-r--r-- | ltests.c | 8 | ||||
-rw-r--r-- | lua.h | 10 |
4 files changed, 25 insertions, 14 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.88 2009/08/07 16:17:41 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.89 2009/08/31 14:26:28 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 | */ |
@@ -102,11 +102,6 @@ LUA_API int lua_checkstack (lua_State *L, int size) { | |||
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | LUA_API lua_State *lua_mainthread (lua_State *L) { | ||
106 | return G(L)->mainthread; | ||
107 | } | ||
108 | |||
109 | |||
110 | LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { | 105 | LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { |
111 | int i; | 106 | int i; |
112 | if (from == to) return; | 107 | if (from == to) return; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.56 2009/06/18 18:59:18 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.57 2009/07/15 17:26:14 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -91,6 +91,16 @@ static void freestack (lua_State *L) { | |||
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | static void init_registry (lua_State *L) { | ||
95 | Table *registry = luaH_new(L); | ||
96 | TValue mt; | ||
97 | sethvalue(L, registry(L), registry); | ||
98 | luaH_resize(L, registry, LUA_RIDX_LAST, 0); | ||
99 | setthvalue(L, &mt, L); | ||
100 | setobj2t(L, luaH_setint(L, registry, LUA_RIDX_MAINTHREAD), &mt); | ||
101 | } | ||
102 | |||
103 | |||
94 | /* | 104 | /* |
95 | ** open parts that may cause memory-allocation errors | 105 | ** open parts that may cause memory-allocation errors |
96 | */ | 106 | */ |
@@ -99,7 +109,7 @@ static void f_luaopen (lua_State *L, void *ud) { | |||
99 | UNUSED(ud); | 109 | UNUSED(ud); |
100 | stack_init(L, L); /* init stack */ | 110 | stack_init(L, L); /* init stack */ |
101 | sethvalue(L, gt(L), luaH_new(L)); /* table of globals */ | 111 | sethvalue(L, gt(L), luaH_new(L)); /* table of globals */ |
102 | sethvalue(L, registry(L), luaH_new(L)); /* registry */ | 112 | init_registry(L); |
103 | luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ | 113 | luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ |
104 | luaT_init(L); | 114 | luaT_init(L); |
105 | luaX_init(L); | 115 | luaX_init(L); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.70 2009/09/09 20:44:10 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.71 2009/09/14 14:30:39 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 | */ |
@@ -697,8 +697,6 @@ static int doonnewstack (lua_State *L) { | |||
697 | size_t l; | 697 | size_t l; |
698 | const char *s = luaL_checklstring(L, 1, &l); | 698 | const char *s = luaL_checklstring(L, 1, &l); |
699 | int status = luaL_loadbuffer(L1, s, l, s); | 699 | int status = luaL_loadbuffer(L1, s, l, s); |
700 | lua_State *ML = lua_mainthread(L1); | ||
701 | lua_assert(L1 != L && ML != L1 && lua_mainthread(L) == ML); | ||
702 | if (status == LUA_OK) | 700 | if (status == LUA_OK) |
703 | status = lua_pcall(L1, 0, 0, 0); | 701 | status = lua_pcall(L1, 0, 0, 0); |
704 | lua_pushinteger(L, status); | 702 | lua_pushinteger(L, status); |
@@ -973,6 +971,10 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { | |||
973 | else if EQ("gettable") { | 971 | else if EQ("gettable") { |
974 | lua_gettable(L1, getindex); | 972 | lua_gettable(L1, getindex); |
975 | } | 973 | } |
974 | else if EQ("rawgeti") { | ||
975 | int t = getindex; | ||
976 | lua_rawgeti(L1, t, getnum); | ||
977 | } | ||
976 | else if EQ("settable") { | 978 | else if EQ("settable") { |
977 | lua_settable(L1, getindex); | 979 | lua_settable(L1, getindex); |
978 | } | 980 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.241 2009/07/15 17:26:14 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.242 2009/09/14 14:30:39 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 |
@@ -89,6 +89,12 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); | |||
89 | #define LUA_MINSTACK 20 | 89 | #define LUA_MINSTACK 20 |
90 | 90 | ||
91 | 91 | ||
92 | /* predefined values in the registry */ | ||
93 | #define LUA_RIDX_MAINTHREAD 1 | ||
94 | #define LUA_RIDX_LAST LUA_RIDX_MAINTHREAD | ||
95 | |||
96 | |||
97 | |||
92 | /* | 98 | /* |
93 | ** generic extra include file | 99 | ** generic extra include file |
94 | */ | 100 | */ |
@@ -113,8 +119,6 @@ LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); | |||
113 | LUA_API void (lua_close) (lua_State *L); | 119 | LUA_API void (lua_close) (lua_State *L); |
114 | LUA_API lua_State *(lua_newthread) (lua_State *L); | 120 | LUA_API lua_State *(lua_newthread) (lua_State *L); |
115 | 121 | ||
116 | LUA_API lua_State *(lua_mainthread) (lua_State *L); | ||
117 | |||
118 | LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); | 122 | LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); |
119 | 123 | ||
120 | 124 | ||