summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/util-sto.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/util-sto.lua')
-rw-r--r--tex/context/base/mkiv/util-sto.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/util-sto.lua b/tex/context/base/mkiv/util-sto.lua
index bcd8c85a3..5b6915eaf 100644
--- a/tex/context/base/mkiv/util-sto.lua
+++ b/tex/context/base/mkiv/util-sto.lua
@@ -158,6 +158,29 @@ function table.setmetatablecall(t,f)
return t
end
+-- the manual is somewhat fuzzy about this but suggests that one can best
+-- set all fields before assigning a metatable
+
+function table.setmetatableindices(t,f,n,c)
+ 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 = i
+ m.__newindex = n
+ m.__call = c
+ else
+ setmetatable(t,{
+ __index = i,
+ __newindex = n,
+ __call = c,
+ })
+ end
+ return t
+end
+
function table.setmetatablekey(t,key,value)
local m = getmetatable(t)
if not m then