lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi!

I have been writing small D module to use Lua scripts with my project. Yesterday I ran in to a problem that I have not been able to solve. I posted the question to stackoverflow:

https://stackoverflow.com/questions/56036831/d-win32-lua-rawgeti-pushes-nil  

Shortly, it seems that on 32-bit Windows, lua_rawgeti() pushes nil to stack. Either luaL_ref() fails to create correct reference, or lua_rawgeti() fails to get correct value. The code in question:

lua_getglobal(L, toStringz("_G"));
int t1 = lua_type(L, -1);
auto r = luaL_ref(L, LUA_REGISTRYINDEX);

lua_rawgeti(L, LUA_REGISTRYINDEX, r);
int t2 = lua_type(L, -1);
On Linux, both t1 and t2 are 5 (table). On 32-bit Windows, t1 = 5 (table), but t2 = 0 (nil).

To see if lua_rawgeti() gets correct value from D caller, I compiled Lua from sources and added printf() to lua_rawgeti() to see what values the reference gets from API user. It ensures that the reference value is correct (both D and Lua say it is 3).

Any ideas what causes this? Any ideas where to look for fixes?