diff --git a/.gitattributes b/.gitattributes index 9b03811..a9bfeea 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,3 +21,4 @@ *.xz filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text +*.changes merge=merge-changes diff --git a/.gitignore b/.gitignore index 57affb6..a33e773 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ .osc +*.obscpio +*.osc +_build.* +.pbuild +lua*-toluapp-*-build/ diff --git a/tolua++-1.0.93-lua52.patch b/lua-compatibility.patch similarity index 63% rename from tolua++-1.0.93-lua52.patch rename to lua-compatibility.patch index c0dc13e..59a8f0c 100644 --- a/tolua++-1.0.93-lua52.patch +++ b/lua-compatibility.patch @@ -1,7 +1,44 @@ +--- + SConstruct | 2 ++ + config_linux.py | 4 ++-- + config_posix.py | 2 +- + include/tolua++.h | 7 +++++-- + src/bin/SCsub | 4 ++-- + src/bin/lua/all.lua | 2 +- + src/bin/lua/basic.lua | 20 ++++++++++++-------- + src/bin/lua/class.lua | 6 +++--- + src/bin/lua/clean.lua | 4 ++-- + src/bin/lua/compat-5.1.lua | 6 +++--- + src/bin/lua/compat.lua | 13 ++++++++----- + src/bin/lua/declaration.lua | 4 ++-- + src/bin/lua/feature.lua | 2 +- + src/bin/lua/function.lua | 2 +- + src/bin/lua/package.lua | 20 ++++++++++---------- + src/bin/lua/template_class.lua | 8 ++++---- + src/bin/tolua.c | 27 ++++++++++++++++----------- + src/lib/tolua_event.c | 18 +++++++++++++++++- + src/lib/tolua_is.c | 2 +- + src/lib/tolua_map.c | 35 ++++++++++++++++++++++------------- + src/lib/tolua_push.c | 6 ++++-- + 21 files changed, 119 insertions(+), 75 deletions(-) + +Index: toluapp-1.0.93/SConstruct +=================================================================== +--- toluapp-1.0.93.orig/SConstruct 2025-10-13 18:34:10.155194536 +0200 ++++ toluapp-1.0.93/SConstruct 2025-10-13 18:34:11.251071137 +0200 +@@ -89,6 +89,8 @@ + header = target[:-2] + '.h' + pheader = Dir('.').path + '/' + header + ++ print("Generating ", target, " from ", source) ++ + tolua = "" + if bootstrap: + if os.name == 'nt': Index: toluapp-1.0.93/config_linux.py =================================================================== ---- toluapp-1.0.93.orig/config_linux.py -+++ toluapp-1.0.93/config_linux.py +--- toluapp-1.0.93.orig/config_linux.py 2012-08-24 03:01:53.000000000 +0200 ++++ toluapp-1.0.93/config_linux.py 2025-10-13 18:34:11.251503108 +0200 @@ -4,7 +4,7 @@ # Compiler flags (based on Debian's installation of lua) @@ -11,30 +48,65 @@ Index: toluapp-1.0.93/config_linux.py #CCFLAGS = ['-I/usr/include/lua50', '-g'] # this is the default directory for installation. Files will be installed on -@@ -18,5 +18,5 @@ CCFLAGS = ['-I/usr/include/lua50', '-O2' +@@ -18,5 +18,5 @@ prefix = '/usr/local' # libraries (based on Debian's installation of lua) -LIBS = ['lua50', 'lualib50', 'dl', 'm'] +LIBS = ['lua', 'dl', 'm'] -Index: toluapp-1.0.93/SConstruct +Index: toluapp-1.0.93/config_posix.py =================================================================== ---- toluapp-1.0.93.orig/SConstruct -+++ toluapp-1.0.93/SConstruct -@@ -85,6 +85,8 @@ def make_tolua_code(self, target, source - header = target[:-2] + '.h' - pheader = Dir('.').path + '/' + header +--- toluapp-1.0.93.orig/config_posix.py 2012-08-24 03:01:53.000000000 +0200 ++++ toluapp-1.0.93/config_posix.py 2025-10-13 18:34:11.251778425 +0200 +@@ -16,7 +16,7 @@ + prefix = '/usr/local' -+ print("Generating ", target, " from ", source) + # libraries +-LIBS = ['lua', 'lualib', 'm'] ++LIBS = ['lua', 'm'] + + + +Index: toluapp-1.0.93/include/tolua++.h +=================================================================== +--- toluapp-1.0.93.orig/include/tolua++.h 2012-08-24 03:01:53.000000000 +0200 ++++ toluapp-1.0.93/include/tolua++.h 2025-10-13 18:34:11.252055068 +0200 +@@ -46,10 +46,13 @@ + #include "lua.h" + #include "lauxlib.h" + ++#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 ++# define luaL_getn(L, i) ((int)lua_objlen(L, i)) ++#endif + - tolua = "" - if bootstrap: - if os.name == 'nt': + struct tolua_Error + { +- int index; +- int array; ++ int index; int array; + const char* type; + }; + typedef struct tolua_Error tolua_Error; +Index: toluapp-1.0.93/src/bin/SCsub +=================================================================== +--- toluapp-1.0.93.orig/src/bin/SCsub 2012-08-24 03:01:53.000000000 +0200 ++++ toluapp-1.0.93/src/bin/SCsub 2025-10-13 18:34:11.252301470 +0200 +@@ -5,8 +5,8 @@ + ] + + +-toluabind = env.LuaBinding('toluabind.c', 'tolua_scons.pkg', 'tolua', bootstrap = True) ++#toluabind = env.LuaBinding('toluabind.c', 'tolua_scons.pkg', 'tolua', bootstrap = True) + +-env.bin_target = env.Program('#/bin/'+env['tolua_bin'], src + [toluabind], LIBS = ['$tolua_lib'] + env['LIBS']) ++env.bin_target = env.Program('#/bin/'+env['tolua_bin'], src, LIBS = ['$tolua_lib'] + env['LIBS']) + + env.bootstrap_target = env.Program('#/bin/'+env['TOLUAPP_BOOTSTRAP'], src + ['toluabind_default.c', env.lib_target_static], LIBS = env['LIBS']) Index: toluapp-1.0.93/src/bin/lua/all.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/all.lua -+++ toluapp-1.0.93/src/bin/lua/all.lua +--- toluapp-1.0.93.orig/src/bin/lua/all.lua 2025-10-13 18:33:57.203290200 +0200 ++++ toluapp-1.0.93/src/bin/lua/all.lua 2025-10-13 18:34:11.252570501 +0200 @@ -1,8 +1,8 @@ dofile(path.."compat-5.1.lua") dofile(path.."compat.lua") @@ -47,9 +119,19 @@ Index: toluapp-1.0.93/src/bin/lua/all.lua dofile(path.."container.lua") Index: toluapp-1.0.93/src/bin/lua/basic.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/basic.lua -+++ toluapp-1.0.93/src/bin/lua/basic.lua -@@ -75,8 +75,8 @@ function appendrenaming (s) +--- toluapp-1.0.93.orig/src/bin/lua/basic.lua 2025-10-13 18:33:57.203847677 +0200 ++++ toluapp-1.0.93/src/bin/lua/basic.lua 2025-10-13 18:34:11.252831080 +0200 +@@ -10,7 +10,8 @@ + -- the author has no obligation to provide maintenance, support, updates, + -- enhancements, or modifications. + +- ++-- Compatibility shim ++local unpack = table.unpack or unpack + -- Basic C types and their corresponding Lua types + -- All occurrences of "char*" will be replaced by "_cstring", + -- and all occurrences of "void*" will be replaced by "_userdata" +@@ -75,8 +76,8 @@ end function applyrenaming (s) @@ -60,7 +142,7 @@ Index: toluapp-1.0.93/src/bin/lua/basic.lua if n ~= 0 then return m end -@@ -252,7 +252,8 @@ end +@@ -252,7 +253,8 @@ -- concatenate all parameters, following output rules function concatparam (line, ...) local i=1 @@ -70,7 +152,7 @@ Index: toluapp-1.0.93/src/bin/lua/basic.lua if _cont and not strfind(_cont,'[%(,"]') and strfind(arg[i],"^[%a_~]") then line = line .. ' ' -@@ -263,7 +264,7 @@ function concatparam (line, ...) +@@ -263,7 +265,7 @@ end i = i+1 end @@ -79,7 +161,7 @@ Index: toluapp-1.0.93/src/bin/lua/basic.lua _cont=nil line = line .. '\n' end return line -@@ -272,7 +273,8 @@ end +@@ -272,7 +274,8 @@ -- output line function output (...) local i=1 @@ -89,7 +171,7 @@ Index: toluapp-1.0.93/src/bin/lua/basic.lua if _cont and not strfind(_cont,'[%(,"]') and strfind(arg[i],"^[%a_~]") then write(' ') -@@ -283,7 +285,7 @@ function output (...) +@@ -283,7 +286,7 @@ end i = i+1 end @@ -98,7 +180,7 @@ Index: toluapp-1.0.93/src/bin/lua/basic.lua _cont=nil write('\n') end end -@@ -373,9 +375,10 @@ function pre_register_hook(package) +@@ -373,9 +376,10 @@ end @@ -106,15 +188,15 @@ Index: toluapp-1.0.93/src/bin/lua/basic.lua -- called to output an error message function output_error_hook(...) - return string.format(...) -+ return string.format(table.unpack{...}) ++ return string.format(unpack{...}) end -- custom pushers Index: toluapp-1.0.93/src/bin/lua/class.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/class.lua -+++ toluapp-1.0.93/src/bin/lua/class.lua -@@ -92,7 +92,7 @@ function classClass:decltype () +--- toluapp-1.0.93.orig/src/bin/lua/class.lua 2025-10-13 18:33:57.204120828 +0200 ++++ toluapp-1.0.93/src/bin/lua/class.lua 2025-10-13 18:34:11.253061558 +0200 +@@ -92,7 +92,7 @@ self.btype = typevar(self.base) self.ctype = 'const '..self.type if self.extra_bases then @@ -123,7 +205,7 @@ Index: toluapp-1.0.93/src/bin/lua/class.lua self.extra_bases[i] = typevar(self.extra_bases[i]) end end -@@ -138,9 +138,9 @@ end +@@ -138,9 +138,9 @@ -- Expects the name, the base (array) and the body of the class. function Class (n,p,b) @@ -137,9 +219,9 @@ Index: toluapp-1.0.93/src/bin/lua/class.lua b = b.."\n}" Index: toluapp-1.0.93/src/bin/lua/clean.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/clean.lua -+++ toluapp-1.0.93/src/bin/lua/clean.lua -@@ -19,14 +19,14 @@ MASK = { -- the substitution order is im +--- toluapp-1.0.93.orig/src/bin/lua/clean.lua 2025-10-13 18:33:57.204330493 +0200 ++++ toluapp-1.0.93/src/bin/lua/clean.lua 2025-10-13 18:34:11.253247337 +0200 +@@ -19,14 +19,14 @@ } function mask (s) @@ -158,26 +240,27 @@ Index: toluapp-1.0.93/src/bin/lua/clean.lua return s Index: toluapp-1.0.93/src/bin/lua/compat-5.1.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/compat-5.1.lua -+++ toluapp-1.0.93/src/bin/lua/compat-5.1.lua -@@ -25,10 +25,10 @@ local function pp_dofile(path) - end - end - -- local f = load(getfile, path) -+ local f, errmsg = load(getfile, path) - if not f then - -- error("error loading file "..path) -+ error("error loading file "..path ..": " .. errmsg) - end - return f() - end +--- toluapp-1.0.93.orig/src/bin/lua/compat-5.1.lua 2025-10-13 18:33:57.204792497 +0200 ++++ toluapp-1.0.93/src/bin/lua/compat-5.1.lua 2025-10-13 18:34:11.253449110 +0200 +@@ -25,10 +25,10 @@ + end + end + +- local f = load(getfile, path) ++ local f, errmsg = load(getfile, path) + if not f then +- +- error("error loading file "..path) ++ ++ error("error loading file "..path ..": " .. errmsg) + end + return f() + end Index: toluapp-1.0.93/src/bin/lua/compat.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/compat.lua -+++ toluapp-1.0.93/src/bin/lua/compat.lua -@@ -40,15 +40,13 @@ function do_ (f, err) +--- toluapp-1.0.93.orig/src/bin/lua/compat.lua 2025-10-13 18:33:57.204992803 +0200 ++++ toluapp-1.0.93/src/bin/lua/compat.lua 2025-10-13 18:34:11.253523003 +0200 +@@ -40,18 +40,17 @@ end end @@ -195,16 +278,22 @@ Index: toluapp-1.0.93/src/bin/lua/compat.lua tinsert = tab.insert tremove = tab.remove sort = tab.sort -@@ -78,7 +76,7 @@ floor = math.floor ++unpack = table.unpack or unpack + + ------------------------------------------------------------------- + -- Debug library +@@ -78,7 +77,9 @@ frexp = math.frexp ldexp = math.ldexp log = math.log -log10 = math.log10 -+log10 = function(val) return math.log(10, val) end ++-- Lua PCU 5.1 math.log doesn’t read the second argument ++-- and it is ONLY the natural logarithm ++log10 = function(val) return math.log(val) / math.log(10) end max = math.max min = math.min mod = math.mod -@@ -177,17 +175,19 @@ end +@@ -177,6 +178,7 @@ function read (...) local f = _INPUT @@ -212,9 +301,7 @@ Index: toluapp-1.0.93/src/bin/lua/compat.lua if rawtype(arg[1]) == 'userdata' then f = tab.remove(arg, 1) end -- return f:read(unpack(arg)) -+ return f:read(table.unpack(arg)) - end +@@ -185,6 +187,7 @@ function write (...) local f = _OUTPUT @@ -222,15 +309,11 @@ Index: toluapp-1.0.93/src/bin/lua/compat.lua if rawtype(arg[1]) == 'userdata' then f = tab.remove(arg, 1) end -- return f:write(unpack(arg)) -+ return f:write(table.unpack(arg)) - end - Index: toluapp-1.0.93/src/bin/lua/declaration.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/declaration.lua -+++ toluapp-1.0.93/src/bin/lua/declaration.lua -@@ -137,7 +137,7 @@ function resolve_template_types(type) +--- toluapp-1.0.93.orig/src/bin/lua/declaration.lua 2025-10-13 18:33:57.205763647 +0200 ++++ toluapp-1.0.93/src/bin/lua/declaration.lua 2025-10-13 18:34:11.253903711 +0200 +@@ -137,7 +137,7 @@ if b then m = split_c_tokens(string.sub(m, 2, -2), ",") @@ -239,7 +322,7 @@ Index: toluapp-1.0.93/src/bin/lua/declaration.lua m[i] = string.gsub(m[i],"%s*([%*&])", "%1") if not isbasic(m[i]) then if not isenum(m[i]) then _, m[i] = applytypedef("", m[i]) end -@@ -522,7 +522,7 @@ function Declaration (s,kind,is_paramete +@@ -522,7 +522,7 @@ end -- check the form: mod type* name @@ -250,9 +333,9 @@ Index: toluapp-1.0.93/src/bin/lua/declaration.lua t[2] = gsub(t[2],'\1','%*') -- restore * in dimension expression Index: toluapp-1.0.93/src/bin/lua/feature.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/feature.lua -+++ toluapp-1.0.93/src/bin/lua/feature.lua -@@ -132,7 +132,7 @@ function classFeature:cfuncname (n) +--- toluapp-1.0.93.orig/src/bin/lua/feature.lua 2025-10-13 18:33:57.206592460 +0200 ++++ toluapp-1.0.93/src/bin/lua/feature.lua 2025-10-13 18:34:11.254122316 +0200 +@@ -132,7 +132,7 @@ if not fname or fname == '' then fname = self.name end @@ -263,9 +346,9 @@ Index: toluapp-1.0.93/src/bin/lua/feature.lua end Index: toluapp-1.0.93/src/bin/lua/function.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/function.lua -+++ toluapp-1.0.93/src/bin/lua/function.lua -@@ -520,7 +520,7 @@ end +--- toluapp-1.0.93.orig/src/bin/lua/function.lua 2025-10-13 18:33:57.206794233 +0200 ++++ toluapp-1.0.93/src/bin/lua/function.lua 2025-10-13 18:34:11.254306698 +0200 +@@ -520,7 +520,7 @@ function join(t, sep, first, last) first = first or 1 @@ -276,9 +359,19 @@ Index: toluapp-1.0.93/src/bin/lua/function.lua local loop = false Index: toluapp-1.0.93/src/bin/lua/package.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/package.lua -+++ toluapp-1.0.93/src/bin/lua/package.lua -@@ -39,7 +39,7 @@ function classPackage:preprocess () +--- toluapp-1.0.93.orig/src/bin/lua/package.lua 2025-10-13 18:34:08.677254902 +0200 ++++ toluapp-1.0.93/src/bin/lua/package.lua 2025-10-13 18:34:11.254530681 +0200 +@@ -9,7 +9,8 @@ + -- the author has no obligation to provide maintenance, support, updates, + -- enhancements, or modifications. + +- ++-- Compatibility shim ++local unpack = table.unpack or unpack + + -- Package class + -- Represents the whole package being bound. +@@ -39,7 +40,7 @@ self.code = gsub(self.code,"\n%s*%$%]","\2") self.code = gsub(self.code,"(%b\1\2)", function (c) tinsert(L,c) @@ -287,7 +380,7 @@ Index: toluapp-1.0.93/src/bin/lua/package.lua end) -- avoid preprocessing embedded C code local C = {} -@@ -47,14 +47,14 @@ function classPackage:preprocess () +@@ -47,14 +48,14 @@ self.code = gsub(self.code,"\n%s*%$%>","\4") self.code = gsub(self.code,"(%b\3\4)", function (c) tinsert(C,c) @@ -304,7 +397,7 @@ Index: toluapp-1.0.93/src/bin/lua/package.lua end) --self.code = gsub(self.code,"\n%s*#[^d][^\n]*\n", "\n\n") -- eliminate preprocessor directives that don't start with 'd' -@@ -64,7 +64,7 @@ function classPackage:preprocess () +@@ -64,7 +65,7 @@ local V = {} self.code = gsub(self.code,"\n(%s*%$[^%[%]][^\n]*)",function (v) tinsert(V,v) @@ -313,7 +406,7 @@ Index: toluapp-1.0.93/src/bin/lua/package.lua end) -- perform global substitution -@@ -152,14 +152,14 @@ function classPackage:preamble () +@@ -152,14 +153,14 @@ if flags.t then output("#ifndef Mtolua_typeid\n#define Mtolua_typeid(L,TI,T)\n#endif\n") end @@ -330,25 +423,16 @@ Index: toluapp-1.0.93/src/bin/lua/package.lua output('}') output('\n') end -@@ -288,7 +288,7 @@ function Package (name,fn) - local t = {code=s} - extra = string.gsub(extra, "^%s*,%s*", "") - local pars = split_c_tokens(extra, ",") -- include_file_hook(t, fn, unpack(pars)) -+ include_file_hook(t, fn, table.unpack(pars)) - return "\n\n" .. t.code - else - error('#Invalid include directive (use $cfile, $pfile, $lfile or $ifile)') -@@ -322,7 +322,7 @@ function prep(file) +@@ -322,7 +323,7 @@ table.insert(chunk, string.sub(line, 3) .. "\n") else local last = 1 - for text, expr, index in string.gfind(line, "(.-)$(%b())()") do -+ for text, expr, index in string.gmatch(line, "(.-)$(%b())()") do ++ for text, expr, index in string.gmatch(line, "(.-)$(%b())()") do last = index if text ~= "" then table.insert(chunk, string.format('table.insert(__ret, %q )', text)) -@@ -334,10 +334,9 @@ function prep(file) +@@ -334,10 +335,9 @@ end end table.insert(chunk, '\nreturn table.concat(__ret)\n') @@ -362,9 +446,9 @@ Index: toluapp-1.0.93/src/bin/lua/package.lua end Index: toluapp-1.0.93/src/bin/lua/template_class.lua =================================================================== ---- toluapp-1.0.93.orig/src/bin/lua/template_class.lua -+++ toluapp-1.0.93/src/bin/lua/template_class.lua -@@ -22,7 +22,7 @@ function classTemplateClass:throw(types, +--- toluapp-1.0.93.orig/src/bin/lua/template_class.lua 2025-10-13 18:33:57.207900876 +0200 ++++ toluapp-1.0.93/src/bin/lua/template_class.lua 2025-10-13 18:34:11.254772613 +0200 +@@ -22,7 +22,7 @@ for i =1 , types.n do local Il = split_c_tokens(types[i], " ") @@ -373,7 +457,7 @@ Index: toluapp-1.0.93/src/bin/lua/template_class.lua error("#invalid parameter count for "..types[i]) end local bI = self.body -@@ -31,16 +31,16 @@ function classTemplateClass:throw(types, +@@ -31,16 +31,16 @@ --Tl[j] = findtype(Tl[j]) or Tl[j] bI = string.gsub(bI, "([^_%w])"..self.args[j].."([^_%w])", "%1"..Il[j].."%2") if self.parents then @@ -395,9 +479,9 @@ Index: toluapp-1.0.93/src/bin/lua/template_class.lua end Index: toluapp-1.0.93/src/bin/tolua.c =================================================================== ---- toluapp-1.0.93.orig/src/bin/tolua.c -+++ toluapp-1.0.93/src/bin/tolua.c -@@ -67,7 +67,11 @@ static void setfield (lua_State* L, int +--- toluapp-1.0.93.orig/src/bin/tolua.c 2012-08-24 03:01:53.000000000 +0200 ++++ toluapp-1.0.93/src/bin/tolua.c 2025-10-13 18:34:11.254974106 +0200 +@@ -67,7 +67,11 @@ static void add_extra (lua_State* L, char* value) { int len; lua_getglobal(L, "_extra_parameters"); @@ -409,7 +493,7 @@ Index: toluapp-1.0.93/src/bin/tolua.c lua_pushstring(L, value); lua_rawseti(L, -2, len+1); lua_pop(L, 1); -@@ -145,7 +149,7 @@ int main (int argc, char* argv[]) +@@ -145,7 +149,7 @@ } lua_pop(L,1); } @@ -418,7 +502,7 @@ Index: toluapp-1.0.93/src/bin/tolua.c #ifndef TOLUA_SCRIPT_RUN { int tolua_tolua_open (lua_State* L); -@@ -153,16 +157,17 @@ int main (int argc, char* argv[]) +@@ -153,16 +157,17 @@ } #else { @@ -448,8 +532,8 @@ Index: toluapp-1.0.93/src/bin/tolua.c return 0; Index: toluapp-1.0.93/src/lib/tolua_event.c =================================================================== ---- toluapp-1.0.93.orig/src/lib/tolua_event.c -+++ toluapp-1.0.93/src/lib/tolua_event.c +--- toluapp-1.0.93.orig/src/lib/tolua_event.c 2012-08-24 03:01:53.000000000 +0200 ++++ toluapp-1.0.93/src/lib/tolua_event.c 2025-10-13 18:34:11.255204095 +0200 @@ -23,12 +23,20 @@ static void storeatubox (lua_State* L, int lo) { @@ -471,7 +555,7 @@ Index: toluapp-1.0.93/src/lib/tolua_event.c }; lua_insert(L, -3); lua_settable(L, -3); /* on lua 5.1, we trade the "tolua_peers" lookup for a settable call */ -@@ -141,7 +149,11 @@ static int class_index_event (lua_State* +@@ -141,7 +149,11 @@ { /* Access alternative table */ #ifdef LUA_VERSION_NUM /* new macro on version 5.1 */ @@ -483,7 +567,7 @@ Index: toluapp-1.0.93/src/lib/tolua_event.c if (!lua_rawequal(L, -1, TOLUA_NOPEER)) { lua_pushvalue(L, 2); /* key */ lua_gettable(L, -2); /* on lua 5.1, we trade the "tolua_peers" lookup for a gettable call */ -@@ -420,6 +432,8 @@ static int class_gc_event (lua_State* L) +@@ -420,6 +432,8 @@ */ TOLUA_API int class_gc_event (lua_State* L) { @@ -492,7 +576,7 @@ Index: toluapp-1.0.93/src/lib/tolua_event.c void* u = *((void**)lua_touserdata(L,1)); int top; /*fprintf(stderr, "collecting: looking at %p\n", u);*/ -@@ -427,7 +441,8 @@ TOLUA_API int class_gc_event (lua_State* +@@ -427,7 +441,8 @@ lua_pushstring(L,"tolua_gc"); lua_rawget(L,LUA_REGISTRYINDEX); */ @@ -502,7 +586,7 @@ Index: toluapp-1.0.93/src/lib/tolua_event.c lua_pushlightuserdata(L,u); lua_rawget(L,-2); /* stack: gc umt */ lua_getmetatable(L,1); /* stack: gc umt mt */ -@@ -456,6 +471,7 @@ TOLUA_API int class_gc_event (lua_State* +@@ -456,6 +471,7 @@ lua_rawset(L,-5); /* stack: gc umt mt */ } lua_pop(L,3); @@ -510,11 +594,33 @@ Index: toluapp-1.0.93/src/lib/tolua_event.c return 0; } +Index: toluapp-1.0.93/src/lib/tolua_is.c +=================================================================== +--- toluapp-1.0.93.orig/src/lib/tolua_is.c 2012-08-24 03:01:53.000000000 +0200 ++++ toluapp-1.0.93/src/lib/tolua_is.c 2025-10-13 18:34:11.255501901 +0200 +@@ -116,7 +116,7 @@ + } + + /* the equivalent of lua_is* for usertable */ +-static int lua_isusertable (lua_State* L, int lo, const const char* type) ++static int lua_isusertable (lua_State* L, int lo, const char* type) + { + int r = 0; + if (lo < 0) lo = lua_gettop(L)+lo+1; Index: toluapp-1.0.93/src/lib/tolua_map.c =================================================================== ---- toluapp-1.0.93.orig/src/lib/tolua_map.c -+++ toluapp-1.0.93/src/lib/tolua_map.c -@@ -262,8 +262,12 @@ static int tolua_bnd_setpeer(lua_State* +--- toluapp-1.0.93.orig/src/lib/tolua_map.c 2012-08-24 03:01:53.000000000 +0200 ++++ toluapp-1.0.93/src/lib/tolua_map.c 2025-10-13 18:34:11.255740969 +0200 +@@ -25,7 +25,7 @@ + /* Create metatable + * Create and register new metatable + */ +-static int tolua_newmetatable (lua_State* L, char* name) ++static int tolua_newmetatable (lua_State* L, const char* name) + { + int r = luaL_newmetatable(L,name); + +@@ -262,8 +262,12 @@ lua_pop(L, 1); lua_pushvalue(L, TOLUA_NOPEER); @@ -528,7 +634,7 @@ Index: toluapp-1.0.93/src/lib/tolua_map.c return 0; }; -@@ -271,7 +275,11 @@ static int tolua_bnd_setpeer(lua_State* +@@ -271,7 +275,11 @@ static int tolua_bnd_getpeer(lua_State* L) { /* stack: userdata */ @@ -540,7 +646,34 @@ Index: toluapp-1.0.93/src/lib/tolua_map.c if (lua_rawequal(L, -1, TOLUA_NOPEER)) { lua_pop(L, 1); lua_pushnil(L); -@@ -411,7 +419,11 @@ TOLUA_API void tolua_beginmodule (lua_St +@@ -291,15 +299,6 @@ + { + lua_pushstring(L,"tolua_opened"); lua_pushboolean(L,1); lua_rawset(L,LUA_REGISTRYINDEX); + +- #ifndef LUA_VERSION_NUM /* only prior to lua 5.1 */ +- /* create peer object table */ +- lua_pushstring(L, "tolua_peers"); lua_newtable(L); +- /* make weak key metatable for peers indexed by userdata object */ +- lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "k"); lua_rawset(L, -3); /* stack: string peers mt */ +- lua_setmetatable(L, -2); /* stack: string peers */ +- lua_rawset(L,LUA_REGISTRYINDEX); +- #endif +- + /* create object ptr -> udata mapping table */ + lua_pushstring(L,"tolua_ubox"); lua_newtable(L); + /* make weak value metatable for ubox table to allow userdata to be +@@ -331,10 +330,8 @@ + tolua_function(L,"releaseownership",tolua_bnd_releaseownership); + tolua_function(L,"cast",tolua_bnd_cast); + tolua_function(L,"inherit", tolua_bnd_inherit); +- #ifdef LUA_VERSION_NUM /* lua 5.1 */ + tolua_function(L, "setpeer", tolua_bnd_setpeer); + tolua_function(L, "getpeer", tolua_bnd_getpeer); +- #endif + + tolua_endmodule(L); + tolua_endmodule(L); +@@ -411,7 +408,11 @@ lua_rawget(L,-2); } else @@ -552,7 +685,7 @@ Index: toluapp-1.0.93/src/lib/tolua_map.c } /* End module -@@ -445,7 +457,11 @@ TOLUA_API void tolua_module (lua_State* +@@ -445,7 +446,11 @@ else { /* global table */ @@ -564,7 +697,7 @@ Index: toluapp-1.0.93/src/lib/tolua_map.c } if (hasvar) { -@@ -473,7 +489,11 @@ TOLUA_API void tolua_module (lua_State* +@@ -473,7 +478,11 @@ else { /* global table */ @@ -578,32 +711,20 @@ Index: toluapp-1.0.93/src/lib/tolua_map.c { Index: toluapp-1.0.93/src/lib/tolua_push.c =================================================================== ---- toluapp-1.0.93.orig/src/lib/tolua_push.c -+++ toluapp-1.0.93/src/lib/tolua_push.c -@@ -79,7 +79,11 @@ TOLUA_API void tolua_pushusertype (lua_S +--- toluapp-1.0.93.orig/src/lib/tolua_push.c 2012-08-24 03:01:53.000000000 +0200 ++++ toluapp-1.0.93/src/lib/tolua_push.c 2025-10-13 18:34:11.255991352 +0200 +@@ -77,10 +77,12 @@ + lua_pushvalue(L, -2); /* stack: mt newud mt */ + lua_setmetatable(L,-2); /* stack: mt newud */ - #ifdef LUA_VERSION_NUM +- #ifdef LUA_VERSION_NUM lua_pushvalue(L, TOLUA_NOPEER); +#if LUA_VERSION_NUM > 501 + lua_setuservalue(L, -2); +#else lua_setfenv(L, -2); +- #endif +#endif - #endif } else -Index: toluapp-1.0.93/src/bin/SCsub -=================================================================== ---- toluapp-1.0.93.orig/src/bin/SCsub -+++ toluapp-1.0.93/src/bin/SCsub -@@ -5,8 +5,8 @@ src = [ - ] - - --toluabind = env.LuaBinding('toluabind.c', 'tolua_scons.pkg', 'tolua', bootstrap = True) -+#toluabind = env.LuaBinding('toluabind.c', 'tolua_scons.pkg', 'tolua', bootstrap = True) - --env.bin_target = env.Program('#/bin/'+env['tolua_bin'], src + [toluabind], LIBS = ['$tolua_lib'] + env['LIBS']) -+env.bin_target = env.Program('#/bin/'+env['tolua_bin'], src, LIBS = ['$tolua_lib'] + env['LIBS']) - - env.bootstrap_target = env.Program('#/bin/'+env['TOLUAPP_BOOTSTRAP'], src + ['toluabind_default.c', env.lib_target_static], LIBS = env['LIBS']) + { diff --git a/lua-toluapp.changes b/lua-toluapp.changes index e3f1641..8d155b5 100644 --- a/lua-toluapp.changes +++ b/lua-toluapp.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon Oct 13 14:10:09 UTC 2025 - Matej Cepl + +- Make the package buildable with LuaJIT. +- Add lua-compatibility.patch to cover for the incompatibilities. +- Remove tolua++-1.0.93-lua52.patch which has been folded into + the previous patch. + ------------------------------------------------------------------- Thu Feb 22 09:54:05 UTC 2024 - Michael Vetter diff --git a/lua-toluapp.spec b/lua-toluapp.spec index f820c93..251504c 100644 --- a/lua-toluapp.spec +++ b/lua-toluapp.spec @@ -19,8 +19,12 @@ %define flavor @BUILD_FLAVOR@ %define mod_name toluapp %define lua_suffix %(lua -e 'print(_VERSION)' | cut -d ' ' -f 2 |sed -e 's:\.:_:') +%if "%{flavor}" == "luajit" +%define lua_value 52 +%else %define lua_value %(echo "%{flavor}" |sed -e 's:lua::') -%if "%{flavor}" == "lua51" +%endif +%if "%{flavor}" == "lua51" || "%{flavor}" == "luajit" %define lua_suffix 5_1 %endif %if "%{flavor}" == "lua52" @@ -40,14 +44,16 @@ Group: Development/Languages/Other URL: https://github.com/LuaDist/toluapp Source: https://github.com/LuaDist/toluapp/archive/%{version}/toluapp-%{version}.tar.gz Patch0: toluapp-libdir.patch -Patch1: toluapp-versioned-shared-lib.patch -Patch2: toluapp-build-compare.patch -Patch3: tolua++-1.0.93-lua52.patch -Patch4: toluapp-scons-py3.patch +Patch1: toluapp-scons-py3.patch +Patch2: toluapp-versioned-shared-lib.patch +Patch3: toluapp-build-compare.patch +#PATCH-FIX-OPENSUSE mlin@suse.com - scons env.Copy() has been deprecated, use env.Clone() instead if needed +Patch4: toluapp-fix-deprecared-env-copy.patch #PATCH-FIX-UPSTREAM marguerite@opensuse.org - scons Options() is deprecated in 0.98.1, use Variables() instead Patch5: scons-0.98.1-Options-deprecated.patch -#PATCH-FIX-OPENSUSE mlin@suse.com - scons env.Copy() has been deprecated, use env.Clone() instead if needed -Patch6: toluapp-fix-deprecared-env-copy.patch +# PATCH-FIX-UPSTREAM lua-compatibility.patch bsc#[0-9]+ mcepl@suse.com +# make the code compatible with all Lua APIs >= 5.1 +Patch6: lua-compatibility.patch BuildRequires: %{flavor}-devel BuildRequires: gcc-c++ BuildRequires: lua-macros @@ -92,7 +98,7 @@ This package provides shared libraries for tolua++. Summary: Development headers for tolua++ Group: Development/Libraries/C and C++ Requires: toluapp-%{lua_version} -Conflicts: otherproviders(toluapp-devel) +Conflicts: toluapp-devel Provides: toluapp-devel = %{version} %description -n libtolua++-%{lua_suffix}-devel @@ -100,15 +106,9 @@ This package provides development headers for tolua++. %prep %setup -q -n toluapp-%{version} -%patch -P 0 -p1 -%patch -P 1 -p1 -%patch -P 2 -p1 -%patch -P 4 -p1 -%patch -P 5 -p1 -%patch -P 6 -p1 -%if "%{flavor}" != "lua51" -%patch -P 3 -p1 -%endif +find . -name \*.lua -exec sed -i 's/\r/\n/g; s/\n$//' '{}' + +%autopatch -p1 + sed -i "s/@SUFFIX@/%{lua_version}/" SConstruct %build diff --git a/scons-0.98.1-Options-deprecated.patch b/scons-0.98.1-Options-deprecated.patch index 102c494..0620c47 100644 --- a/scons-0.98.1-Options-deprecated.patch +++ b/scons-0.98.1-Options-deprecated.patch @@ -1,8 +1,12 @@ +--- + SConstruct | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + Index: toluapp-1.0.93/SConstruct =================================================================== ---- toluapp-1.0.93.orig/SConstruct -+++ toluapp-1.0.93/SConstruct -@@ -16,7 +16,11 @@ elif 'msvc' in env['TOOLS']: +--- toluapp-1.0.93.orig/SConstruct 2025-10-13 16:32:08.143176758 +0200 ++++ toluapp-1.0.93/SConstruct 2025-10-13 16:32:58.631888989 +0200 +@@ -18,7 +18,11 @@ else: options_file = "posix" @@ -15,3 +19,12 @@ Index: toluapp-1.0.93/SConstruct opts.Add('CC', 'The C compiler.') opts.Add('CXX', 'The C++ compiler (for the tests)') opts.Add('CCFLAGS', 'Flags for the compiler.', ['-O2', '-Wall']) +@@ -69,7 +73,7 @@ + pkg = open(source, "rt") + + for linea in pkg: +- dep = re.search("^[\t\w]*\$[cphl]file\s*\"([^\"]+)\"", linea) ++ dep = re.search(r"^[\t\w]*\$[cphl]file\s*\"([^\"]+)\"", linea) + if dep: + self.Depends(target, '#' + dep.groups()[0]); + diff --git a/toluapp-scons-py3.patch b/toluapp-scons-py3.patch index f505233..1c2701a 100644 --- a/toluapp-scons-py3.patch +++ b/toluapp-scons-py3.patch @@ -1,8 +1,12 @@ +--- + SConstruct | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + Index: toluapp-1.0.93/SConstruct =================================================================== ---- toluapp-1.0.93.orig/SConstruct -+++ toluapp-1.0.93/SConstruct -@@ -52,9 +52,9 @@ env['TOLUAPP_BOOTSTRAP'] = env['tolua_bi +--- toluapp-1.0.93.orig/SConstruct 2025-10-13 18:29:14.209840999 +0200 ++++ toluapp-1.0.93/SConstruct 2025-10-13 18:29:15.010128928 +0200 +@@ -50,9 +50,9 @@ env['build_dev'] = int(env['build_dev']) ## detecting the install directory on win32 @@ -14,7 +18,7 @@ Index: toluapp-1.0.93/SConstruct env['prefix'] = env['MSVS']['PLATFORMSDKDIR'] -@@ -68,7 +68,7 @@ def pkg_scan_dep(self, target, source): +@@ -66,7 +66,7 @@ ## TODO: detectar si el archivo existe antes de abrirlo asi nomas pkg = open(source, "rt") @@ -23,7 +27,7 @@ Index: toluapp-1.0.93/SConstruct dep = re.search("^[\t\w]*\$[cphl]file\s*\"([^\"]+)\"", linea) if dep: self.Depends(target, '#' + dep.groups()[0]); -@@ -91,7 +91,7 @@ def make_tolua_code(self, target, source +@@ -89,7 +89,7 @@ tolua = 'bin\\'+self['TOLUAPP_BOOTSTRAP'] else: tolua = 'bin/'+self['TOLUAPP_BOOTSTRAP']