diff options
| author | ruki <[email protected]> | 2016-05-27 14:17:22 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-05-27 14:17:22 +0800 |
| commit | 7f281a4bcc32519b717f269fd4f2307704f2cd70 (patch) | |
| tree | eb1a537f8a0660f9484ce8223d4598fd0c9aef58 /xmake/core/base/interpreter.lua | |
| parent | ba420896702097733403ec8e3ce56b8ee4e54e88 (diff) | |
dispatch the old api for project
Diffstat (limited to 'xmake/core/base/interpreter.lua')
| -rw-r--r-- | xmake/core/base/interpreter.lua | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index a9bbadd9a..dd5e7c45f 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -250,6 +250,28 @@ function interpreter:_api_builtin_add_subdirfiles(isdirs, ...) self._PRIVATE._CURFILE = curfile end +-- get api function within scope +function interpreter:_api_within_scope(scope_kind, apiname) + + -- the private + local priv = self._PRIVATE + assert(priv) + + -- the scopes + local scopes = priv._SCOPES + assert(scopes) + + -- done + if scope_kind and priv._APIS then + + -- get api function + local api_scope = priv._APIS[scope_kind] + if api_scope then + return api_scope[apiname] + end + end +end + -- clear results function interpreter:_clear() @@ -432,18 +454,12 @@ function interpreter.new() -- dispatch the api calling for scope setmetatable(instance._PUBLIC, { __index = function (tbl, key) - -- get scope kind - local apifunc = nil - local priv = instance._PRIVATE - local scope_kind = priv._SCOPES._CURRENT_KIND or priv._ROOTSCOPE - if scope_kind and priv._APIS then - - -- get api function - apifunc = priv._APIS[scope_kind][key] - end + -- get the scope kind + local priv = instance._PRIVATE + local scope_kind = priv._SCOPES._CURRENT_KIND or priv._ROOTSCOPE - -- ok? - return apifunc + -- get the api function from the given scope + return instance:_api_within_scope(scope_kind, key) end}) -- register the builtin interfaces |
