refactoring
This commit is contained in:
+1
-1
@@ -58,7 +58,7 @@ end
|
||||
|
||||
function public.event_listener(event, cb)
|
||||
local listener_id = unique_id
|
||||
listeners[listener_id] = { event=event, cb=cb, kill=function(...) auto[arg] = true if arg.n == 0 or arg[1] then kill_listener(listener_id) end end }
|
||||
listeners[listener_id] = { event=event, cb=cb, kill=vararg-function(arg) if getn(arg) == 0 or arg[1] then kill_listener(listener_id) end end }
|
||||
event_frame:RegisterEvent(event)
|
||||
return listener_id
|
||||
end
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ end
|
||||
|
||||
function private.query.get() return state.params.queries[state.query_index] end
|
||||
|
||||
function wait_for_callback(...) auto[arg] = true
|
||||
function private.vararg.wait_for_callback(arg)
|
||||
local send_signal, signal_received = signal()
|
||||
local suspended, ret
|
||||
|
||||
|
||||
+5
-1
@@ -139,7 +139,11 @@ do
|
||||
setfenv(chunk, {f=f, setn=setn, acquire=acquire, set_auto_release=set_auto_release})
|
||||
return chunk()
|
||||
end
|
||||
public.vararg = vararg
|
||||
public.vararg = setmetatable({}, {
|
||||
__metatable = false,
|
||||
__call = function(_, v) return vararg(v) end,
|
||||
__sub = function(_, v) return vararg(v) end,
|
||||
})
|
||||
end
|
||||
|
||||
public.A = vararg(function(arg)
|
||||
|
||||
+3
-2
@@ -101,8 +101,9 @@ function public.vararg.partial(arg)
|
||||
end)
|
||||
end
|
||||
|
||||
function public.index(t, ...) auto[arg] = true
|
||||
for i = 1, arg.n do t = t and t[arg[i]] end return t
|
||||
function public.vararg.index(arg)
|
||||
local t = tremove(arg, 1)
|
||||
for i = 1, getn(arg) do t = t and t[arg[i]] end return t
|
||||
end
|
||||
|
||||
public.huge = 1.8 * 10 ^ 308
|
||||
|
||||
Reference in New Issue
Block a user