mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 15:28:17 +00:00
eval: Add luaeval function
No tests yet, no documentation update, no :lua* stuff, no vim module. converter.c should also work with typval_T, not Object. Known problem: luaeval("1", {}) results in PANIC: unprotected error in call to Lua API (attempt to index a nil value) Ref #3823
This commit is contained in:
38
scripts/generate_vim_module.lua
Normal file
38
scripts/generate_vim_module.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
assert(#arg == 2)
|
||||
|
||||
module_file = arg[1]
|
||||
target_file = arg[2]
|
||||
|
||||
module = io.open(module_file, 'r')
|
||||
target = io.open(target_file, 'w')
|
||||
|
||||
target:write('#include <stdint.h>\n\n')
|
||||
target:write('static const uint8_t vim_module[] = {\n')
|
||||
|
||||
num_bytes = 0
|
||||
MAX_NUM_BYTES = 15 -- 78 / 5: maximum number of bytes on one line
|
||||
target:write(' ')
|
||||
|
||||
increase_num_bytes = function()
|
||||
num_bytes = num_bytes + 1
|
||||
if num_bytes == MAX_NUM_BYTES then
|
||||
num_bytes = 0
|
||||
target:write('\n ')
|
||||
end
|
||||
end
|
||||
|
||||
for line in module:lines() do
|
||||
for i = 1,string.len(line) do
|
||||
byte = string.byte(line, i)
|
||||
assert(byte ~= 0)
|
||||
target:write(string.format(' %3u,', byte))
|
||||
increase_num_bytes()
|
||||
end
|
||||
target:write(string.format(' %3u,', string.byte('\n', 1)))
|
||||
increase_num_bytes()
|
||||
end
|
||||
|
||||
target:write(' 0};\n')
|
||||
|
||||
module:close()
|
||||
target:close()
|
Reference in New Issue
Block a user