don't check imported function in snax.hotfix

This commit is contained in:
Cloud Wu
2014-08-07 18:06:08 +08:00
parent ae5a9bb855
commit 87a02ffe72
2 changed files with 20 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ Dev version
* bugfix: service exit before init would not report back
* add skynet.response and check multicall skynet.ret
* skynet.newservice throw error when lanuch faild
* Don't check imported function in snax.hotfix
v0.5.0 (2014-7-28)
-----------

View File

@@ -3,7 +3,21 @@ local io = io
local hotfix = {}
local function collect_uv(f , uv)
local function envid(f)
local i = 1
while true do
local name, value = debug.getupvalue(f, i)
if name == nil then
return
end
if name == "_ENV" then
return debug.upvalueid(f, i)
end
i = i + 1
end
end
local function collect_uv(f , uv, env)
local i = 1
while true do
local name, value = debug.getupvalue(f, i)
@@ -18,7 +32,9 @@ local function collect_uv(f , uv)
uv[name] = { func = f, index = i, id = id }
if type(value) == "function" then
collect_uv(value, uv)
if envid(value) == env then
collect_uv(value, uv, env)
end
end
end
@@ -30,7 +46,7 @@ local function collect_all_uv(funcs)
local global = {}
for _, v in pairs(funcs) do
if v[4] then
collect_uv(v[4], global)
collect_uv(v[4], global, envid(v[4]))
end
end