no nullfn, more clever hook

This commit is contained in:
p.kosyh 2010-06-19 14:59:57 +00:00
parent 91a6a9a8b3
commit 73f455dbf8

View file

@ -7,8 +7,6 @@ stead = {
os = os, os = os,
call_top = 0, call_top = 0,
cctx = { txt = nil, self = nil }, cctx = { txt = nil, self = nil },
nullfn = function()
end,
timer = function() timer = function()
if type(timer) == 'table' and type(timer.callback) == 'function' then if type(timer) == 'table' and type(timer.callback) == 'function' then
return timer:callback(); return timer:callback();
@ -2332,8 +2330,10 @@ end
function hook(o, f) function hook(o, f)
return function(...) return function(...)
if not o then if type(o) ~= 'function' then
o = stead.nullfn o = function(s)
return o;
end
end end
return f(o, unpack(arg)) return f(o, unpack(arg))
end end