Skip to content

Commit

Permalink
fix namespace scope
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jan 6, 2025
1 parent 5bc580c commit 5b6f93f
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions xmake/core/base/interpreter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,27 +164,15 @@ end
-- register scope end: scopename_end()
function interpreter:_api_register_scope_end(...)
assert(self and self._PUBLIC and self._PRIVATE)

-- done
for _, apiname in ipairs({...}) do

-- check
assert(apiname)

-- register scope api
self:api_register(nil, apiname .. "_end", function (self, ...)

-- check
assert(self and self._PRIVATE and apiname)

-- the scopes
local scopes = self._PRIVATE._SCOPES
assert(scopes)

-- enter root scope
local scopes = self._PRIVATE._SCOPES
scopes._CURRENT = nil

-- clear scope kind
scopes._CURRENT_KIND = nil
end)
end
Expand Down Expand Up @@ -1864,6 +1852,14 @@ end

-- the builtin api: namespace()
function interpreter:api_builtin_namespace(name, callback)

-- enter root scope
self:api_interp_save_scope()
local scopes = self._PRIVATE._SCOPES
scopes._CURRENT = nil
scopes._CURRENT_KIND = nil

-- enter namespace
local namespace = self._NAMESPACE
if namespace == nil then
namespace = {}
Expand All @@ -1879,6 +1875,7 @@ end

-- the builtin api: namespace_end()
function interpreter:api_builtin_namespace_end()
assert(self and self._PRIVATE)
local namespace = self._NAMESPACE
if namespace then
table.remove(namespace)
Expand All @@ -1888,6 +1885,7 @@ function interpreter:api_builtin_namespace_end()
else
self._NAMESPACE_STR = nil
end
self:api_interp_restore_scope()
end

-- the interpreter api: interp_save_scope()
Expand Down

0 comments on commit 5b6f93f

Please sign in to comment.