From ce17332266dff01cfb9f83edbf10b7e080a770ca Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 21 Nov 2015 16:35:59 +0100 Subject: sync with Context as of 2015-11-21 --- lualibs-util-sto.lua | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'lualibs-util-sto.lua') 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 -- cgit v1.2.3