Lua: Support Lua 5.2.X too

This commit is contained in:
Ilari Liusvaara 2012-01-11 16:41:23 +02:00
parent 993acecdbb
commit cd28aa2987
4 changed files with 39 additions and 10 deletions

View file

@ -1 +1 @@
1-β4 1-β5

View file

@ -125,6 +125,14 @@ Portaudio (portaudio sound only)
std::thread and co (for threaded dumper only) std::thread and co (for threaded dumper only)
\end_layout \end_layout
\begin_layout Enumerate
Lua (if Lua support is needed).
\end_layout
\begin_layout Itemize
Version 5.1.X or 5.2X.
\end_layout
\begin_layout Section \begin_layout Section
Building Building
\end_layout \end_layout
@ -298,11 +306,6 @@ LUA=<package>
Package to use for Lua support. Package to use for Lua support.
\end_layout \end_layout
\begin_layout Itemize
Needs to be Lua 5.1.x.
If Lua 5.2.x works is unknown.
\end_layout
\begin_layout Itemize \begin_layout Itemize
Usually valid value is 'lua' or 'lua5.1'. Usually valid value is 'lua' or 'lua5.1'.
\end_layout \end_layout
@ -4906,5 +4909,17 @@ Detect revisions.
Wxwidgets: Allow controlling dumper from the menu. Wxwidgets: Allow controlling dumper from the menu.
\end_layout \end_layout
\begin_layout Subsection
rr1-beta5
\end_layout
\begin_layout Itemize
Rewrite parts of manual
\end_layout
\begin_layout Itemize
Lua: Make it work with Lua 5.2.
\end_layout
\end_body \end_body
\end_document \end_document

View file

@ -30,6 +30,10 @@ lsnes is SNES rerecording emulator based on bsnes core.
10. std::thread and co (for threaded dumper only) 10. std::thread and co (for threaded dumper only)
11. Lua (if Lua support is needed).
• Version 5.1.X or 5.2X.
3 Building 3 Building
Building is via makefile, the following options are available: Building is via makefile, the following options are available:
@ -111,8 +115,6 @@ Building is via makefile, the following options are available:
Package to use for Lua support. Package to use for Lua support.
Needs to be Lua 5.1.x. If Lua 5.2.x works is unknown.
Usually valid value is 'lua' or 'lua5.1'. Usually valid value is 'lua' or 'lua5.1'.
Default is not to build Lua support. Default is not to build Lua support.
@ -2379,3 +2381,9 @@ set-axis joystick0axis19 disabled
• Wxwidgets: Allow controlling dumper from the menu. • Wxwidgets: Allow controlling dumper from the menu.
14.34 rr1-beta5
• Rewrite parts of manual
• Lua: Make it work with Lua 5.2.

View file

@ -57,7 +57,7 @@ namespace
void recursive_lookup_table(lua_State* L, const std::string& tab) void recursive_lookup_table(lua_State* L, const std::string& tab)
{ {
if(tab == "") { if(tab == "") {
lua_pushvalue(L, LUA_GLOBALSINDEX); lua_getglobal(L, "_G");
return; return;
} }
std::string u = tab; std::string u = tab;
@ -214,7 +214,12 @@ namespace
{ {
if(recursive_flag) if(recursive_flag)
return; return;
#if LUA_VERSION_NUM == 501
int t = lua_load(L, read_lua_fragment, NULL, "run_lua_fragment"); int t = lua_load(L, read_lua_fragment, NULL, "run_lua_fragment");
#endif
#if LUA_VERSION_NUM == 502
int t = lua_load(L, read_lua_fragment, NULL, "run_lua_fragment", "bt");
#endif
if(t == LUA_ERRSYNTAX) { if(t == LUA_ERRSYNTAX) {
messages << "Can't run Lua: Internal syntax error: " << lua_tostring(L, -1) << std::endl; messages << "Can't run Lua: Internal syntax error: " << lua_tostring(L, -1) << std::endl;
lua_pop(L, 1); lua_pop(L, 1);
@ -294,9 +299,10 @@ namespace
void copy_system_tables(lua_State* L) void copy_system_tables(lua_State* L)
{ {
lua_getglobal(L, "_G");
lua_newtable(L); lua_newtable(L);
lua_pushnil(L); lua_pushnil(L);
while(lua_next(L, LUA_GLOBALSINDEX)) { while(lua_next(L, -3)) {
//Stack: _SYSTEM, KEY, VALUE //Stack: _SYSTEM, KEY, VALUE
lua_pushvalue(L, -2); lua_pushvalue(L, -2);
lua_pushvalue(L, -2); lua_pushvalue(L, -2);