some ui improvements

This commit is contained in:
Manuel Simon Hirsig
2016-08-06 16:07:31 +02:00
parent 135ebbd536
commit b94cabfc08
22 changed files with 379 additions and 318 deletions
+60 -60
View File
@@ -1,62 +1,62 @@
local __ = {}
local public_interface_mt = {
__newindex = function()
error('Unsupported operation.', 2)
end,
__index = function(self, key)
if __[self].public[key] then
return __[self].data[key]
else
error('Read of undeclared "'..key..'".', 2)
end
end,
}
local private_interface_mt = {
__newindex = function(self, key, value)
if not __[self].declared[key] then
error('Write of undeclared "'..key..'".', 2)
end
__[self].data[key] = value
end,
__index = function(self, key)
if not __[self].declared[key] then
error('Read of undeclared "'..key..'".', 2)
end
return __[self].data[key]
end,
}
local public_declarator_mt = {
__newindex = function(self, key, value)
if __[self].declared[key] then
error('Multiple declarations of "'..key..'".', 2)
end
__[self].data[key] = value
__[self].public[key] = true
__[self].declared[key] = true
end,
__index = function()
error('Unsupported operation.', 2)
end,
}
local private_declarator_mt = {
__newindex = function(self, key, value)
if __[self].declared[key] then
error('Multiple declarations of "'..key..'".', 2)
end
__[self].data[key] = value
__[self].declared[key] = true
end,
__index = function()
error('Unsupported operation.', 2)
end,
}
function aux_module()
local data, is_public, is_declared, public_interface, private_interface, public, private = {}, {}, {}, {}, {}, {}, {}
setmetatable(public_interface, {
__newindex = function()
error('Unsupported operation.', 2)
end,
__index = function(_, key)
if not is_public[key] then
error('Read of undeclared "'..key..'".', 2)
end
if is_public[key] then
return data[key]
end
end,
__call = function(_, key)
return is_public[key]
end
})
setmetatable(private_interface, {
__newindex = function(_, key, value)
if not is_declared[key] then
error('Write of undeclared "'..key..'".', 2)
end
data[key] = value
end,
__index = function(_, key)
if not is_declared[key] then
error('Read of undeclared "'..key..'".', 2)
end
return data[key]
end,
__call = function(_, key)
return is_declared[key]
end
})
setmetatable(public, {
__newindex = function(_, key, value)
if is_declared[key] then
error('Multiple declarations of "'..key..'".', 2)
end
data[key] = value
is_public[key] = true
is_declared[key] = true
end,
__index = function()
error('Unsupported operation.', 2)
end,
})
setmetatable(private, {
__newindex = function(_, key, value)
if is_declared[key] then
error('Multiple declarations of "'..key..'".', 2)
end
data[key] = value
is_declared[key] = true
end,
__index = function()
error('Unsupported operation.', 2)
end,
})
return { public_interface, private_interface, public, private }
local dataset = {data={}, public={}, declared={}}
local module = {setmetatable({}, public_interface_mt), setmetatable({}, private_interface_mt), setmetatable({}, public_declarator_mt), setmetatable({}, private_declarator_mt)}
for _, component in module do
__[component] = dataset
end
return module
end