diff options
| author | ruki <[email protected]> | 2017-02-28 09:15:08 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-02-28 09:15:08 +0800 |
| commit | 89ad6953438a23a61690d3c32738c330bf2df989 (patch) | |
| tree | ad78d8fe0a9beb43b0e12ef697faf8260cfdbe66 | |
| parent | 1a93fd94a1f1f24e4dc0307796438772c88eb436 (diff) | |
add scope_end api
| -rw-r--r-- | xmake/core/base/deprecated/interpreter.lua | 4 | ||||
| -rw-r--r-- | xmake/core/base/interpreter.lua | 45 |
2 files changed, 41 insertions, 8 deletions
diff --git a/xmake/core/base/deprecated/interpreter.lua b/xmake/core/base/deprecated/interpreter.lua index ab1ce1166..206551c88 100644 --- a/xmake/core/base/deprecated/interpreter.lua +++ b/xmake/core/base/deprecated/interpreter.lua @@ -70,7 +70,7 @@ function deprecated_interpreter:api_register_set_scope(...) end -- register implementation - self:_api_register_xxx_scope(nil, "set", implementation, ...) + self:_api_register_scope_api(nil, "set", implementation, ...) end -- register api for add_scope() @@ -109,7 +109,7 @@ function deprecated_interpreter:api_register_add_scope(...) end -- register implementation - self:_api_register_xxx_scope(nil, "add", implementation, ...) + self:_api_register_scope_api(nil, "add", implementation, ...) end -- register api for set_script diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index f913c61db..c4ae93a9f 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -83,8 +83,39 @@ function interpreter._traceback(errors) return results end --- register api: xxx_apiname() -function interpreter:_api_register_xxx_scope(scope_kind, action, apifunc, ...) +-- register scope end: scopename_end() +function interpreter:_api_register_scope_end(...) + + -- check + assert(self and self._PUBLIC and self._PRIVATE) + + -- done + for _, apiname in ipairs({...}) do + + -- check + assert(apiname) + + -- register scope api + self:api_register(ni, apiname .. "_end", function (self, ...) + + -- check + assert(self and self._PRIVATE and apiname) + + -- the scopes + local scopes = self._PRIVATE._SCOPES + assert(scopes) + + -- enter root scope + scopes._CURRENT = nil + + -- clear scope kind + scopes._CURRENT_KIND = nil + end) + end +end + +-- register scope api: xxx_apiname() +function interpreter:_api_register_scope_api(scope_kind, action, apifunc, ...) -- check assert(self and self._PUBLIC and self._PRIVATE) @@ -114,7 +145,6 @@ function interpreter:_api_register_xxx_scope(scope_kind, action, apifunc, ...) -- call function return apifunc(self, scopes, apiname, ...) - end) end end @@ -160,7 +190,7 @@ function interpreter:_api_register_xxx_values(scope_kind, action, apifunc, ...) end -- register implementation - self:_api_register_xxx_scope(scope_kind, action, implementation, ...) + self:_api_register_scope_api(scope_kind, action, implementation, ...) end -- translate api pathes @@ -817,8 +847,11 @@ function interpreter:api_register_scope(...) end end - -- register implementation - self:_api_register_xxx_scope(nil, nil, implementation, ...) + -- register implementation to the root scope + self:_api_register_scope_api(nil, nil, implementation, ...) + + -- register scope end + self:_api_register_scope_end(...) end -- register api for set_values |
