2017-04-03 09:24:51 +00:00
|
|
|
|
2017-07-17 19:33:11 +00:00
|
|
|
-- TODO: I don't like to have such tiny modules. Either merge into another
|
|
|
|
-- module or provide the funtionallity with another approach.
|
|
|
|
|
2017-04-03 09:24:51 +00:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- Enum
|
|
|
|
|
|
|
|
local enum_metatable = {
|
|
|
|
__tostring = function (e) return 'Enum:' .. e.name or 'Enum: no name' end,
|
|
|
|
__concat = function (a, b) return tostring(a) .. tostring(b) end,
|
|
|
|
}
|
|
|
|
|
|
|
|
local function enum (t)
|
|
|
|
local e = {}
|
|
|
|
for _, v in ipairs(t) do
|
|
|
|
e[v] = setmetatable({ name = v }, enum_metatable)
|
|
|
|
end
|
|
|
|
return e
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
local TABLE_TYPE = enum { 'EMPTY', 'SEQUENCE', 'STRING_MAP', 'PURE_MAP', 'MIXED', 'SET' }
|
|
|
|
|
|
|
|
return TABLE_TYPE
|