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