summaryrefslogtreecommitdiff
path: root/xmake/core/base/interpreter.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-12-26 08:59:06 +0800
committerruki <[email protected]>2017-01-06 17:20:08 +0800
commitcf15bd5f7162d6f009ff749e4fe6a29bd22cdda2 (patch)
tree82e72a1f6a2a5a84b3cdc8b1ee9d00eeab726a12 /xmake/core/base/interpreter.lua
parent41b436bf13e65ea0a9eb3e826d944a626e387df2 (diff)
define apis for all scopes again
Diffstat (limited to 'xmake/core/base/interpreter.lua')
-rw-r--r--xmake/core/base/interpreter.lua20
1 files changed, 17 insertions, 3 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index af21e9b82..86f57ebb2 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -1121,14 +1121,22 @@ end
function interpreter:api_define(apis)
-- register language apis
+ local scopes = {}
for apitype, apifuncs in pairs(apis) do
for _, apifunc in ipairs(apifuncs) do
-- get api function
+ local apiscope = nil
+ local funcname = nil
apifunc = apifunc:split('.')
- local apiscope = apifunc[1]
- local funcname = apifunc[2]
- assert(apiscope and funcname)
+ assert(apifunc)
+ if #apifunc == 2 then
+ apiscope = apifunc[1]
+ funcname = apifunc[2]
+ else
+ funcname = apifunc[1]
+ end
+ assert(funcname)
-- get function prefix
local prefix = nil
@@ -1148,6 +1156,12 @@ function interpreter:api_define(apis)
if not register then
os.raise("interp:api_register_%s_%s() is unknown!", prefix, apitype)
end
+
+ -- register scope first
+ if apiscope ~= nil and not scopes[apiscope] then
+ self:api_register_scope(apiscope)
+ scopes[apiscope] = true
+ end
-- register api
register(self, apiscope, funcname)