mirror of https://github.com/swig/swig.git
the new Lua directors feature uses lua_setuservalue, added in Lua 5.2. Removing the LUA_VERSION_NUM-guarded compatibility defines for lua_rawlen, lua_pushglobaltable and lua_rawsetp/lua_rawgetp from Lib/lua/luarun.swg. LuaJIT implements the Lua 5.1 API and, per its own documentation, is "API+ABI-compatible with Lua 5.1, which prevents implementing features that would otherwise break the Lua/C API and ABI" (https://luajit.org/extensions.html, "Extensions from Lua 5.2" section) - so it never defines these Lua 5.2 additions. Noticed when rebuilding obs-studio's LuaJIT-based Lua bindings against SWIG master. Restore those compatibility defines, scoped to 5.1 and later only (the old Lua 5.0-only shims are not restored). Also revert an incidental ok!=LUA_OK comparison introduced by #3394 back to ok!=0, since LUA_OK isn't defined pre-5.2 either and luaL_dostring() already returns 0 on success on every Lua version. Fix the examples and test-suite where they themselves used Lua 5.2 only features: LUA_OK in Examples/lua/embed/embed.c, _ENV in helpers.lua, and string.format("%c", ...) in li_cdata_bytes, which yields an empty string for a NUL byte in Lua 5.1 as strlen() is applied to the formatted result, so string.char() is used instead. Directors continue to require Lua 5.2 or later and are unaffected by this change; the Lua 5.1 director test failures are addressed separately. Assisted-by: Claude Code (Sonnet 5) |
||
|---|---|---|
| .. | ||
| Makefile | ||
| embed.c | ||
| example.c | ||
| example.i | ||
| runme.lua | ||