diff options
| author | ruki <[email protected]> | 2021-10-10 11:36:17 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-10 11:36:17 +0800 |
| commit | 0d11c00ccd8398552e22fa414eb30c10be7336fc (patch) | |
| tree | d960c637a793985d387315d900a605ec29384a66 | |
| parent | dd6dd5f7558ccdff0e886823c35f2397602a0fde (diff) | |
| parent | eb8ceef85ae8181d86e4e977ab060a477510a079 (diff) | |
Merge pull request #1739 from xmake-io/lua54
Support lua5.4.3
60 files changed, 146 insertions, 102 deletions
diff --git a/core/src/lcurses/lcurses.c b/core/src/lcurses/lcurses.c index f3bdf7244..a55b86606 100644 --- a/core/src/lcurses/lcurses.c +++ b/core/src/lcurses/lcurses.c @@ -2431,8 +2431,11 @@ int xm_curses_register (lua_State *L) lua_pushliteral(L, "__index"); lua_pushvalue(L, -2); /* push metatable */ lua_rawset(L, -3); /* metatable.__index = metatable */ +#if 0 luaL_openlib(L, NULL, windowlib, 0); - +#else + luaL_setfuncs(L, windowlib, 0); +#endif lua_pop(L, 1); /* remove metatable from stack */ /* @@ -2442,8 +2445,11 @@ int xm_curses_register (lua_State *L) lua_pushliteral(L, "__index"); lua_pushvalue(L, -2); /* push metatable */ lua_rawset(L, -3); /* metatable.__index = metatable */ +#if 0 luaL_openlib(L, NULL, chstrlib, 0); - +#else + luaL_setfuncs(L, chstrlib, 0); +#endif lua_pop(L, 1); /* remove metatable from stack */ @@ -2451,7 +2457,11 @@ int xm_curses_register (lua_State *L) ** create global table with curses methods/variables/constants */ lua_newtable(L); +#if 0 luaL_register(L, NULL, curseslib); +#else + luaL_setfuncs(L, curseslib, 0); +#endif lua_pushstring(L, "init"); lua_pushvalue(L, -2); diff --git a/core/src/lcurses/makefile b/core/src/lcurses/makefile index e5d519499..6347b4c8e 100644 --- a/core/src/lcurses/makefile +++ b/core/src/lcurses/makefile @@ -23,7 +23,7 @@ lcurses_CXFLAGS += -DUSE_LUAJIT endif ifeq ($(RUNTIME),lua) lcurses_INC_DIRS += ../lua/lua -lcurses_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 +lcurses_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_3 endif # suffix diff --git a/core/src/lua-cjson/makefile b/core/src/lua-cjson/makefile index 021c3d015..4a2c4ffeb 100644 --- a/core/src/lua-cjson/makefile +++ b/core/src/lua-cjson/makefile @@ -28,7 +28,7 @@ lua-cjson_CXFLAGS += -DUSE_LUAJIT endif ifeq ($(RUNTIME),lua) lua-cjson_INC_DIRS += ../lua/lua -lua-cjson_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 +lua-cjson_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_3 endif # use given system library? diff --git a/core/src/lua/makefile b/core/src/lua/makefile index 8a9639947..9db0fa518 100644 --- a/core/src/lua/makefile +++ b/core/src/lua/makefile @@ -37,7 +37,6 @@ lua_C_FILES += \ lua/lcorolib \ lua/lcode \ lua/ltablib \ - lua/lbitlib \ lua/lapi \ lua/lbaselib \ lua/ldebug \ @@ -62,7 +61,7 @@ ifeq ($(PLAT),cygwin) iswin = yes endif -lua_CFLAGS := -std=c99 -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 +lua_CFLAGS := -std=c99 -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_3 ifdef iswin lua_CFLAGS_PLAT := -DLUA_USE_WINDOWS endif diff --git a/core/src/lua/xmake.lua b/core/src/lua/xmake.lua index 4f209b693..62326e748 100644 --- a/core/src/lua/xmake.lua +++ b/core/src/lua/xmake.lua @@ -17,10 +17,10 @@ target("lua") add_includedirs("lua", {public = true}) -- add the common source files - add_files("lua/*.c|lua.c") + add_files("lua/*.c|lua.c|onelua.c") -- add defines - add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", {public = true}) + add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", "LUA_COMPAT_5_3", {public = true}) if is_plat("windows") then add_defines("LUA_USE_WINDOWS") elseif is_plat("macosx", "iphoneos") then diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index dbea858c1..0793f426e 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -845,41 +845,41 @@ xm_engine_ref_t xm_engine_init(tb_char_t const* name, xm_engine_lni_initalizer_c luaL_openlibs(engine->lua); // bind os functions - luaL_register(engine->lua, "os", g_os_functions); + xm_lua_register(engine->lua, "os", g_os_functions); // bind io functions - luaL_register(engine->lua, "io", g_io_functions); + xm_lua_register(engine->lua, "io", g_io_functions); // bind path functions - luaL_register(engine->lua, "path", g_path_functions); + xm_lua_register(engine->lua, "path", g_path_functions); // bind hash functions - luaL_register(engine->lua, "hash", g_hash_functions); + xm_lua_register(engine->lua, "hash", g_hash_functions); // bind string functions - luaL_register(engine->lua, "string", g_string_functions); + xm_lua_register(engine->lua, "string", g_string_functions); // bind process functions - luaL_register(engine->lua, "process", g_process_functions); + xm_lua_register(engine->lua, "process", g_process_functions); // bind sandbox functions - luaL_register(engine->lua, "sandbox", g_sandbox_functions); + xm_lua_register(engine->lua, "sandbox", g_sandbox_functions); // bind windows functions #ifdef TB_CONFIG_OS_WINDOWS - luaL_register(engine->lua, "winos", g_winos_functions); + xm_lua_register(engine->lua, "winos", g_winos_functions); #endif #ifdef XM_CONFIG_API_HAVE_READLINE // bind readline functions - luaL_register(engine->lua, "readline", g_readline_functions); + xm_lua_register(engine->lua, "readline", g_readline_functions); #endif // bind semver functions - luaL_register(engine->lua, "semver", g_semver_functions); + xm_lua_register(engine->lua, "semver", g_semver_functions); // bind libc functions - luaL_register(engine->lua, "libc", g_libc_functions); + xm_lua_register(engine->lua, "libc", g_libc_functions); #ifdef XM_CONFIG_API_HAVE_CURSES // bind curses @@ -1059,7 +1059,7 @@ tb_void_t xm_engine_register(xm_engine_ref_t self, tb_char_t const* module, luaL // do register lua_pushstring(engine->lua, module); lua_newtable(engine->lua); - luaL_register(engine->lua, tb_null, funcs); + xm_lua_register(engine->lua, tb_null, funcs); lua_rawset(engine->lua, -3); } tb_int_t xm_engine_run(tb_char_t const* name, tb_int_t argc, tb_char_t** argv, tb_char_t** taskargv, xm_engine_lni_initalizer_cb_t lni_initalizer) diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index b29e8cc20..48eb51974 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -164,7 +164,7 @@ xmake_CXFLAGS += -DUSE_LUAJIT endif ifeq ($(RUNTIME),lua) xmake_INC_DIRS += ../lua/lua -xmake_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 +xmake_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_3 endif diff --git a/core/src/xmake/os/args.c b/core/src/xmake/os/args.c index 4f1c89f7f..c6de9e6c6 100644 --- a/core/src/xmake/os/args.c +++ b/core/src/xmake/os/args.c @@ -108,7 +108,7 @@ tb_int_t xm_os_args(lua_State* lua) if (lua_istable(lua, 1)) { tb_size_t i = 0; - tb_size_t n = lua_objlen(lua, 1); + tb_size_t n = (tb_size_t)lua_objlen(lua, 1); for (i = 1; i <= n; i++) { // add space diff --git a/core/src/xmake/prefix.h b/core/src/xmake/prefix.h index f78b61127..fabb775fb 100644 --- a/core/src/xmake/prefix.h +++ b/core/src/xmake/prefix.h @@ -114,6 +114,22 @@ static __tb_inline__ tb_pointer_t xm_lua_topointer(lua_State* lua, tb_int_t idx) } #endif +static __tb_inline__ tb_void_t xm_lua_register(lua_State *lua, tb_char_t const* libname, luaL_Reg const* l) +{ +#if LUA_VERSION_NUM >= 504 + lua_getglobal(lua, libname); + if (lua_isnil(lua, -1)) + { + lua_pop(lua, 1); + lua_newtable(lua); + } + luaL_setfuncs(lua, l, 0); + lua_setglobal(lua, libname); +#else + luaL_register(lua, libname, l); +#endif +} + #endif diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c index 46bec2cf5..493ba02ec 100644 --- a/core/src/xmake/process/openv.c +++ b/core/src/xmake/process/openv.c @@ -60,7 +60,7 @@ tb_int_t xm_process_openv(lua_State* lua) tb_check_return_val(shellname, 0); // get the arguments count - tb_long_t argn = lua_objlen(lua, 2); + tb_long_t argn = (tb_long_t)lua_objlen(lua, 2); tb_check_return_val(argn >= 0, 0); // get arguments diff --git a/core/src/xmake/sandbox/interactive.c b/core/src/xmake/sandbox/interactive.c index a62f6f77c..fc0acad12 100644 --- a/core/src/xmake/sandbox/interactive.c +++ b/core/src/xmake/sandbox/interactive.c @@ -51,6 +51,11 @@ // buffer size for prompt #define LUA_PROMPT_BUFSIZE 4096 +// for lua5.4 +#ifndef LUA_QL +# define LUA_QL(x) "'" x "'" +#endif + /* ////////////////////////////////////////////////////////////////////////////////////// * private implementation */ @@ -253,7 +258,7 @@ static tb_int_t xm_sandbox_loadline(lua_State* lua, tb_int_t top) * stack: arg1(sandbox_scope) scriptbuffer(top) -> ... * after: arg1(sandbox_scope) scriptbuffer scriptfunc(top) -> ... */ - status = luaL_loadbuffer(lua, lua_tostring(lua, -1), lua_strlen(lua, -1), "=stdin"); + status = luaL_loadbuffer(lua, lua_tostring(lua, -1), (size_t)lua_strlen(lua, -1), "=stdin"); // complete? if (!xm_sandbox_incomplete(lua, status)) break; diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index a74845f95..f79a5d6b2 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -48,10 +48,10 @@ function _do_run_target(target) -- add run environments local addrunenvs, setrunenvs = make_runenvs(target) for name, values in pairs(addrunenvs) do - os.addenv(name, unpack(table.wrap(values))) + os.addenv(name, table.unpack(table.wrap(values))) end for name, value in pairs(setrunenvs) do - os.setenv(name, unpack(table.wrap(value))) + os.setenv(name, table.unpack(table.wrap(value))) end -- debugging? diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua index cf82a5a9c..b35768058 100644 --- a/xmake/core/_xmake_main.lua +++ b/xmake/core/_xmake_main.lua @@ -120,8 +120,8 @@ function loadfile(filepath, mode, opt) return script, errors end --- init package path -table.insert(package.loaders, 2, function(v) +-- init package path, package.searchers for lua5.4 +table.insert(package.loaders or package.searchers, 2, function(v) local filepath = xmake._PROGRAM_DIR .. "/core/" .. v .. ".lua" local script, serr = _loadfile_impl(filepath) if not script then diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua index 9f7b6ca4f..bb65d0cfc 100644 --- a/xmake/core/base/bytes.lua +++ b/xmake/core/base/bytes.lua @@ -28,6 +28,7 @@ local os = require("base/os") local utils = require("base/utils") local todisplay = require("base/todisplay") local libc = require("base/libc") +local table = require("base/table") -- new a bytes instance -- @@ -42,7 +43,7 @@ local libc = require("base/libc") -- function _instance.new(...) local args = {...} - local arg1, arg2, arg3 = unpack(args) + local arg1, arg2, arg3 = table.unpack(args) local instance = table.inherit(_instance) if type(arg1) == "number" then local size = arg1 diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 32602c4c4..90e0a57e5 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -459,13 +459,12 @@ function interpreter:_filter(values, level) else -- filter value or arrays values = table.wrap(values) - for idx = 1, table.maxn(values) do - + for idx = 1, #values do local value = values[idx] if type(value) == "string" then value = filter:handle(value) elseif table.is_array(value) then - for i = 1, table.maxn(value) do + for i = 1, #value do local v = value[i] if type(v) == "string" then v = filter:handle(v) @@ -1306,7 +1305,7 @@ function interpreter:api_register_set_paths(scope_kind, ...) end -- translate paths - values = table.join(unpack(values)) + values = table.join(table.unpack(values)) local paths = self:_api_translate_paths(values, "set_" .. name) -- save values @@ -1378,7 +1377,7 @@ function interpreter:api_register_add_paths(scope_kind, ...) end -- translate paths - values = table.join(unpack(values)) + values = table.join(table.unpack(values)) local paths = self:_api_translate_paths(values, "add_" .. name) -- save values diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 312d5705d..a4fdb570e 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -377,7 +377,7 @@ end -- match directories -- --- @note only return {} without count to simplify code, e.g. unpack(os.dirs("")) +-- @note only return {} without count to simplify code, e.g. table.unpack(os.dirs("")) -- function os.dirs(pattern, callback) return (os.match(pattern, 'd', callback)) diff --git a/xmake/core/base/pipe.lua b/xmake/core/base/pipe.lua index 5f7c46c06..92ad42bc6 100644 --- a/xmake/core/base/pipe.lua +++ b/xmake/core/base/pipe.lua @@ -67,7 +67,7 @@ function _instance:write(data, opt) return -1, errors end - -- data is bytes? unpack the raw address + -- data is bytes? table.unpack the raw address local datasize = #data if type(data) == "table" and data.caddr then datasize = data:size() diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua index 1f07e236f..9d4888f1c 100644 --- a/xmake/core/base/scopeinfo.lua +++ b/xmake/core/base/scopeinfo.lua @@ -109,7 +109,7 @@ function _instance:_api_set_values(name, ...) end -- expand values - values = table.join(unpack(values)) + values = table.join(table.unpack(values)) -- handle values local handled_values = self:_api_handle(values) @@ -148,7 +148,7 @@ function _instance:_api_add_values(name, ...) end -- expand values - values = table.join(unpack(values)) + values = table.join(table.unpack(values)) -- save values scope[name] = self:_api_handle(table.join2(table.wrap(scope[name]), values)) @@ -311,7 +311,7 @@ function _instance:_api_set_paths(name, ...) end -- expand values - values = table.join(unpack(values)) + values = table.join(table.unpack(values)) -- translate paths local paths = interp:_api_translate_paths(values, "set_" .. name, 5) @@ -351,7 +351,7 @@ function _instance:_api_add_paths(name, ...) end -- expand values - values = table.join(unpack(values)) + values = table.join(table.unpack(values)) -- translate paths local paths = interp:_api_translate_paths(values, "add_" .. name, 5) @@ -451,7 +451,7 @@ function _instance:apival_set(name, ...) local array = name for _, dict in ipairs(array) do for k, v in pairs(dict) do - self:apival_set(k, unpack(table.wrap(v))) + self:apival_set(k, table.unpack(table.wrap(v))) end end @@ -459,7 +459,7 @@ function _instance:apival_set(name, ...) elseif table.is_dictionary(name) then local dict = name for k, v in pairs(dict) do - self:apival_set(k, unpack(table.wrap(v))) + self:apival_set(k, table.unpack(table.wrap(v))) end elseif name ~= nil then os.raise("unknown type(%s) for %s:set(%s, ...)", type(name), self:kind(), name) @@ -487,7 +487,7 @@ function _instance:apival_add(name, ...) local array = name for _, dict in ipairs(array) do for k, v in pairs(dict) do - self:apival_add(k, unpack(table.wrap(v))) + self:apival_add(k, table.unpack(table.wrap(v))) end end @@ -495,7 +495,7 @@ function _instance:apival_add(name, ...) elseif table.is_dictionary(name) then local dict = name for k, v in pairs(dict) do - self:apival_add(k, unpack(table.wrap(v))) + self:apival_add(k, table.unpack(table.wrap(v))) end elseif name ~= nil then os.raise("unknown type(%s) for %s:add(%s, ...)", type(name), self:kind(), name) diff --git a/xmake/core/base/serialize.lua b/xmake/core/base/serialize.lua index a49122308..2f8030338 100644 --- a/xmake/core/base/serialize.lua +++ b/xmake/core/base/serialize.lua @@ -323,7 +323,7 @@ function serialize.save(obj, opt) end -- binary mode - local func, lerr = loadstring("return " .. result, "=") + local func, lerr = load("return " .. result, "=") if lerr ~= nil then return nil, lerr end diff --git a/xmake/core/base/socket.lua b/xmake/core/base/socket.lua index 7269cb504..4e6435c09 100644 --- a/xmake/core/base/socket.lua +++ b/xmake/core/base/socket.lua @@ -244,7 +244,7 @@ function _instance:send(data, opt) return -1, errors end - -- data is bytes? unpack the raw address + -- data is bytes? table.unpack the raw address local datasize = #data if type(data) == "table" and data.caddr then datasize = data:size() @@ -442,7 +442,7 @@ function _instance:sendto(data, addr, port, opt) return -1, string.format("%s: sendto empty address!", self) end - -- data is bytes? unpack the raw address + -- data is bytes? table.unpack the raw address if type(data) == "table" and data.caddr then data = {data = data:caddr(), size = data:size()} end diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua index 1e93efd8d..5f2c4585a 100644 --- a/xmake/core/base/table.lua +++ b/xmake/core/base/table.lua @@ -53,6 +53,19 @@ if not table.getn then end end +-- get array max integer key for lua5.4 +if not table.maxn then + function table.maxn(t) + local max = 0 + for k, _ in pairs(t) do + if type(k) == "number" and k > max then + max = k + end + end + return max + end +end + -- move values of table(a1) to table(a2) -- -- disable the builtin implementation for android termux/arm64, it will crash when calling `table.move({1, 1}, 1, 2, 1, {})` @@ -320,9 +333,9 @@ function table.pack(...) return { n = select("#", ...), ... } end --- unpack table values --- polyfill of lua 5.2, @see https://www.lua.org/manual/5.2/manual.html#pdf-table.unpack -table.unpack = unpack +-- table.unpack table values +-- polyfill of lua 5.2, @see https://www.lua.org/manual/5.2/manual.html#pdf-unpack +table.unpack = table.unpack or unpack -- get keys of a table function table.keys(tab) diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index e636cfbf5..80f7e9904 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -731,7 +731,7 @@ function _instance:envs_enter() end end else - os.addenv(name, unpack(table.wrap(values))) + os.addenv(name, table.unpack(table.wrap(values))) end end end diff --git a/xmake/core/sandbox/modules/interpreter/print.lua b/xmake/core/sandbox/modules/interpreter/print.lua index 0f906f5a4..dd42c8fe9 100644 --- a/xmake/core/sandbox/modules/interpreter/print.lua +++ b/xmake/core/sandbox/modules/interpreter/print.lua @@ -19,6 +19,7 @@ -- -- load modules +local table = require("base/table") local try = require("sandbox/modules/try") local catch = require("sandbox/modules/catch") @@ -33,13 +34,13 @@ function _print(format, ...) { function () -- attempt to print format string first - io.write(string.format(format, unpack(args)) .. "\n") + io.write(string.format(format, table.unpack(args)) .. "\n") end, catch { function () -- print multi-variables with raw lua action - print(format, unpack(args)) + print(format, table.unpack(args)) end } } diff --git a/xmake/core/sandbox/modules/interpreter/unpack.lua b/xmake/core/sandbox/modules/interpreter/unpack.lua index 766e49f98..5d3b9c811 100644 --- a/xmake/core/sandbox/modules/interpreter/unpack.lua +++ b/xmake/core/sandbox/modules/interpreter/unpack.lua @@ -15,9 +15,9 @@ -- Copyright (C) 2015-present, TBOOX Open Source Group. -- -- @author ruki --- @file unpack.lua +-- @file table.unpack.lua -- -- load module -return unpack +return require("base/table").unpack diff --git a/xmake/core/sandbox/modules/irpairs.lua b/xmake/core/sandbox/modules/irpairs.lua index 7cb175173..d59574481 100644 --- a/xmake/core/sandbox/modules/irpairs.lua +++ b/xmake/core/sandbox/modules/irpairs.lua @@ -60,7 +60,7 @@ function sandbox_irpairs(t, filter, ...) -- return iterator and initialized state t = table.wrap(t) - return iter, t, table.maxn(t) + 1 + return iter, t, table.getn(t) + 1 end -- load module diff --git a/xmake/core/sandbox/modules/unpack.lua b/xmake/core/sandbox/modules/unpack.lua index 766e49f98..5d3b9c811 100644 --- a/xmake/core/sandbox/modules/unpack.lua +++ b/xmake/core/sandbox/modules/unpack.lua @@ -15,9 +15,9 @@ -- Copyright (C) 2015-present, TBOOX Open Source Group. -- -- @author ruki --- @file unpack.lua +-- @file table.unpack.lua -- -- load module -return unpack +return require("base/table").unpack diff --git a/xmake/core/sandbox/modules/utils.lua b/xmake/core/sandbox/modules/utils.lua index 528f59b9e..b2f9a682a 100644 --- a/xmake/core/sandbox/modules/utils.lua +++ b/xmake/core/sandbox/modules/utils.lua @@ -55,10 +55,10 @@ function sandbox_utils._print(...) end -- print multi-variables with raw lua action - utils._print(unpack(args)) + utils._print(table.unpack(args)) -- write to the log file - log:printv(unpack(args)) + log:printv(table.unpack(args)) end -- print format string with newline @@ -75,7 +75,7 @@ function sandbox_utils.print(format, ...) { function () -- attempt to format message - local message = vformat(format, unpack(args)) + local message = vformat(format, table.unpack(args)) -- trace utils._print(message) @@ -87,7 +87,7 @@ function sandbox_utils.print(format, ...) { function (errors) -- print multi-variables with raw lua action - sandbox_utils._print(format, unpack(args)) + sandbox_utils._print(format, table.unpack(args)) end } } diff --git a/xmake/includes/check_cflags.lua b/xmake/includes/check_cflags.lua index ef3f7866b..63354dfac 100644 --- a/xmake/includes/check_cflags.lua +++ b/xmake/includes/check_cflags.lua @@ -55,7 +55,7 @@ end function configvar_check_cflags(definition, flags, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) if opt.default == nil then diff --git a/xmake/includes/check_cfuncs.lua b/xmake/includes/check_cfuncs.lua index 1a64cb250..51352e424 100644 --- a/xmake/includes/check_cfuncs.lua +++ b/xmake/includes/check_cfuncs.lua @@ -76,7 +76,7 @@ end function configvar_check_cfuncs(definition, funcs, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_cfuncs(funcs) diff --git a/xmake/includes/check_cincludes.lua b/xmake/includes/check_cincludes.lua index dc0308a65..c954b5260 100644 --- a/xmake/includes/check_cincludes.lua +++ b/xmake/includes/check_cincludes.lua @@ -51,7 +51,7 @@ end function configvar_check_cincludes(definition, includes, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_cincludes(includes) diff --git a/xmake/includes/check_csnippets.lua b/xmake/includes/check_csnippets.lua index 9d2370ee0..19e87ab9e 100644 --- a/xmake/includes/check_csnippets.lua +++ b/xmake/includes/check_csnippets.lua @@ -87,7 +87,7 @@ end function configvar_check_csnippets(definition, snippets, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_csnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output}) diff --git a/xmake/includes/check_ctypes.lua b/xmake/includes/check_ctypes.lua index b3f59b04e..d14c64aa7 100644 --- a/xmake/includes/check_ctypes.lua +++ b/xmake/includes/check_ctypes.lua @@ -64,7 +64,7 @@ end function configvar_check_ctypes(definition, types, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_ctypes(types) diff --git a/xmake/includes/check_cxxflags.lua b/xmake/includes/check_cxxflags.lua index 38ea5172e..c93745134 100644 --- a/xmake/includes/check_cxxflags.lua +++ b/xmake/includes/check_cxxflags.lua @@ -55,7 +55,7 @@ end function configvar_check_cxxflags(definition, flags, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) if opt.default == nil then diff --git a/xmake/includes/check_cxxfuncs.lua b/xmake/includes/check_cxxfuncs.lua index 1488f7312..241effd19 100644 --- a/xmake/includes/check_cxxfuncs.lua +++ b/xmake/includes/check_cxxfuncs.lua @@ -76,7 +76,7 @@ end function configvar_check_cxxfuncs(definition, funcs, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_cxxfuncs(funcs) diff --git a/xmake/includes/check_cxxincludes.lua b/xmake/includes/check_cxxincludes.lua index 45cb2d2c0..15f4fa1df 100644 --- a/xmake/includes/check_cxxincludes.lua +++ b/xmake/includes/check_cxxincludes.lua @@ -48,7 +48,7 @@ end function configvar_check_cxxincludes(definition, includes, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_cxxincludes(includes) diff --git a/xmake/includes/check_cxxsnippets.lua b/xmake/includes/check_cxxsnippets.lua index daa71780c..9405b5707 100644 --- a/xmake/includes/check_cxxsnippets.lua +++ b/xmake/includes/check_cxxsnippets.lua @@ -87,7 +87,7 @@ end function configvar_check_cxxsnippets(definition, snippets, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_cxxsnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output}) diff --git a/xmake/includes/check_cxxtypes.lua b/xmake/includes/check_cxxtypes.lua index f5b8c677a..928ecbad5 100644 --- a/xmake/includes/check_cxxtypes.lua +++ b/xmake/includes/check_cxxtypes.lua @@ -64,7 +64,7 @@ end function configvar_check_cxxtypes(definition, types, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_cxxtypes(types) diff --git a/xmake/includes/check_features.lua b/xmake/includes/check_features.lua index 3e8fb47be..481d9b6fe 100644 --- a/xmake/includes/check_features.lua +++ b/xmake/includes/check_features.lua @@ -60,7 +60,7 @@ end function configvar_check_features(definition, features, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_features(features) diff --git a/xmake/includes/check_links.lua b/xmake/includes/check_links.lua index 54891361e..25ddaa619 100644 --- a/xmake/includes/check_links.lua +++ b/xmake/includes/check_links.lua @@ -48,7 +48,7 @@ end function configvar_check_links(definition, links, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_links(links) diff --git a/xmake/includes/check_macros.lua b/xmake/includes/check_macros.lua index 0ed879c95..352a2382f 100644 --- a/xmake/includes/check_macros.lua +++ b/xmake/includes/check_macros.lua @@ -81,7 +81,7 @@ end function configvar_check_macros(definition, macros, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) local snippets = {} save_scope() option(optname) diff --git a/xmake/includes/check_syslinks.lua b/xmake/includes/check_syslinks.lua index 8df32a1b8..379bb005a 100644 --- a/xmake/includes/check_syslinks.lua +++ b/xmake/includes/check_syslinks.lua @@ -48,7 +48,7 @@ end function configvar_check_syslinks(definition, links, opt) opt = opt or {} local optname = "__" .. (opt.name or definition) - local defname, defval = unpack(definition:split('=')) + local defname, defval = table.unpack(definition:split('=')) save_scope() option(optname) add_syslinks(links) diff --git a/xmake/includes/qt_add_static_plugins.lua b/xmake/includes/qt_add_static_plugins.lua index 8ecb06056..e65965972 100644 --- a/xmake/includes/qt_add_static_plugins.lua +++ b/xmake/includes/qt_add_static_plugins.lua @@ -34,10 +34,10 @@ function qt_add_static_plugins(plugin, opt) opt = opt or {} add_values("qt.plugins", plugin) if opt.links then - add_values("qt.links", unpack(table.wrap(opt.links))) + add_values("qt.links", table.unpack(table.wrap(opt.links))) end if opt.linkdirs then - add_values("qt.linkdirs", unpack(table.wrap(opt.linkdirs))) + add_values("qt.linkdirs", table.unpack(table.wrap(opt.linkdirs))) end end diff --git a/xmake/modules/detect/tools/clang_cl/has_flags.lua b/xmake/modules/detect/tools/clang_cl/has_flags.lua index 27728697f..4917fb665 100644 --- a/xmake/modules/detect/tools/clang_cl/has_flags.lua +++ b/xmake/modules/detect/tools/clang_cl/has_flags.lua @@ -61,7 +61,7 @@ function _try_running(...) local argv = {...} local errors = nil - return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors + return try { function () os.runv(table.unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors end -- try running to check flags diff --git a/xmake/modules/detect/tools/dmd/has_flags.lua b/xmake/modules/detect/tools/dmd/has_flags.lua index 459db9228..235e99d4c 100644 --- a/xmake/modules/detect/tools/dmd/has_flags.lua +++ b/xmake/modules/detect/tools/dmd/has_flags.lua @@ -40,7 +40,7 @@ function _try_running(...) local argv = {...} local errors = nil - return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors + return try { function () os.runv(table.unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors end -- attempt to check it from the argument list diff --git a/xmake/modules/detect/tools/fpc/has_flags.lua b/xmake/modules/detect/tools/fpc/has_flags.lua index 9f66939cc..109e1014b 100644 --- a/xmake/modules/detect/tools/fpc/has_flags.lua +++ b/xmake/modules/detect/tools/fpc/has_flags.lua @@ -26,7 +26,7 @@ function _try_running(...) local argv = {...} local errors = nil - return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors + return try { function () os.runv(table.unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors end -- attempt to check it from the argument list diff --git a/xmake/modules/detect/tools/go/has_flags.lua b/xmake/modules/detect/tools/go/has_flags.lua index 267d4de8a..e1acf3769 100644 --- a/xmake/modules/detect/tools/go/has_flags.lua +++ b/xmake/modules/detect/tools/go/has_flags.lua @@ -35,7 +35,7 @@ function _try_running(...) local argv = {...} local errors = nil - return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors + return try { function () os.runv(table.unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors end -- attempt to check it from the argument list diff --git a/xmake/modules/detect/tools/rustc/has_flags.lua b/xmake/modules/detect/tools/rustc/has_flags.lua index e7c55a180..904a3c85a 100644 --- a/xmake/modules/detect/tools/rustc/has_flags.lua +++ b/xmake/modules/detect/tools/rustc/has_flags.lua @@ -26,7 +26,7 @@ function _try_running(...) local argv = {...} local errors = nil - return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors + return try { function () os.runv(table.unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors end -- attempt to check it from the argument list diff --git a/xmake/modules/detect/tools/sdcc/has_flags.lua b/xmake/modules/detect/tools/sdcc/has_flags.lua index 1198b6f44..c7c440a8a 100644 --- a/xmake/modules/detect/tools/sdcc/has_flags.lua +++ b/xmake/modules/detect/tools/sdcc/has_flags.lua @@ -41,7 +41,7 @@ function _try_running(...) local argv = {...} local errors = nil - return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors + return try { function () os.runv(table.unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors end -- attempt to check it from the argument list diff --git a/xmake/modules/detect/tools/swiftc/has_flags.lua b/xmake/modules/detect/tools/swiftc/has_flags.lua index 541b897a9..fc4ff6540 100644 --- a/xmake/modules/detect/tools/swiftc/has_flags.lua +++ b/xmake/modules/detect/tools/swiftc/has_flags.lua @@ -26,7 +26,7 @@ function _try_running(...) local argv = {...} local errors = nil - return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors + return try { function () os.runv(table.unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors end -- attempt to check it from the argument list diff --git a/xmake/modules/detect/tools/zig/has_flags.lua b/xmake/modules/detect/tools/zig/has_flags.lua index b12f3defb..1dea91cfe 100644 --- a/xmake/modules/detect/tools/zig/has_flags.lua +++ b/xmake/modules/detect/tools/zig/has_flags.lua @@ -34,7 +34,7 @@ function _try_running(...) local argv = {...} local errors = nil - return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors + return try { function () os.runv(table.unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors end -- attempt to check it from the argument list diff --git a/xmake/modules/lib/detect/pkgconfig.lua b/xmake/modules/lib/detect/pkgconfig.lua index 9cd07a1e7..57726bae0 100644 --- a/xmake/modules/lib/detect/pkgconfig.lua +++ b/xmake/modules/lib/detect/pkgconfig.lua @@ -46,7 +46,7 @@ function version(name, opt) local configdirs_old = os.getenv("PKG_CONFIG_PATH") local configdirs = table.wrap(opt.configdirs) if #configdirs > 0 then - os.setenv("PKG_CONFIG_PATH", unpack(configdirs)) + os.setenv("PKG_CONFIG_PATH", table.unpack(configdirs)) end -- get version @@ -85,7 +85,7 @@ function variables(name, variables, opt) local configdirs_old = os.getenv("PKG_CONFIG_PATH") local configdirs = table.wrap(opt.configdirs) if #configdirs > 0 then - os.setenv("PKG_CONFIG_PATH", unpack(configdirs)) + os.setenv("PKG_CONFIG_PATH", table.unpack(configdirs)) end -- get variable value diff --git a/xmake/modules/package/manager/find_package.lua b/xmake/modules/package/manager/find_package.lua index 41c110796..7d82043b2 100644 --- a/xmake/modules/package/manager/find_package.lua +++ b/xmake/modules/package/manager/find_package.lua @@ -174,7 +174,7 @@ function main(name, opt) opt.mode = opt.mode or config.mode() or "release" -- get package manager name - local manager_name, package_name = unpack(name:split("::", {plain = true, strict = true})) + local manager_name, package_name = table.unpack(name:split("::", {plain = true, strict = true})) if package_name == nil then package_name = manager_name manager_name = nil @@ -184,7 +184,7 @@ function main(name, opt) -- get package name and require version local require_version = nil - package_name, require_version = unpack(package_name:trim():split("%s")) + package_name, require_version = table.unpack(package_name:trim():split("%s")) opt.require_version = require_version or opt.require_version -- find package diff --git a/xmake/modules/package/manager/install_package.lua b/xmake/modules/package/manager/install_package.lua index 1c5d5ab07..05e13ed27 100644 --- a/xmake/modules/package/manager/install_package.lua +++ b/xmake/modules/package/manager/install_package.lua @@ -93,7 +93,7 @@ function main(name, opt) opt.mode = opt.mode or config.mode() or "release" -- get package manager name - local manager_name, package_name = unpack(name:split("::", {plain = true, strict = true})) + local manager_name, package_name = table.unpack(name:split("::", {plain = true, strict = true})) if package_name == nil then package_name = manager_name manager_name = nil @@ -103,7 +103,7 @@ function main(name, opt) -- get package name and require version local require_version = nil - package_name, require_version = unpack(package_name:trim():split("%s")) + package_name, require_version = table.unpack(package_name:trim():split("%s")) opt.require_version = require_version or opt.require_version -- do install package diff --git a/xmake/modules/private/action/require/impl/packagenv.lua b/xmake/modules/private/action/require/impl/packagenv.lua index 12a98d36f..06a70df91 100644 --- a/xmake/modules/private/action/require/impl/packagenv.lua +++ b/xmake/modules/private/action/require/impl/packagenv.lua @@ -33,7 +33,7 @@ function _enter_package(package_name, envs, installdir) end end else - os.addenv(name, unpack(table.wrap(values))) + os.addenv(name, table.unpack(table.wrap(values))) end end end diff --git a/xmake/modules/private/action/require/impl/search_packages.lua b/xmake/modules/private/action/require/impl/search_packages.lua index 00cf1ffbf..276747db4 100644 --- a/xmake/modules/private/action/require/impl/search_packages.lua +++ b/xmake/modules/private/action/require/impl/search_packages.lua @@ -22,7 +22,7 @@ function _search_packages(name) -- get package manager name - local manager_name, package_name = unpack(name:split("::", {plain = true, strict = true})) + local manager_name, package_name = table.unpack(name:split("::", {plain = true, strict = true})) if package_name == nil then package_name = manager_name manager_name = "xmake" diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index b29d01623..742d30d12 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -208,7 +208,7 @@ function _package_addenvs(envs, instance) end end else - _addenvs(envs, name, unpack(table.wrap(values))) + _addenvs(envs, name, table.unpack(table.wrap(values))) end end @@ -237,7 +237,7 @@ function _toolchain_addenvs(envs) local toolchain_inst = toolchain.load(name, toolchain_opt) if toolchain_inst then for k, v in pairs(toolchain_inst:runenvs()) do - _addenvs(envs, k, unpack(path.splitenv(v))) + _addenvs(envs, k, table.unpack(path.splitenv(v))) end end end diff --git a/xmake/plugins/lua/main.lua b/xmake/plugins/lua/main.lua index 40b16249e..cf0ed80a1 100644 --- a/xmake/plugins/lua/main.lua +++ b/xmake/plugins/lua/main.lua @@ -122,7 +122,7 @@ function _run_script(script, args) if _is_callable(func) then local result = table.pack(func(table.unpack(args, 1, args.n))) if printresult and result and result.n ~= 0 then - utils.dump(unpack(result, 1, result.n)) + utils.dump(table.unpack(result, 1, result.n)) end else -- dump variables directly diff --git a/xmake/rules/cuda/gencodes/xmake.lua b/xmake/rules/cuda/gencodes/xmake.lua index b5ebc22d1..e208c1f4f 100644 --- a/xmake/rules/cuda/gencodes/xmake.lua +++ b/xmake/rules/cuda/gencodes/xmake.lua @@ -112,7 +112,7 @@ rule("cuda.gencodes") if v_arch then table.insert(r_archs, v_arch) else - v_arch = math.min(unpack(r_archs)) + v_arch = math.min(table.unpack(r_archs)) end r_archs = table.unique(r_archs) diff --git a/xmake/rules/qt/load.lua b/xmake/rules/qt/load.lua index 1c4627f11..c5bec10af 100644 --- a/xmake/rules/qt/load.lua +++ b/xmake/rules/qt/load.lua @@ -81,10 +81,10 @@ function _add_plugins(target, plugins) for name, plugin in pairs(plugins) do target:values_add("qt.plugins", name) if plugin.links then - target:values_add("qt.links", unpack(table.wrap(plugin.links))) + target:values_add("qt.links", table.unpack(table.wrap(plugin.links))) end if plugin.linkdirs then - target:values_add("qt.linkdirs", unpack(table.wrap(plugin.linkdirs))) + target:values_add("qt.linkdirs", table.unpack(table.wrap(plugin.linkdirs))) end end end diff --git a/xmake/rules/xcode/application/run.lua b/xmake/rules/xcode/application/run.lua index e92397a29..0e0663207 100644 --- a/xmake/rules/xcode/application/run.lua +++ b/xmake/rules/xcode/application/run.lua @@ -40,10 +40,10 @@ function _run_on_macosx(target, opt) -- add run environments local addrunenvs, setrunenvs = make_runenvs(target) for name, values in pairs(addrunenvs) do - os.addenv(name, unpack(table.wrap(values))) + os.addenv(name, table.unpack(table.wrap(values))) end for name, value in pairs(setrunenvs) do - os.setenv(name, unpack(table.wrap(value))) + os.setenv(name, table.unpack(table.wrap(value))) end -- debugging? |
