mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 05:02:31 +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.
|
||||
local args = {...}
|
||||
local rtorrent = args[1]
|
||||
@@ -19,8 +19,10 @@ function mt.__index (t, key)
|
||||
end
|
||||
rtorrent["autocall"] = setmetatable({}, mt)
|
||||
|
||||
-- Autocall-config Same as autocall, but passes an empty first target
|
||||
-- implicitly, for syntax like `rtorrent.autocall_config.session.directory.set("/tmp/")`
|
||||
-- Autocall-config
|
||||
-- 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 = {}
|
||||
function mt.__call (t, ...)
|
||||
name = table.concat(rawget(t, "__namestack"), ".")
|
||||
@@ -37,6 +39,9 @@ function mt.__index (t, key)
|
||||
table.insert(ns, key)
|
||||
return setmetatable({__namestack=ns}, mt)
|
||||
end
|
||||
function mt.__newindex (t, key, value)
|
||||
t[key].set(value)
|
||||
end
|
||||
rtorrent["autocall_config"] = setmetatable({}, mt)
|
||||
|
||||
return rtorrent
|
||||
|
||||
Reference in New Issue
Block a user