swig/Examples/lua
William S Fulton 294c944c10 [Lua] Restore Lua 5.1 and LuaJIT compatibility for non-director wrapping
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)
2026-07-14 20:15:39 +01:00
..
arrays Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
class Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
constants Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
contract More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
dual Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
embed [Lua] Restore Lua 5.1 and LuaJIT compatibility for non-director wrapping 2026-07-14 20:15:39 +01:00
embed2 Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
embed3 Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
enum More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
exception Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
funcptr More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
funcptr3 Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
functest Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
functor Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
import Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
import_template More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
nspace Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
operator More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
overloading More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
owner Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
pointer Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
reference More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
simple Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
smartptr More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
std_vector More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
template More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
value More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
variables Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00
check.list More Lua tests (#3405) 2026-05-31 15:09:53 +01:00
lua.c Remove Lua 5.0 and Lua 5.1 and Lua options 2026-05-30 17:24:17 +01:00