mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
object: Add type information to documentation
This commit is contained in:
parent
4b21ca9184
commit
b1c33fbd09
1 changed files with 15 additions and 15 deletions
|
@ -21,10 +21,10 @@ local function check(obj)
|
|||
end
|
||||
|
||||
--- Find a given signal
|
||||
-- @param obj The object to search in
|
||||
-- @param name The signal to find
|
||||
-- @param error_msg Error message for if the signal is not found
|
||||
-- @return The signal table
|
||||
-- @tparam table obj The object to search in
|
||||
-- @tparam string name The signal to find
|
||||
-- @tparam string error_msg Error message for if the signal is not found
|
||||
-- @treturn table The signal table
|
||||
local function find_signal(obj, name, error_msg)
|
||||
check(obj)
|
||||
if not obj._signals[name] then
|
||||
|
@ -34,7 +34,7 @@ local function find_signal(obj, name, error_msg)
|
|||
end
|
||||
|
||||
--- Add a signal to an object. All signals must be added before they can be used.
|
||||
-- @param name The name of the new signal.
|
||||
-- @tparam string 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))
|
||||
|
@ -46,9 +46,9 @@ function object:add_signal(name)
|
|||
end
|
||||
end
|
||||
|
||||
--- Connect to a signal
|
||||
-- @param name The name of the signal
|
||||
-- @param func The callback to call when the signal is emitted
|
||||
--- Connect to a signal.
|
||||
-- @tparam string name The name of the signal
|
||||
-- @tparam function 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")
|
||||
|
@ -88,8 +88,8 @@ end
|
|||
|
||||
--- Connect to a signal weakly. This allows the callback function to be garbage
|
||||
-- collected and automatically disconnects the signal when that happens.
|
||||
-- @param name The name of the signal
|
||||
-- @param func The callback to call when the signal is emitted
|
||||
-- @tparam string name The name of the signal
|
||||
-- @tparam function func The callback to call when the signal is emitted
|
||||
function object:weak_connect_signal(name, func)
|
||||
assert(type(func) == "function", "callback must be a function, got: " .. type(func))
|
||||
local sig = find_signal(self, name, "connect to")
|
||||
|
@ -97,18 +97,18 @@ function object:weak_connect_signal(name, func)
|
|||
sig.weak[func] = make_the_gc_obey(func)
|
||||
end
|
||||
|
||||
--- Disonnect to a signal
|
||||
-- @param name The name of the signal
|
||||
-- @param func The callback that should be disconnected
|
||||
--- Disonnect to a signal.
|
||||
-- @tparam string name The name of the signal
|
||||
-- @tparam function func The callback that should be disconnected
|
||||
function object:disconnect_signal(name, func)
|
||||
local sig = find_signal(self, name, "disconnect from")
|
||||
sig.weak[func] = nil
|
||||
sig.strong[func] = nil
|
||||
end
|
||||
|
||||
--- Emit a signal
|
||||
--- Emit a signal.
|
||||
--
|
||||
-- @param name The name of the signal
|
||||
-- @tparam string name The name of the signal
|
||||
-- @param ... Extra arguments for the callback functions. Each connected
|
||||
-- function receives the object as first argument and then any extra arguments
|
||||
-- that are given to emit_signal()
|
||||
|
|
Loading…
Reference in a new issue