From fccfafe963bc60348fab25908dcfa9f43a39093d Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 28 May 2022 22:23:11 +0800 Subject: fix c++modules for cl --- xmake/core/base/table.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'xmake/core/base/table.lua') diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua index b8e83cd40..25fc92802 100644 --- a/xmake/core/base/table.lua +++ b/xmake/core/base/table.lua @@ -93,7 +93,7 @@ end function table.join(...) local result = {} for _, t in ipairs({...}) do - if type(t) == "table" and not t.__wraplocked__ then + if type(t) == "table" and not t.__wrap_locked__ then for k, v in pairs(t) do if type(k) == "number" then table.insert(result, v) else result[k] = v end @@ -108,7 +108,7 @@ end -- join all objects and tables to self function table.join2(self, ...) for _, t in ipairs({...}) do - if type(t) == "table" and not t.__wraplocked__ then + if type(t) == "table" and not t.__wrap_locked__ then for k, v in pairs(t) do if type(k) == "number" then table.insert(self, v) else self[k] = v end @@ -310,7 +310,7 @@ end -- unwrap array if be only one value function table.unwrap(array) - if type(array) == "table" and not array.__wraplocked__ then + if type(array) == "table" and not array.__wrap_locked__ then if #array == 1 then return array[1] end @@ -323,7 +323,7 @@ function table.wrap(value) if nil == value then return {} end - if type(value) ~= "table" or value.__wraplocked__ then + if type(value) ~= "table" or value.__wrap_locked__ then return {value} end return value @@ -332,10 +332,17 @@ end -- lock table value to avoid unwrap -- -- a = {1}, wrap(a): {1}, unwrap(a): 1 --- a = wraplock({1}), wrap(a): {a}, unwrap(a): a -function table.wraplock(value) +-- a = wrap_lock({1}), wrap(a): {a}, unwrap(a): a +function table.wrap_lock(value) if type(value) == "table" then - value.__wraplocked__ = true + value.__wrap_locked__ = true + end +end + +-- unlock table value to unwrap +function table.wrap_unlock(value) + if type(value) == "table" then + value.__wrap_locked__ = nil end end -- cgit v1.3.1