summaryrefslogtreecommitdiff
path: root/xmake/core/base
diff options
context:
space:
mode:
authorruki <[email protected]>2021-10-09 23:58:21 +0800
committerruki <[email protected]>2021-10-09 23:58:21 +0800
commit1af0820871a06217312fcee22b68e15954fc553a (patch)
tree5eb9e9b0f96089bebc18256ae3cc6644975d8112 /xmake/core/base
parentf35f6e15e13a4e5a360b94148534623b6a9c5feb (diff)
fix some errors for lua5.4
Diffstat (limited to 'xmake/core/base')
-rw-r--r--xmake/core/base/bytes.lua3
-rw-r--r--xmake/core/base/table.lua9
2 files changed, 10 insertions, 2 deletions
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/table.lua b/xmake/core/base/table.lua
index 1e93efd8d..372e5f975 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -53,6 +53,13 @@ if not table.getn then
end
end
+-- get array max length for lua5.4
+if not table.maxn then
+ function table.maxn(t)
+ return #t
+ 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, {})`
@@ -322,7 +329,7 @@ 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.unpack or unpack
-- get keys of a table
function table.keys(tab)