26 lines
734 B
Lua
26 lines
734 B
Lua
|
|
-- TODO: I don't like to have such tiny modules. Either merge into another
|
|
-- module or provide the funtionallity with another approach.
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- 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
|