diff options
| author | ruki <[email protected]> | 2024-12-22 22:57:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-01-06 18:12:52 +0800 |
| commit | 32db8fc2f0f2c560ab803acd4c4394466843c0bd (patch) | |
| tree | af0715559a42fee42530bec5786e32b1f78601ca /xmake/core/base | |
| parent | 904e9410660956c149f9bb6dcfc631c2720ac32a (diff) | |
add nested namespace tests
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/interpreter.lua | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 95d256851..716ce3004 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -1847,11 +1847,25 @@ function interpreter:api_builtin_add_subfiles(...) end -- the builtin api: namespace() -function interpreter:api_builtin_namespace(...) +function interpreter:api_builtin_namespace(name, callback) + local namespace = self._NAMESPACE + if namespace == nil then + namespace = {} + self._NAMESPACE = namespace + end + table.insert(namespace, name) + if callback and type(callback) == "function" then + callback() + self:api_builtin_namespace_end() + end end -- the builtin api: namespace_end() -function interpreter:api_builtin_namespace_end(...) +function interpreter:api_builtin_namespace_end() + local namespace = self._NAMESPACE + if namespace then + table.remove(namespace) + end end -- the interpreter api: interp_save_scope() |
