diff options
Diffstat (limited to 'xmake/core/base/interpreter.lua')
| -rw-r--r-- | xmake/core/base/interpreter.lua | 20 |
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) |
