gears.object: Assert that arguments have the correct type
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
6fc15f4afd
commit
7bc4ab0bf7
|
@ -36,6 +36,7 @@ end
|
|||
-- @param name The name of the new signal.
|
||||
function object:add_signal(name)
|
||||
check(self)
|
||||
assert(type(name) == "string", "name must be a string, got: " .. type(name))
|
||||
if not self._signals[name] then
|
||||
self._signals[name] = {}
|
||||
end
|
||||
|
@ -45,6 +46,7 @@ end
|
|||
-- @param name The name of the signal
|
||||
-- @param func The callback to call when the signal is emitted
|
||||
function object:connect_signal(name, func)
|
||||
assert(type(func) == "function", "callback must be a function, got: " .. type(func))
|
||||
local sig = find_signal(self, name, "connect to")
|
||||
sig[func] = func
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue