From ac688f9ccbbbaff5ff6d2bd9efb8bd183875f157 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Apr 2012 20:37:39 +0000 Subject: [PATCH] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12985 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/lua/luarun.swg | 9 +++++++++ Lib/lua/luaruntime.swg | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b6bc01ac8..c12f9f6d9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2012-04-14: wsfulton + [Lua] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable + 2012-04-14: wsfulton [Ruby] Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR. diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 31808e82b..af3e7a3af 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -33,6 +33,15 @@ extern "C" { # define lua_rawlen lua_objlen #endif + +/* lua_pushglobaltable is the recommended "future-proof" way to get + the global table for Lua 5.2 and later. Here we define + lua_pushglobaltable ourselves for Lua versions before 5.2. */ +#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 +# define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) +#endif + + /* ----------------------------------------------------------------------------- * global swig types * ----------------------------------------------------------------------------- */ diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg index 9cf6a14a4..0f59b0476 100644 --- a/Lib/lua/luaruntime.swg +++ b/Lib/lua/luaruntime.swg @@ -30,11 +30,7 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */ #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */ int i; /* start with global table */ -#ifdef LUA_RIDX_GLOBALS - lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); -#else - lua_pushvalue(L,LUA_GLOBALSINDEX); -#endif + lua_pushglobaltable (L); /* SWIG's internal initalisation */ SWIG_InitializeModule((void*)L); SWIG_PropagateClientData();