swig/Examples/lua/embed
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
..
Makefile Remove use of preinst-swig script 2015-08-21 22:43:17 +01:00
embed.c [Lua] Restore Lua 5.1 and LuaJIT compatibility for non-director wrapping 2026-07-14 20:15:39 +01:00
example.c Convert to unix fileformat 2013-01-12 16:54:45 +00:00
example.i [lua] Fix a bug in the class hierachy code, where the methods were not propagated, 2007-12-04 09:25:58 +00:00
runme.lua Fix typos 2014-04-29 11:31:29 +12:00