diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2015-11-21 16:35:59 +0100 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2015-11-21 16:35:59 +0100 |
commit | ce17332266dff01cfb9f83edbf10b7e080a770ca (patch) | |
tree | fc842ed016caa9f5d20de15b8f9a706c009de5e9 /lualibs-util-sto.lua | |
parent | 4295a3eb51db73a87774d59fb3a38a54690319f7 (diff) | |
download | lualibs-ce17332266dff01cfb9f83edbf10b7e080a770ca.tar.gz |
sync with Context as of 2015-11-21
Diffstat (limited to 'lualibs-util-sto.lua')
-rw-r--r-- | lualibs-util-sto.lua | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/lualibs-util-sto.lua b/lualibs-util-sto.lua index 8aafca4..d21267d 100644 --- a/lualibs-util-sto.lua +++ b/lualibs-util-sto.lua @@ -113,22 +113,16 @@ local f_index = { ["number"] = f_number, } -local t_index = { - ["empty"] = { __index = f_empty }, - ["self"] = { __index = f_self }, - ["table"] = { __index = f_table }, - ["number"] = { __index = f_number }, -} - function table.setmetatableindex(t,f) if type(t) ~= "table" then f, t = t, { } end local m = getmetatable(t) + local i = f_index[f] or f if m then - m.__index = f_index[f] or f + m.__index = i else - setmetatable(t,t_index[f] or { __index = f }) + setmetatable(t,{ __index = i }) end return t end @@ -137,19 +131,16 @@ local f_index = { ["ignore"] = f_ignore, } -local t_index = { - ["ignore"] = { __newindex = f_ignore }, -} - function table.setmetatablenewindex(t,f) if type(t) ~= "table" then f, t = t, { } end local m = getmetatable(t) + local i = f_index[f] or f if m then - m.__newindex = f_index[f] or f + m.__newindex = i else - setmetatable(t,t_index[f] or { __newindex = f }) + setmetatable(t,{ __newindex = i }) end return t end |