gears.object: Assert that arguments have the correct type

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2015-01-11 11:04:33 +01:00
parent 6fc15f4afd
commit 7bc4ab0bf7
1 changed files with 2 additions and 0 deletions

View File

@ -36,6 +36,7 @@ end
-- @param name The name of the new signal. -- @param name The name of the new signal.
function object:add_signal(name) function object:add_signal(name)
check(self) check(self)
assert(type(name) == "string", "name must be a string, got: " .. type(name))
if not self._signals[name] then if not self._signals[name] then
self._signals[name] = {} self._signals[name] = {}
end end
@ -45,6 +46,7 @@ end
-- @param name The name of the signal -- @param name The name of the signal
-- @param func The callback to call when the signal is emitted -- @param func The callback to call when the signal is emitted
function object:connect_signal(name, func) 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") local sig = find_signal(self, name, "connect to")
sig[func] = func sig[func] = func
end end