mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-17 22:56:18 +00:00
feat(lua): Add autocall_config assignment semantic
This commit is contained in:
+8
-3
@@ -1,4 +1,4 @@
|
|||||||
-- the "rtorrent" table is passed in by the C++ code, modify and
|
-- The "rtorrent" table is passed in by the C++ code, modify and
|
||||||
-- return it for loading.
|
-- return it for loading.
|
||||||
local args = {...}
|
local args = {...}
|
||||||
local rtorrent = args[1]
|
local rtorrent = args[1]
|
||||||
@@ -19,8 +19,10 @@ function mt.__index (t, key)
|
|||||||
end
|
end
|
||||||
rtorrent["autocall"] = setmetatable({}, mt)
|
rtorrent["autocall"] = setmetatable({}, mt)
|
||||||
|
|
||||||
-- Autocall-config Same as autocall, but passes an empty first target
|
-- Autocall-config
|
||||||
-- implicitly, for syntax like `rtorrent.autocall_config.session.directory.set("/tmp/")`
|
-- Same as autocall, but passes an empty first target implicitly, for syntax
|
||||||
|
-- like `rtorrent.autocall_config.session.directory.set("/tmp/")` or
|
||||||
|
-- like `rtorrent.autocall_config.session.directory = "/tmp/"`
|
||||||
local mt = {}
|
local mt = {}
|
||||||
function mt.__call (t, ...)
|
function mt.__call (t, ...)
|
||||||
name = table.concat(rawget(t, "__namestack"), ".")
|
name = table.concat(rawget(t, "__namestack"), ".")
|
||||||
@@ -37,6 +39,9 @@ function mt.__index (t, key)
|
|||||||
table.insert(ns, key)
|
table.insert(ns, key)
|
||||||
return setmetatable({__namestack=ns}, mt)
|
return setmetatable({__namestack=ns}, mt)
|
||||||
end
|
end
|
||||||
|
function mt.__newindex (t, key, value)
|
||||||
|
t[key].set(value)
|
||||||
|
end
|
||||||
rtorrent["autocall_config"] = setmetatable({}, mt)
|
rtorrent["autocall_config"] = setmetatable({}, mt)
|
||||||
|
|
||||||
return rtorrent
|
return rtorrent
|
||||||
|
|||||||
Reference in New Issue
Block a user