From cd28aa2987b74900f4205aea1368946a2bb70a6c Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 11 Jan 2012 16:41:23 +0200 Subject: [PATCH] Lua: Support Lua 5.2.X too --- VERSION | 2 +- manual.lyx | 25 ++++++++++++++++++++----- manual.txt | 12 ++++++++++-- src/core/lua.cpp | 10 ++++++++-- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index 7d4a7478..9158b8f9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1-β4 +1-β5 diff --git a/manual.lyx b/manual.lyx index 9be252fc..05681557 100644 --- a/manual.lyx +++ b/manual.lyx @@ -125,6 +125,14 @@ Portaudio (portaudio sound only) std::thread and co (for threaded dumper only) \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 Building \end_layout @@ -299,11 +307,6 @@ Package to use for Lua support. \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 Usually valid value is 'lua' or 'lua5.1'. \end_layout @@ -4906,5 +4909,17 @@ Detect revisions. Wxwidgets: Allow controlling dumper from the menu. \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_document diff --git a/manual.txt b/manual.txt index 6e835d47..9482f0d3 100644 --- a/manual.txt +++ b/manual.txt @@ -30,6 +30,10 @@ lsnes is SNES rerecording emulator based on bsnes core. 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 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. - – Needs to be Lua 5.1.x. If Lua 5.2.x works is unknown. - – Usually valid value is 'lua' or 'lua5.1'. – Default is not to build Lua support. @@ -2379,3 +2381,9 @@ set-axis joystick0axis19 disabled • Wxwidgets: Allow controlling dumper from the menu. +14.34 rr1-beta5 + +• Rewrite parts of manual + +• Lua: Make it work with Lua 5.2. + diff --git a/src/core/lua.cpp b/src/core/lua.cpp index bd4f3212..eb76e128 100644 --- a/src/core/lua.cpp +++ b/src/core/lua.cpp @@ -57,7 +57,7 @@ namespace void recursive_lookup_table(lua_State* L, const std::string& tab) { if(tab == "") { - lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_getglobal(L, "_G"); return; } std::string u = tab; @@ -214,7 +214,12 @@ namespace { if(recursive_flag) return; +#if LUA_VERSION_NUM == 501 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) { messages << "Can't run Lua: Internal syntax error: " << lua_tostring(L, -1) << std::endl; lua_pop(L, 1); @@ -294,9 +299,10 @@ namespace void copy_system_tables(lua_State* L) { + lua_getglobal(L, "_G"); lua_newtable(L); lua_pushnil(L); - while(lua_next(L, LUA_GLOBALSINDEX)) { + while(lua_next(L, -3)) { //Stack: _SYSTEM, KEY, VALUE lua_pushvalue(L, -2); lua_pushvalue(L, -2); -- 2.11.4.GIT