summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-12 22:47:51 +0800
committerruki <[email protected]>2023-10-12 22:47:51 +0800
commit74633ce5a35b554125c13c922c43287119adce34 (patch)
tree7d11effc01dcef5adf68946649f17450ada5ca31
parent09ad995e7113f2273b5e441905a914198e23927b (diff)
add scopeapis
-rw-r--r--xmake/core/base/interpreter.lua19
1 files changed, 15 insertions, 4 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 8a4672284..6060fc319 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -694,7 +694,7 @@ function interpreter.new()
instance:api_register(nil, "interp_restore_scope", interpreter.api_interp_restore_scope)
instance:api_register(nil, "interp_get_scopekind", interpreter.api_interp_get_scopekind)
instance:api_register(nil, "interp_get_scopename", interpreter.api_interp_get_scopename)
- instance:api_register(nil, "interp_register_apis", interpreter.api_interp_register_apis)
+ instance:api_register(nil, "interp_add_scopeapis", interpreter.api_interp_add_scopeapis)
-- register the builtin modules
for module_name, module in pairs(interpreter._builtin_modules()) do
@@ -1859,9 +1859,20 @@ function interpreter:api_interp_get_scopename()
end
end
--- the interpreter api: interp_register_apis()
-function interpreter:api_interp_register_apis(apis)
- return self:api_define(apis)
+-- the interpreter api: interp_add_scopeapis()
+function interpreter:api_interp_add_scopeapis(...)
+ local apis = {...}
+ local extra_config = apis[#apis]
+ if table.is_dictionary(extra_config) then
+ table.remove(apis)
+ else
+ extra_config = nil
+ end
+ local kind = "values"
+ if extra_config and extra_config.kind then
+ kind = extra_config.kind
+ end
+ return self:api_define({[kind] = apis})
end
-- get api function