aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/gendeclarations.lua34
-rw-r--r--src/nvim/msgpack_rpc/helpers.c7
2 files changed, 23 insertions, 18 deletions
diff --git a/scripts/gendeclarations.lua b/scripts/gendeclarations.lua
index 3f948b91df..e999e53e4a 100755
--- a/scripts/gendeclarations.lua
+++ b/scripts/gendeclarations.lua
@@ -69,17 +69,18 @@ local word = branch(
right_word
)
)
+local inline_comment = concat(
+ lit('/*'),
+ any_amount(concat(
+ neg_look_ahead(lit('*/')),
+ any_character
+ )),
+ lit('*/')
+)
local spaces = any_amount(branch(
s,
-- Comments are really handled by preprocessor, so the following is not needed
- concat(
- lit('/*'),
- any_amount(concat(
- neg_look_ahead(lit('*/')),
- any_character
- )),
- lit('*/')
- ),
+ inline_comment,
concat(
lit('//'),
any_amount(concat(
@@ -110,6 +111,7 @@ local typ = one_or_more(typ_part)
local typ_id = two_or_more(typ_part)
local arg = typ_id -- argument name is swallowed by typ
local pattern = concat(
+ any_amount(branch(set(' ', '\t'), inline_comment)),
typ_id, -- return type with function name
spaces,
lit('('),
@@ -197,17 +199,22 @@ local neededfile = fname:match('[^/]+$')
local declline = 0
local declendpos = 0
local curdir = nil
+local is_needed_file = false
while init ~= nil do
- init = text:find('\n', init)
+ init = text:find('[\n;}]', init)
if init == nil then
break
end
+ local init_is_nl = text:sub(init, init) == '\n'
init = init + 1
- declline = declline + 1
- if text:sub(init, init) == '#' then
+ if init_is_nl and is_needed_file then
+ declline = declline + 1
+ end
+ if init_is_nl and text:sub(init, init) == '#' then
local line, dir, file = text:match(filepattern, init)
if file ~= nil then
curfile = file
+ is_needed_file = (curfile == neededfile)
declline = tonumber(line) - 1
local curdir_start = dir:find('src/nvim/')
if curdir_start ~= nil then
@@ -220,7 +227,7 @@ while init ~= nil do
end
elseif init < declendpos then
-- Skipping over declaration
- elseif curfile == neededfile then
+ elseif is_needed_file then
s = init
e = pattern:match(text, init)
if e ~= nil then
@@ -240,11 +247,12 @@ while init ~= nil do
declaration = declaration:gsub(' ?(%*+) ?', ' %1')
declaration = declaration:gsub(' ?(FUNC_ATTR_)', ' %1')
declaration = declaration:gsub(' $', '')
+ declaration = declaration:gsub('^ ', '')
declaration = declaration .. ';'
declaration = declaration .. (' // %s/%s:%u'):format(
curdir, curfile, declline)
declaration = declaration .. '\n'
- if text:sub(s, s + 5) == 'static' then
+ if declaration:sub(1, 6) == 'static' then
static = static .. declaration
else
non_static = non_static .. declaration
diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c
index 94a4f5ce3e..ec35d56978 100644
--- a/src/nvim/msgpack_rpc/helpers.c
+++ b/src/nvim/msgpack_rpc/helpers.c
@@ -30,9 +30,7 @@ static msgpack_sbuffer sbuffer;
#define HANDLE_TYPE_CONVERSION_IMPL(t, lt) \
static bool msgpack_rpc_to_##lt(const msgpack_object *const obj, \
Integer *const arg) \
- REAL_FATTR_NONNULL_ALL REAL_FATTR_WARN_UNUSED_RESULT; \
- static bool msgpack_rpc_to_##lt(const msgpack_object *const obj, \
- Integer *const arg) \
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT \
{ \
if (obj->type != MSGPACK_OBJECT_EXT \
|| obj->via.ext.type + EXT_OBJECT_TYPE_SHIFT != kObjectType##t) { \
@@ -55,8 +53,7 @@ static msgpack_sbuffer sbuffer;
} \
\
static void msgpack_rpc_from_##lt(Integer o, msgpack_packer *res) \
- REAL_FATTR_NONNULL_ARG(2); \
- static void msgpack_rpc_from_##lt(Integer o, msgpack_packer *res) \
+ FUNC_ATTR_NONNULL_ARG(2) \
{ \
msgpack_packer pac; \
msgpack_packer_init(&pac, &sbuffer, msgpack_sbuffer_write); \