Added "apidocs" target to Makefile
[project/luci.git] / libs / core / luasrc / util.lua
index 48b6fa0..a4ea2d2 100644 (file)
@@ -320,7 +320,7 @@ end
 --- Combines two or more numerically indexed tables into one.
 -- @param tbl1 Table value to combine
 -- @param tbl2 Table value to combine
--- @param tblN More values to combine
+-- @param ...  More tables to combine
 -- @return             Table value containing all values of given tables
 function combine(...)
        local result = {}
@@ -375,6 +375,19 @@ function clone(object, deep)
        return copy
 end
 
+
+--- Create a dynamic table which automatically creates subtables.
+-- @return     Dynamic Table
+function dtable()
+        return setmetatable({}, { __index =
+                function(tbl, key)
+                        return rawget(tbl, key)
+                         or rawget(rawset(tbl, key, dtable()), key)
+                end
+        })
+end
+
+
 -- Serialize the contents of a table value.
 function _serialize_table(t)
        local data = ""