aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/generators/gen_declarations.lua
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-06-13 12:00:58 +0200
committerbfredl <bjorn.linse@gmail.com>2024-07-13 12:30:49 +0200
commit7dffc36e61c46e6adc92cff5944e876446f3c40e (patch)
tree99278b5578dbcf5cbe5e53ca158bfc0de5df58d1 /src/nvim/generators/gen_declarations.lua
parentb0f39f3ef5502c037b5bdb0da3d45d312b7fdc2a (diff)
downloadrneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.tar.gz
rneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.tar.bz2
rneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.zip
refactor(declarations): also generate prototypes for functions in headers
Before this change, "static inline" functions in headers needed to have their function attributes specified in a completely different way. The prototype had to be duplicated, and REAL_FATTR_ had to be used instead of the public FUNC_ATTR_ names. TODO: need a check that a "header.h.inline.generated.h" file is not forgotten when the first "static inline" function with attributes is added to a header (they would just be silently missing).
Diffstat (limited to 'src/nvim/generators/gen_declarations.lua')
-rw-r--r--src/nvim/generators/gen_declarations.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua
index 5d1e586fe6..3bba0aa4b9 100644
--- a/src/nvim/generators/gen_declarations.lua
+++ b/src/nvim/generators/gen_declarations.lua
@@ -2,6 +2,7 @@ local fname = arg[1]
local static_fname = arg[2]
local non_static_fname = arg[3]
local preproc_fname = arg[4]
+local static_basename = arg[5]
local lpeg = vim.lpeg
@@ -235,6 +236,7 @@ local declendpos = 0
local curdir = nil
local is_needed_file = false
local init_is_nl = true
+local any_static = false
while init ~= nil do
if init_is_nl and text:sub(init, init) == '#' then
local line, dir, file = text:match(filepattern, init)
@@ -276,6 +278,9 @@ while init ~= nil do
end
declaration = declaration .. '\n'
if declaration:sub(1, 6) == 'static' then
+ if declaration:find('FUNC_ATTR_') then
+ any_static = true
+ end
static = static .. declaration
else
declaration = 'DLLEXPORT ' .. declaration
@@ -303,6 +308,18 @@ F = io.open(static_fname, 'w')
F:write(static)
F:close()
+if non_static_fname == 'SKIP' then
+ F = io.open(fname, 'r')
+ if any_static then
+ local orig_text = F:read('*a')
+ local pat = '\n#%s?include%s+"' .. static_basename .. '"\n'
+ if not string.find(orig_text, pat) then
+ error('fail: missing include for ' .. static_basename .. ' in ' .. fname)
+ end
+ end
+ return -- only want static declarations
+end
+
-- Before generating the non-static headers, check if the current file (if
-- exists) is different from the new one. If they are the same, we won't touch
-- the current version to avoid triggering an unnecessary rebuilds of modules