summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-25 14:12:27 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-25 14:18:07 +0100
commitfe363eed4fd96c4443c4ca9ffe13c2c47c9efe0e (patch)
tree593930c9d84a062e86217f70f299df6170633c13 /lib
parent05f5c01ba6b609f8b15574412fd874adda322590 (diff)
downloadclod-fe363eed4fd96c4443c4ca9ffe13c2c47c9efe0e.tar.gz
Support migrating lists, which Gitano needs at least short-term
Diffstat (limited to 'lib')
-rw-r--r--lib/clod.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/clod.lua b/lib/clod.lua
index 4114fd6..8f9ec7f 100644
--- a/lib/clod.lua
+++ b/lib/clod.lua
@@ -293,7 +293,7 @@ function clod_mt:__index(key)
end
end
-local function parse_config(conf, confname)
+local function parse_config(conf, confname, migrate_lists)
local ret = {}
local settings = {}
local last_entry = {lineno = 0}
@@ -316,16 +316,28 @@ local function parse_config(conf, confname)
end
function parse_mt:__newindex(key, value)
-- This is the equivalent of 'foo = "bar"' instead of 'foo "bar"'
+ if migrate_lists and type(value) == "table" then
+ for i = 1, #value do
+ self[key .. ".*"](value[i],1)
+ end
+ return
+ end
if type(value) == "table" or type(value) == "function" then
error("Clod does not support " .. type(value) .. "s as values")
end
return self[key](value, 1)
end
function parse_mt:__call(value, offset)
+ local key = assert(keys[self])
+ if migrate_lists and type(value) == "table" then
+ for i = 1, #value do
+ self["*"](value[i],2)
+ end
+ return
+ end
if type(value) == "table" or type(value) == "function" then
error("Clod does not support " .. type(value) .. "s as values")
end
- local key = assert(keys[self])
local wild_prefix, last_key_element = key:match("^(.-)([^.]+)$")
if last_key_element == "*" then
-- Wild insert, so calculate a unique key to use