Closed LesNewell-SheetCam closed 4 years ago
@sheetcam, what's the actual error you are getting? There is no luaL_register
in lua 5.2 unless you turn the compatibility settings on, so the change may not work in some of the cases.
I think the following patch should work with both Lua 5.2 and Lua 5.3:
diff --git a/wxLua/modules/wxlua/bit.c b/wxLua/modules/wxlua/bit.c
index 1c37f86..377d544 100644
--- a/wxLua/modules/wxlua/bit.c
+++ b/wxLua/modules/wxlua/bit.c
@@ -177,7 +177,8 @@ static int libsize (const luaL_Reg *l) {
static void pushmodule (lua_State *L, const char *modname, int sizehint) {
lua_pushglobaltable(L);
lua_pushstring(L, modname);
- if (lua_rawget(L, -2) != LUA_TNIL) { /* no such field? */
+ lua_rawget(L, -2);
+ if (!lua_isnil(L, -1)) {
luaL_error(L, "name conflict for module '%s'", modname);
}
lua_pop(L, 1); /* remove this nil */
Can you apply it and let me know?
I just built wxWidgets 3.1.3 with 2.8 compatibility enabled then used the cmake defaults apart from setting the Lua version to 5.2 and the build type to MinSizeRel. Your change appears to build. I'll run some more tests later.
@sheetcam, sounds good. I pushed the changes, but let me know if you run into any issues.
If you try to build for Lua5.2 the build fails in bit.c, line 180. It expects a return value from lua_rawget but lua_rawget does not return a value in 5.2. This appears to only be available in 5.3+ I have attached a diff to fix the issue (bit.c.txt):