summaryrefslogtreecommitdiff
path: root/xmake/scripts/base/utils.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/scripts/base/utils.lua')
-rw-r--r--xmake/scripts/base/utils.lua33
1 files changed, 32 insertions, 1 deletions
diff --git a/xmake/scripts/base/utils.lua b/xmake/scripts/base/utils.lua
index a2efbb482..bbbc802ac 100644
--- a/xmake/scripts/base/utils.lua
+++ b/xmake/scripts/base/utils.lua
@@ -121,7 +121,12 @@ function utils._dump_with_level(object, exclude, level)
end
-- dump object
-function utils.dump(object, exclude)
+function utils.dump(object, exclude, prefix)
+
+ -- dump prefix
+ if prefix then
+ io.write(prefix)
+ end
-- dump it
utils._dump_with_level(object, exclude, 0)
@@ -202,5 +207,31 @@ function utils.unique(array)
return array
end
+-- call functions
+function utils.call(self, funcs, pred, ...)
+
+ -- check
+ assert(self and funcs and type(funcs) == "table")
+
+ -- call all
+ for _, name in ipairs(funcs) do
+
+ -- check
+ assert(type(name) == "string")
+
+ -- get function
+ local func = self[name]
+ assert(type(func) == "function")
+
+ -- call it
+ local result = func(...)
+
+ -- exists predicate?
+ if pred and type(pred) == "function" then
+ if not pred(name, result) then break end
+ end
+ end
+end
+
-- return module: utils
return utils