summaryrefslogtreecommitdiff
path: root/xmake/core/base/deprecated/interpreter.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-02-18 09:42:04 +0800
committerruki <[email protected]>2016-02-18 09:42:04 +0800
commit0d6ebe7b964bdcec0a224dd491da5b3418d9b805 (patch)
tree19ce663f169dfb93b5c2fbf650deb90096295923 /xmake/core/base/deprecated/interpreter.lua
parentfd9f0efb0d5886481ea4f6f398807eae56c6c6fa (diff)
rename set_script api to on_script
Diffstat (limited to 'xmake/core/base/deprecated/interpreter.lua')
-rw-r--r--xmake/core/base/deprecated/interpreter.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/xmake/core/base/deprecated/interpreter.lua b/xmake/core/base/deprecated/interpreter.lua
index c68ad065a..ca95385f0 100644
--- a/xmake/core/base/deprecated/interpreter.lua
+++ b/xmake/core/base/deprecated/interpreter.lua
@@ -111,5 +111,34 @@ function deprecated_interpreter.api_register_add_scope(self, ...)
self:_api_register_xxx_scope("add", implementation, ...)
end
+-- register api for set_script
+function deprecated_interpreter.api_register_set_script(self, scope_kind, prefix, ...)
+
+ -- check
+ assert(self)
+
+ -- define implementation
+ local implementation = function (self, scope, name, script)
+
+ -- warning
+ utils.warning("please uses on_%s(), \"set_%s()\" has been deprecated!", name, name, scope)
+
+ -- bind script and get new script with sandbox
+ local newscript, errors = sandbox.bind(script, self)
+ if not newscript then
+ utils.error("set_%s(): %s", name, errors)
+ utils.abort()
+ end
+
+ -- update script?
+ scope[name] = {}
+ table.insert(scope[name], newscript)
+
+ end
+
+ -- register implementation
+ self:_api_register_xxx_values(scope_kind, "set", prefix, implementation, ...)
+end
+
-- return module: deprecated_interpreter
return deprecated_interpreter