neovim/scripts/geneval.lua
ZyX 5e59916e84 eval: Use generated hash to look up function list
Problems:
- Disables cross-compiling (alternative: keeps two hash implementations which
  need to be synchronized with each other).
- Puts code-specific name literals into CMakeLists.txt.
- Workaround for lua’s absence of bidirectional pipe communication is rather
  ugly.
2016-08-31 21:40:20 +02:00

35 lines
814 B
Lua

local nvimsrcdir = arg[1]
local autodir = arg[2]
if nvimsrcdir == '--help' then
print([[
Usage:
lua geneval.lua src/nvim build/src/nvim/auto
Will generate build/src/nvim/auto/funcs.generated.h with definition of functions
static const array.
]])
os.exit(0)
end
package.path = nvimsrcdir .. '/?.lua;' .. package.path
local funcsfname = autodir .. '/funcs.generated.h'
local funcspipe = io.open(funcsfname .. '.hsh', 'w')
local funcs = require('eval')
for name, def in pairs(funcs.funcs) do
args = def.args or 0
if type(args) == 'number' then
args = {args, args}
elseif #args == 1 then
args[2] = 'MAX_FUNC_ARGS'
end
func = def.func or ('f_' .. name)
local val = ('{ %s, %s, &%s }'):format(args[1], args[2], func)
funcspipe:write(name .. '\n' .. val .. '\n')
end
funcspipe:close()