refactor(api): give "hl_group" more accurate _meta type

These can either be number or string in lua, so we can specify this
directly as "number|string".
This commit is contained in:
bfredl
2024-01-22 08:49:45 +01:00
parent 646fdf1073
commit d66ed4ea46
5 changed files with 16 additions and 15 deletions

View File

@@ -72,7 +72,6 @@ local keysets = {}
local function add_keyset(val)
local keys = {}
local types = {}
local hlgroups = {}
local is_set_name = 'is_set__' .. val.keyset_name .. '_'
local has_optional = false
for i, field in ipairs(val.fields) do
@@ -81,7 +80,6 @@ local function add_keyset(val)
end
if field.name ~= is_set_name and field.type ~= 'OptionalKeys' then
table.insert(keys, field.name)
hlgroups[field.name] = field.name:find('hl_group') and true or false
else
if i > 1 then
error("'is_set__{type}_' must be first if present")
@@ -97,7 +95,6 @@ local function add_keyset(val)
name = val.keyset_name,
keys = keys,
types = types,
hlgroups = hlgroups,
has_optional = has_optional,
})
end
@@ -285,7 +282,9 @@ for _, k in ipairs(keysets) do
keysets_defs:write('extern KeySetLink ' .. k.name .. '_table[];\n')
local function typename(type)
if type ~= nil then
if type == 'HLGroupID' then
return 'kObjectTypeInteger'
elseif type ~= nil then
return 'kObjectType' .. type
else
return 'kObjectTypeNil'
@@ -311,7 +310,7 @@ for _, k in ipairs(keysets) do
.. ', '
.. ind
.. ', '
.. (k.hlgroups[key] and 'true' or 'false')
.. (k.types[key] == 'HLGroupID' and 'true' or 'false')
.. '},\n'
)
end