diff options
| author | ruki <[email protected]> | 2016-02-16 21:26:29 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-02-16 21:26:29 +0800 |
| commit | 58a508ef0789085f970c695a87825c31f95689db (patch) | |
| tree | 6871de6a63fe5ae706d7039c0d2f9bc407a8192f | |
| parent | c5723f9909f7500caa3b592df559e8e35b9f47ce (diff) | |
bind interpreter to sandbox
| -rw-r--r-- | xmake/core/base/interpreter.lua | 12 | ||||
| -rw-r--r-- | xmake/core/base/sandbox.lua | 7 |
2 files changed, 16 insertions, 3 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 1da93d5a0..869d20b99 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -482,6 +482,16 @@ function interpreter.mtimes(self) return self._PRIVATE._MTIMES end +-- get filter +function interpreter.filter(self) + + -- check + assert(self and self._PRIVATE) + + -- get filter + return self._PRIVATE._FILTER +end + -- set filter function interpreter.filter_set(self, filter) @@ -792,7 +802,7 @@ function interpreter.api_register_set_script(self, scope_kind, prefix, ...) local implementation = function (self, scope, name, script) -- bind script and get new script with sandbox - local newscript, errors = sandbox.bind(script, self._PRIVATE._FILTER) + local newscript, errors = sandbox.bind(script, self) if not newscript then utils.error("set_%s(\"%s\"): %s", scope, name, errors) utils.abort() diff --git a/xmake/core/base/sandbox.lua b/xmake/core/base/sandbox.lua index 8654e6290..570a22fa4 100644 --- a/xmake/core/base/sandbox.lua +++ b/xmake/core/base/sandbox.lua @@ -140,7 +140,10 @@ function sandbox._init() end -- bind script into the sandbox -function sandbox.bind(script, filter) +function sandbox.bind(script, interp) + + -- check + assert(script and interp) -- init self local self = sandbox._init() @@ -149,7 +152,7 @@ function sandbox.bind(script, filter) assert(self and self._PUBLIC and self._PRIVATE) -- save filter - self._PRIVATE._FILTER = filter + self._PRIVATE._FILTER = interp:filter() -- this script is file? load it first if type(script) == "string" then |
