summaryrefslogtreecommitdiff
path: root/src/fontloader/runtime/fontloader-basics-gen.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/fontloader/runtime/fontloader-basics-gen.lua')
-rw-r--r--src/fontloader/runtime/fontloader-basics-gen.lua38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/fontloader/runtime/fontloader-basics-gen.lua b/src/fontloader/runtime/fontloader-basics-gen.lua
index c4d6536..c298f6d 100644
--- a/src/fontloader/runtime/fontloader-basics-gen.lua
+++ b/src/fontloader/runtime/fontloader-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