aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/generators/gen_eval.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
commit931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch)
treed8c1843a95da5ea0bb4acc09f7e37843d9995c86 /src/nvim/generators/gen_eval.lua
parent142d9041391780ac15b89886a54015fdc5c73995 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-userreg.tar.gz
rneovim-userreg.tar.bz2
rneovim-userreg.zip
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'src/nvim/generators/gen_eval.lua')
-rw-r--r--src/nvim/generators/gen_eval.lua53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/nvim/generators/gen_eval.lua b/src/nvim/generators/gen_eval.lua
index baed6a74c2..7b272c337e 100644
--- a/src/nvim/generators/gen_eval.lua
+++ b/src/nvim/generators/gen_eval.lua
@@ -1,37 +1,23 @@
-local mpack = require('mpack')
+local mpack = vim.mpack
-local nvimsrcdir = arg[1]
-local shared_file = arg[2]
-local autodir = arg[3]
-local metadata_file = arg[4]
-local funcs_file = arg[5]
-
-_G.vim = loadfile(shared_file)()
-
-if nvimsrcdir == '--help' then
- print([[
-Usage:
- lua gen_eval.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 autodir = arg[1]
+local metadata_file = arg[2]
+local funcs_file = arg[3]
local funcsfname = autodir .. '/funcs.generated.h'
+--Will generate funcs.generated.h with definition of functions static const array.
+
local hashy = require'generators.hashy'
-local hashpipe = io.open(funcsfname, 'wb')
+local hashpipe = assert(io.open(funcsfname, 'wb'))
hashpipe:write([[
#include "nvim/arglist.h"
#include "nvim/cmdexpand.h"
#include "nvim/cmdhist.h"
#include "nvim/digraph.h"
+#include "nvim/eval.h"
#include "nvim/eval/buffer.h"
#include "nvim/eval/funcs.h"
#include "nvim/eval/typval.h"
@@ -46,11 +32,16 @@ hashpipe:write([[
#include "nvim/match.h"
#include "nvim/mbyte.h"
#include "nvim/menu.h"
+#include "nvim/mouse.h"
#include "nvim/move.h"
#include "nvim/quickfix.h"
+#include "nvim/runtime.h"
#include "nvim/search.h"
+#include "nvim/state.h"
+#include "nvim/strings.h"
#include "nvim/sign.h"
#include "nvim/testing.h"
+#include "nvim/undo.h"
]])
@@ -62,7 +53,7 @@ for _, func in pairs(funcs) do
end
end
-local metadata = mpack.unpack(io.open(metadata_file, 'rb'):read("*all"))
+local metadata = mpack.decode(io.open(metadata_file, 'rb'):read("*all"))
for _,fun in ipairs(metadata) do
if fun.eval then
funcs[fun.name] = {
@@ -73,16 +64,22 @@ for _,fun in ipairs(metadata) do
end
end
-local func_names = vim.tbl_keys(funcs)
+local func_names = vim.tbl_filter(function(name)
+ return name:match('__%d*$') == nil
+end, vim.tbl_keys(funcs))
+
table.sort(func_names)
-local funcsdata = io.open(funcs_file, 'w')
-funcsdata:write(mpack.pack(func_names))
+
+local funcsdata = assert(io.open(funcs_file, 'w'))
+funcsdata:write(mpack.encode(func_names))
funcsdata:close()
local neworder, hashfun = hashy.hashy_hash("find_internal_func", func_names, function (idx)
return "functions["..idx.."].name"
end)
+
hashpipe:write("static const EvalFuncDef functions[] = {\n")
+
for _, name in ipairs(neworder) do
local def = funcs[name]
local args = def.args or 0
@@ -93,12 +90,12 @@ for _, name in ipairs(neworder) do
end
local base = def.base or "BASE_NONE"
local func = def.func or ('f_' .. name)
- local data = def.data or "{ .nullptr = NULL }"
+ local data = def.data or "{ .null = NULL }"
local fast = def.fast and 'true' or 'false'
hashpipe:write((' { "%s", %s, %s, %s, %s, &%s, %s },\n')
:format(name, args[1], args[2], base, fast, func, data))
end
-hashpipe:write(' { NULL, 0, 0, BASE_NONE, false, NULL, { .nullptr = NULL } },\n')
+hashpipe:write(' { NULL, 0, 0, BASE_NONE, false, NULL, { .null = NULL } },\n')
hashpipe:write("};\n\n")
hashpipe:write(hashfun)
hashpipe:close()