mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
Fix #60 - Inconsistent self:calls() in timer and signal
This commit is contained in:
parent
3a5573b1df
commit
8435fc798f
30
signal.lua
30
signal.lua
@ -76,20 +76,20 @@ function Registry:clearPattern(p)
|
||||
end
|
||||
end
|
||||
|
||||
-- the module
|
||||
local function new()
|
||||
local registry = setmetatable({}, Registry)
|
||||
|
||||
return setmetatable({
|
||||
new = new,
|
||||
register = function(...) return registry:register(...) end,
|
||||
emit = function(...) registry:emit(...) end,
|
||||
remove = function(...) registry:remove(...) end,
|
||||
clear = function(...) registry:clear(...) end,
|
||||
emitPattern = function(...) registry:emitPattern(...) end,
|
||||
removePattern = function(...) registry:removePattern(...) end,
|
||||
clearPattern = function(...) registry:clearPattern(...) end,
|
||||
}, {__call = new})
|
||||
-- instancing
|
||||
function Registry.new()
|
||||
return setmetatable({}, Registry)
|
||||
end
|
||||
|
||||
return new()
|
||||
-- default instance
|
||||
local default = Registry.new()
|
||||
|
||||
-- module forwards calls to default instance
|
||||
local module = {}
|
||||
for k in pairs(Registry) do
|
||||
if k ~= "__index" then
|
||||
module[k] = function(...) return default[k](default, ...) end
|
||||
end
|
||||
end
|
||||
|
||||
return setmetatable(module, {__call = Registry.new})
|
||||
|
39
timer.lua
39
timer.lua
@ -174,24 +174,25 @@ __index = function(tweens, key)
|
||||
or error('Unknown interpolation method: ' .. key)
|
||||
end})
|
||||
|
||||
-- the module
|
||||
local function new()
|
||||
local timer = setmetatable({functions = {}, tween = Timer.tween}, Timer)
|
||||
return setmetatable({
|
||||
new = new,
|
||||
update = function(...) return timer:update(...) end,
|
||||
during = function(...) return timer:during(...) end,
|
||||
after = function(...) return timer:after(...) end,
|
||||
every = function(...) return timer:every(...) end,
|
||||
script = function(...) return timer:script(...) end,
|
||||
cancel = function(...) return timer:cancel(...) end,
|
||||
clear = function(...) return timer:clear(...) end,
|
||||
tween = setmetatable({}, {
|
||||
__index = Timer.tween,
|
||||
__newindex = function(_,k,v) Timer.tween[k] = v end,
|
||||
__call = function(t,...) return timer:tween(...) end,
|
||||
})
|
||||
}, {__call = new})
|
||||
-- Timer instancing
|
||||
function Timer.new()
|
||||
return setmetatable({functions = {}, tween = Timer.tween}, Timer)
|
||||
end
|
||||
|
||||
return new()
|
||||
-- default instance
|
||||
local default = Timer.new()
|
||||
|
||||
-- module forwards calls to default instance
|
||||
local module = {}
|
||||
for k in pairs(Timer) do
|
||||
if k ~= "__index" then
|
||||
module[k] = function(...) return default[k](default, ...) end
|
||||
end
|
||||
end
|
||||
module.tween = setmetatable({}, {
|
||||
__index = Timer.tween,
|
||||
__newindex = function(k,v) Timer.tween[k] = v end,
|
||||
__call = function(t, ...) return default:tween(...) end,
|
||||
})
|
||||
|
||||
return setmetatable(module, {__call = Timer.new})
|
||||
|
Loading…
Reference in New Issue
Block a user