summaryrefslogtreecommitdiff
path: root/tex/generic/context/luatex/luatex-basics-gen.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-03-26 13:38:18 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-03-26 13:38:18 +0100
commit788487819ccf38a8478cc2afd88e0c0b088d0ec1 (patch)
tree215addbe3b9e293c2958227e7fc8923880b2e71f /tex/generic/context/luatex/luatex-basics-gen.lua
parentadfe72d5a0c9d7bdc1bd7bc8faabb4d05e21d70a (diff)
downloadcontext-788487819ccf38a8478cc2afd88e0c0b088d0ec1.tar.gz
2016-03-26 13:07:00
Diffstat (limited to 'tex/generic/context/luatex/luatex-basics-gen.lua')
-rw-r--r--tex/generic/context/luatex/luatex-basics-gen.lua38
1 files changed, 29 insertions, 9 deletions
diff --git a/tex/generic/context/luatex/luatex-basics-gen.lua b/tex/generic/context/luatex/luatex-basics-gen.lua
index c4d653604..c298f6dd9 100644
--- a/tex/generic/context/luatex/luatex-basics-gen.lua
+++ b/tex/generic/context/luatex/luatex-basics-gen.lua
@@ -63,15 +63,19 @@ logs = {
}
callbacks = {
- register = function(n,f) return callback.register(n,f) end,
+ register = function(n,f)
+ return callback.register(n,f)
+ end,
}
-utilities = {
- storage = {
- allocate = function(t) return t or { } end,
- mark = function(t) return t or { } end,
- },
+utilities = utilities or { } utilities.storage = {
+ allocate = function(t)
+ return t or { }
+ end,
+ mark = function(t)
+ return t or { }
+ end,
}
characters = characters or {
@@ -355,12 +359,28 @@ end
--
+-- function table.setmetatableindex(t,f)
+-- if type(t) ~= "table" then
+-- f = f or t
+-- t = { }
+-- end
+-- setmetatable(t,{ __index = f })
+-- return t
+-- end
+
function table.setmetatableindex(t,f)
if type(t) ~= "table" then
- f = f or t
- t = { }
+ f, t = t, { }
+ end
+ local m = getmetatable(t)
+ if f == "table" then
+ f = function(t,k) local v = { } t[k] = v return v end
+ end
+ if m then
+ m.__index = f
+ else
+ setmetatable(t,{ __index = f })
end
- setmetatable(t,{ __index = f })
return t
end