27 lines
782 B
Lua
27 lines
782 B
Lua
|
|
-- TODO: I don't like to have such tiny modules. Either merge into another
|
|
-- module or provide the functionality 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
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
return {
|
|
TABLE_TYPE = enum { 'EMPTY', 'SEQUENCE', 'STRING_MAP', 'PURE_MAP', 'MIXED', 'SET' },
|
|
DISPLAY = { HIDE = 1, SMALL = 2, INLINE = 3, EXPAND = 4 },
|
|
}
|