From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/clint.py | 31 ++--- src/mpack/lmpack.c | 2 +- src/nvim/api/autocmd.c | 2 +- src/nvim/api/buffer.c | 4 +- src/nvim/api/command.c | 6 +- src/nvim/api/extmark.h | 4 +- src/nvim/api/options.c | 4 +- src/nvim/api/private/converter.c | 4 +- src/nvim/api/private/helpers.c | 4 +- src/nvim/api/private/helpers.h | 4 +- src/nvim/api/private/validate.c | 2 +- src/nvim/api/private/validate.h | 4 +- src/nvim/api/ui.c | 6 +- src/nvim/api/ui.h | 2 +- src/nvim/api/vim.c | 6 +- src/nvim/api/vimscript.c | 4 +- src/nvim/api/win_config.c | 4 +- src/nvim/arabic.c | 4 +- src/nvim/arglist.c | 6 +- src/nvim/ascii.h | 185 ------------------------- src/nvim/ascii_defs.h | 185 +++++++++++++++++++++++++ src/nvim/assert.h | 167 ----------------------- src/nvim/assert_defs.h | 167 +++++++++++++++++++++++ src/nvim/autocmd.c | 6 +- src/nvim/autocmd.h | 2 +- src/nvim/buffer.c | 8 +- src/nvim/buffer.h | 2 +- src/nvim/buffer_defs.h | 2 +- src/nvim/buffer_updates.c | 2 +- src/nvim/bufwrite.c | 8 +- src/nvim/change.c | 8 +- src/nvim/channel.h | 4 +- src/nvim/charset.c | 6 +- src/nvim/cmdexpand.c | 6 +- src/nvim/cmdhist.c | 6 +- src/nvim/cursor.c | 8 +- src/nvim/cursor_shape.c | 6 +- src/nvim/debugger.c | 6 +- src/nvim/decoration.h | 2 +- src/nvim/decoration_provider.h | 2 +- src/nvim/diff.c | 4 +- src/nvim/diff.h | 2 +- src/nvim/digraph.c | 4 +- src/nvim/drawline.c | 4 +- src/nvim/drawline.h | 2 +- src/nvim/drawscreen.c | 4 +- src/nvim/drawscreen.h | 2 +- src/nvim/edit.c | 6 +- src/nvim/eval.c | 8 +- src/nvim/eval.h | 2 +- src/nvim/eval/buffer.c | 6 +- src/nvim/eval/decode.c | 6 +- src/nvim/eval/encode.c | 6 +- src/nvim/eval/executor.c | 2 +- src/nvim/eval/funcs.c | 8 +- src/nvim/eval/typval.c | 8 +- src/nvim/eval/typval.h | 2 +- src/nvim/eval/userfunc.c | 6 +- src/nvim/eval/vars.c | 6 +- src/nvim/eval/window.c | 6 +- src/nvim/eval/window.h | 2 +- src/nvim/event/rstream.c | 2 +- src/nvim/event/socket.c | 2 +- src/nvim/event/wstream.c | 2 +- src/nvim/ex_cmds.c | 6 +- src/nvim/ex_cmds2.c | 6 +- src/nvim/ex_docmd.c | 6 +- src/nvim/ex_eval.c | 4 +- src/nvim/ex_getln.c | 8 +- src/nvim/ex_session.c | 6 +- src/nvim/extmark.c | 2 +- src/nvim/extmark.h | 2 +- src/nvim/file_search.c | 6 +- src/nvim/fileio.c | 8 +- src/nvim/fold.c | 4 +- src/nvim/fold.h | 2 +- src/nvim/func_attr.h | 2 +- src/nvim/generators/gen_api_dispatch.lua | 2 +- src/nvim/getchar.c | 6 +- src/nvim/globals.h | 6 +- src/nvim/grid.c | 6 +- src/nvim/grid.h | 2 +- src/nvim/hashtab.c | 4 +- src/nvim/help.c | 6 +- src/nvim/highlight.c | 6 +- src/nvim/highlight_defs.h | 2 +- src/nvim/highlight_group.c | 8 +- src/nvim/iconv.h | 13 -- src/nvim/iconv_defs.h | 13 ++ src/nvim/indent.c | 6 +- src/nvim/indent_c.c | 6 +- src/nvim/input.c | 4 +- src/nvim/insexpand.c | 6 +- src/nvim/insexpand.h | 4 +- src/nvim/keycodes.c | 6 +- src/nvim/keycodes.h | 2 +- src/nvim/linematch.c | 2 +- src/nvim/log.c | 2 +- src/nvim/log.h | 2 +- src/nvim/lua/converter.c | 6 +- src/nvim/lua/executor.c | 6 +- src/nvim/lua/executor.h | 6 +- src/nvim/lua/spell.c | 2 +- src/nvim/lua/stdlib.c | 6 +- src/nvim/lua/treesitter.c | 4 +- src/nvim/lua/xdiff.c | 4 +- src/nvim/macros.h | 212 ----------------------------- src/nvim/macros_defs.h | 212 +++++++++++++++++++++++++++++ src/nvim/main.c | 6 +- src/nvim/map.c | 2 +- src/nvim/map.h | 226 ------------------------------- src/nvim/map_defs.h | 226 +++++++++++++++++++++++++++++++ src/nvim/map_glyph_cache.c | 6 +- src/nvim/map_key_impl.c.h | 2 +- src/nvim/map_value_impl.c.h | 4 +- src/nvim/mapping.c | 6 +- src/nvim/mark.c | 4 +- src/nvim/mark.h | 4 +- src/nvim/mark_defs.h | 2 +- src/nvim/marktree.c | 2 +- src/nvim/marktree.h | 4 +- src/nvim/match.c | 6 +- src/nvim/mbyte.c | 8 +- src/nvim/mbyte.h | 2 +- src/nvim/mbyte_defs.h | 2 +- src/nvim/memfile.c | 6 +- src/nvim/memfile_defs.h | 2 +- src/nvim/memline.c | 8 +- src/nvim/memory.c | 4 +- src/nvim/memory.h | 7 +- src/nvim/menu.c | 6 +- src/nvim/message.c | 4 +- src/nvim/message.h | 2 +- src/nvim/mouse.c | 6 +- src/nvim/mouse.h | 2 +- src/nvim/move.c | 6 +- src/nvim/move.h | 2 +- src/nvim/msgpack_rpc/channel.c | 2 +- src/nvim/msgpack_rpc/channel.h | 2 +- src/nvim/msgpack_rpc/channel_defs.h | 2 +- src/nvim/msgpack_rpc/helpers.c | 2 +- src/nvim/msgpack_rpc/unpacker.c | 4 +- src/nvim/normal.c | 6 +- src/nvim/normal.h | 4 +- src/nvim/ops.c | 8 +- src/nvim/ops.h | 4 +- src/nvim/option.c | 6 +- src/nvim/option_vars.h | 2 +- src/nvim/optionstr.c | 6 +- src/nvim/os/env.c | 8 +- src/nvim/os/fileio.c | 2 +- src/nvim/os/fs.c | 6 +- src/nvim/os/input.c | 6 +- src/nvim/os/input.h | 2 +- src/nvim/os/lang.c | 6 +- src/nvim/os/os_win_console.c | 2 +- src/nvim/os/process.c | 2 +- src/nvim/os/pty_conpty_win.c | 2 +- src/nvim/os/pty_process_win.c | 2 +- src/nvim/os/shell.c | 6 +- src/nvim/os/stdpaths.c | 2 +- src/nvim/os/time.h | 3 +- src/nvim/os/time_defs.h | 4 + src/nvim/os/users.c | 4 +- src/nvim/path.c | 6 +- src/nvim/plines.c | 6 +- src/nvim/popupmenu.c | 4 +- src/nvim/popupmenu.h | 2 +- src/nvim/profile.c | 2 +- src/nvim/quickfix.c | 6 +- src/nvim/rbuffer.c | 2 +- src/nvim/regexp.c | 6 +- src/nvim/runtime.c | 8 +- src/nvim/search.c | 6 +- src/nvim/search.h | 2 +- src/nvim/sha256.c | 2 +- src/nvim/shada.c | 8 +- src/nvim/sign.c | 8 +- src/nvim/spell.c | 6 +- src/nvim/spell.h | 2 +- src/nvim/spellfile.c | 6 +- src/nvim/spellsuggest.c | 6 +- src/nvim/state.c | 6 +- src/nvim/statusline.c | 6 +- src/nvim/statusline.h | 2 +- src/nvim/statusline_defs.h | 2 +- src/nvim/strings.c | 8 +- src/nvim/strings.h | 2 +- src/nvim/syntax.c | 6 +- src/nvim/syntax.h | 2 +- src/nvim/tag.c | 6 +- src/nvim/terminal.c | 8 +- src/nvim/testing.c | 6 +- src/nvim/textformat.c | 6 +- src/nvim/textobject.c | 6 +- src/nvim/textobject.h | 2 +- src/nvim/tui/input.c | 4 +- src/nvim/tui/terminfo.c | 2 +- src/nvim/tui/tui.c | 4 +- src/nvim/ui.c | 6 +- src/nvim/ui.h | 2 +- src/nvim/ui_client.h | 2 +- src/nvim/ui_compositor.c | 6 +- src/nvim/undo.c | 6 +- src/nvim/usercmd.c | 6 +- src/nvim/version.c | 4 +- src/nvim/version.h | 2 +- src/nvim/vim.h | 204 ---------------------------- src/nvim/vim_defs.h | 204 ++++++++++++++++++++++++++++ src/nvim/viml/parser/expressions.c | 8 +- src/nvim/window.c | 8 +- src/nvim/window.h | 2 +- src/nvim/winfloat.c | 6 +- 213 files changed, 1463 insertions(+), 1468 deletions(-) delete mode 100644 src/nvim/ascii.h create mode 100644 src/nvim/ascii_defs.h delete mode 100644 src/nvim/assert.h create mode 100644 src/nvim/assert_defs.h delete mode 100644 src/nvim/iconv.h create mode 100644 src/nvim/iconv_defs.h delete mode 100644 src/nvim/macros.h create mode 100644 src/nvim/macros_defs.h delete mode 100644 src/nvim/map.h create mode 100644 src/nvim/map_defs.h create mode 100644 src/nvim/os/time_defs.h delete mode 100644 src/nvim/vim.h create mode 100644 src/nvim/vim_defs.h (limited to 'src') diff --git a/src/clint.py b/src/clint.py index 9daa1ad21f..91fee4917a 100755 --- a/src/clint.py +++ b/src/clint.py @@ -903,8 +903,8 @@ def CheckIncludes(filename, lines, error): "src/nvim/api/private/helpers.h", "src/nvim/api/private/validate.h", "src/nvim/api/ui.h", - "src/nvim/ascii.h", - "src/nvim/assert.h", + "src/nvim/ascii_defs.h", + "src/nvim/assert_defs.h", "src/nvim/autocmd.h", "src/nvim/autocmd_defs.h", "src/nvim/buffer.h", @@ -916,7 +916,6 @@ def CheckIncludes(filename, lines, error): "src/nvim/cmdhist.h", "src/nvim/context.h", "src/nvim/decoration.h", - "src/nvim/decoration_defs.h", "src/nvim/decoration_provider.h", "src/nvim/diff.h", "src/nvim/drawline.h", @@ -943,7 +942,6 @@ def CheckIncludes(filename, lines, error): "src/nvim/ex_docmd.h", "src/nvim/ex_getln.h", "src/nvim/extmark.h", - "src/nvim/extmark_defs.h", "src/nvim/file_search.h", "src/nvim/fileio.h", "src/nvim/fold.h", @@ -952,23 +950,15 @@ def CheckIncludes(filename, lines, error): "src/nvim/globals.h", "src/nvim/grid.h", "src/nvim/highlight.h", - "src/nvim/highlight_defs.h", "src/nvim/highlight_group.h", "src/nvim/input.h", "src/nvim/insexpand.h", "src/nvim/keycodes.h", "src/nvim/log.h", "src/nvim/lua/executor.h", - "src/nvim/macros.h", "src/nvim/main.h", - "src/nvim/map.h", "src/nvim/mark.h", - "src/nvim/mark_defs.h", "src/nvim/marktree.h", - "src/nvim/mbyte.h", - "src/nvim/mbyte_defs.h", - "src/nvim/memfile_defs.h", - "src/nvim/memory.h", "src/nvim/message.h", "src/nvim/mouse.h", "src/nvim/move.h", @@ -976,10 +966,8 @@ def CheckIncludes(filename, lines, error): "src/nvim/msgpack_rpc/channel_defs.h", "src/nvim/msgpack_rpc/helpers.h", "src/nvim/msgpack_rpc/unpacker.h", - "src/nvim/normal.h", "src/nvim/ops.h", "src/nvim/option.h", - "src/nvim/option_vars.h", "src/nvim/os/fileio.h", "src/nvim/os/input.h", "src/nvim/os/pty_conpty_win.h", @@ -990,9 +978,6 @@ def CheckIncludes(filename, lines, error): "src/nvim/popupmenu.h", "src/nvim/search.h", "src/nvim/spell.h", - "src/nvim/statusline.h", - "src/nvim/statusline_defs.h", - "src/nvim/strings.h", "src/nvim/syntax.h", "src/nvim/textformat.h", "src/nvim/textobject.h", @@ -1001,13 +986,19 @@ def CheckIncludes(filename, lines, error): "src/nvim/ui.h", "src/nvim/ui_client.h", "src/nvim/ui_compositor.h", - "src/nvim/version.h", - "src/nvim/vim.h", + "src/nvim/vim_defs.h", "src/nvim/viml/parser/expressions.h", "src/nvim/viml/parser/parser.h", "src/nvim/window.h", ] + skip_headers = [ + "klib/kvec.h", + "klib/klist.h", + "auto/config.h", + "nvim/func_attr.h" + ] + for i in check_includes_ignore: if filename.endswith(i): return @@ -1016,6 +1007,8 @@ def CheckIncludes(filename, lines, error): matched = Match(r'#\s*include\s*"([^"]*)"', line) if matched: name = matched.group(1) + if name in skip_headers: + continue if (not name.endswith('.h.generated.h') and not name.endswith('_defs.h') and not name.endswith('/defs.h')): diff --git a/src/mpack/lmpack.c b/src/mpack/lmpack.c index 6e693bcc5d..ff21e29789 100644 --- a/src/mpack/lmpack.c +++ b/src/mpack/lmpack.c @@ -24,7 +24,7 @@ #include #include -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "lmpack.h" diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c index 96d330f92b..08d9d8e117 100644 --- a/src/nvim/api/autocmd.c +++ b/src/nvim/api/autocmd.c @@ -21,7 +21,7 @@ #include "nvim/globals.h" #include "nvim/lua/executor.h" #include "nvim/memory.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/autocmd.c.generated.h" diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 3f4ab2760d..96e0e240f2 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -14,7 +14,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -36,7 +36,7 @@ #include "nvim/pos_defs.h" #include "nvim/types_defs.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/buffer.c.generated.h" diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index f9e2c58dd9..2a57ce9a19 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -11,7 +11,7 @@ #include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer_defs.h" #include "nvim/cmdexpand_defs.h" @@ -22,7 +22,7 @@ #include "nvim/garray.h" #include "nvim/globals.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/ops.h" @@ -31,7 +31,7 @@ #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/usercmd.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/api/extmark.h b/src/nvim/api/extmark.h index 491e468d95..124feaabfb 100644 --- a/src/nvim/api/extmark.h +++ b/src/nvim/api/extmark.h @@ -5,8 +5,8 @@ #include "nvim/api/keysets_defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/decoration_defs.h" // IWYU pragma: keep -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/types_defs.h" EXTERN Map(String, int) namespace_ids INIT( = MAP_INIT); diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index d08a44b0ad..c012a69c7b 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -13,11 +13,11 @@ #include "nvim/eval/window.h" #include "nvim/func_attr.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/option.h" #include "nvim/option_vars.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c index 40ec680184..90023171e5 100644 --- a/src/nvim/api/private/converter.c +++ b/src/nvim/api/private/converter.c @@ -7,7 +7,7 @@ #include "nvim/api/private/converter.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/assert.h" +#include "nvim/assert_defs.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" @@ -15,7 +15,7 @@ #include "nvim/lua/executor.h" #include "nvim/memory.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// Helper structure for vim_to_object typedef struct { diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 2599850452..be39836a5b 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -14,7 +14,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" @@ -25,7 +25,7 @@ #include "nvim/globals.h" #include "nvim/highlight_group.h" #include "nvim/lua/executor.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/mark.h" #include "nvim/memline.h" #include "nvim/memory.h" diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index 56ca9b2057..e61dd5f992 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -13,8 +13,8 @@ #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #include "nvim/message.h" diff --git a/src/nvim/api/private/validate.c b/src/nvim/api/private/validate.c index 17e9d081a6..e198c671eb 100644 --- a/src/nvim/api/private/validate.c +++ b/src/nvim/api/private/validate.c @@ -5,7 +5,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/globals.h" /// Creates "Invalid …" message and sets it on `err`. diff --git a/src/nvim/api/private/validate.h b/src/nvim/api/private/validate.h index 29ca6242f3..d1c977cd6e 100644 --- a/src/nvim/api/private/validate.h +++ b/src/nvim/api/private/validate.h @@ -5,8 +5,8 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/assert.h" -#include "nvim/macros.h" +#include "nvim/assert_defs.h" +#include "nvim/macros_defs.h" #define VALIDATE(cond, fmt_, fmt_arg1, code) \ do { \ diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 9eb1cc675f..bf554a8829 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -21,9 +21,9 @@ #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/msgpack_rpc/channel.h" @@ -31,7 +31,7 @@ #include "nvim/option.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #define BUF_POS(data) ((size_t)((data)->buf_wptr - (data)->buf)) diff --git a/src/nvim/api/ui.h b/src/nvim/api/ui.h index 051153de83..26a91d0dbc 100644 --- a/src/nvim/api/ui.h +++ b/src/nvim/api/ui.h @@ -4,7 +4,7 @@ #include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/highlight_defs.h" // IWYU pragma: keep -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/types_defs.h" // IWYU pragma: keep #include "nvim/ui.h" diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index ad111510e5..fdf12cba9e 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -18,7 +18,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" #include "nvim/api/vim.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/channel.h" @@ -40,7 +40,7 @@ #include "nvim/keycodes.h" #include "nvim/log.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/mark.h" #include "nvim/mbyte.h" @@ -67,7 +67,7 @@ #include "nvim/terminal.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #define LINE_BUFFER_MIN_SIZE 4096 diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 233da2dd9f..c75bf21572 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -10,7 +10,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/vimscript.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" @@ -20,7 +20,7 @@ #include "nvim/globals.h" #include "nvim/memory.h" #include "nvim/runtime.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/viml/parser/expressions.h" #include "nvim/viml/parser/parser.h" diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index f980c277d1..874be200ee 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -8,7 +8,7 @@ #include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/api/win_config.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer_defs.h" #include "nvim/decoration.h" @@ -17,7 +17,7 @@ #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight_group.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/option.h" diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index e5ebd84cb3..84f4297c99 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -21,9 +21,9 @@ #include #include "nvim/arabic.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/func_attr.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/option_vars.h" // Unicode values for Arabic characters. diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index 7854b9a9a2..d2734e6c5a 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -7,7 +7,7 @@ #include "auto/config.h" #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/charset.h" @@ -24,7 +24,7 @@ #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/memline_defs.h" #include "nvim/memory.h" @@ -38,7 +38,7 @@ #include "nvim/types_defs.h" #include "nvim/undo.h" #include "nvim/version.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" /// State used by the :all command to open all the files in the argument list in diff --git a/src/nvim/ascii.h b/src/nvim/ascii.h deleted file mode 100644 index efe00d5e4d..0000000000 --- a/src/nvim/ascii.h +++ /dev/null @@ -1,185 +0,0 @@ -#pragma once - -#include - -#include "nvim/func_attr.h" -#include "nvim/macros.h" -#include "nvim/os/os_defs.h" - -// Definitions of various common control characters. - -#define CHAR_ORD(x) ((uint8_t)(x) < 'a' \ - ? (uint8_t)(x) - 'A' \ - : (uint8_t)(x) - 'a') -#define CHAR_ORD_LOW(x) ((uint8_t)(x) - 'a') -#define CHAR_ORD_UP(x) ((uint8_t)(x) - 'A') -#define ROT13(c, a) (((((c) - (a)) + 13) % 26) + (a)) - -#define NUL '\000' -#define BELL '\007' -#define BS '\010' -#define TAB '\011' -#define NL '\012' -#define NL_STR "\012" -#define FF '\014' -#define CAR '\015' // CR is used by Mac OS X -#define ESC '\033' -#define ESC_STR "\033" -#define DEL 0x7f -#define DEL_STR "\177" -#define CSI 0x9b // Control Sequence Introducer -#define CSI_STR "\233" -#define DCS 0x90 // Device Control String -#define STERM 0x9c // String Terminator - -#define POUND 0xA3 - -#define CTRL_CHR(x) (TOUPPER_ASC(x) ^ 0x40) // '?' -> DEL, '@' -> ^@, etc. -#define META(x) ((x) | 0x80) - -#define CTRL_F_STR "\006" -#define CTRL_H_STR "\010" -#define CTRL_V_STR "\026" - -#define Ctrl_AT 0 // @ -#define Ctrl_A 1 -#define Ctrl_B 2 -#define Ctrl_C 3 -#define Ctrl_D 4 -#define Ctrl_E 5 -#define Ctrl_F 6 -#define Ctrl_G 7 -#define Ctrl_H 8 -#define Ctrl_I 9 -#define Ctrl_J 10 -#define Ctrl_K 11 -#define Ctrl_L 12 -#define Ctrl_M 13 -#define Ctrl_N 14 -#define Ctrl_O 15 -#define Ctrl_P 16 -#define Ctrl_Q 17 -#define Ctrl_R 18 -#define Ctrl_S 19 -#define Ctrl_T 20 -#define Ctrl_U 21 -#define Ctrl_V 22 -#define Ctrl_W 23 -#define Ctrl_X 24 -#define Ctrl_Y 25 -#define Ctrl_Z 26 -// CTRL- [ Left Square Bracket == ESC -#define Ctrl_BSL 28 // \ BackSLash -#define Ctrl_RSB 29 // ] Right Square Bracket -#define Ctrl_HAT 30 // ^ -#define Ctrl__ 31 - -// Character that separates dir names in a path. -#ifdef BACKSLASH_IN_FILENAME -# define PATHSEP psepc -# define PATHSEPSTR pseps -#else -# define PATHSEP '/' -# define PATHSEPSTR "/" -#endif - -static inline bool ascii_iswhite(int c) - REAL_FATTR_CONST - REAL_FATTR_ALWAYS_INLINE; - -static inline bool ascii_iswhite_or_nul(int c) - REAL_FATTR_CONST - REAL_FATTR_ALWAYS_INLINE; - -static inline bool ascii_isdigit(int c) - REAL_FATTR_CONST - REAL_FATTR_ALWAYS_INLINE; - -static inline bool ascii_isxdigit(int c) - REAL_FATTR_CONST - REAL_FATTR_ALWAYS_INLINE; - -static inline bool ascii_isident(int c) - REAL_FATTR_CONST - REAL_FATTR_ALWAYS_INLINE; - -static inline bool ascii_isbdigit(int c) - REAL_FATTR_CONST - REAL_FATTR_ALWAYS_INLINE; - -static inline bool ascii_isspace(int c) - REAL_FATTR_CONST - REAL_FATTR_ALWAYS_INLINE; - -/// Checks if `c` is a space or tab character. -/// -/// @see {ascii_isdigit} -static inline bool ascii_iswhite(int c) -{ - return c == ' ' || c == '\t'; -} - -/// Checks if `c` is a space or tab character or NUL. -/// -/// @see {ascii_isdigit} -static inline bool ascii_iswhite_or_nul(int c) -{ - return ascii_iswhite(c) || c == NUL; -} - -/// Check whether character is a decimal digit. -/// -/// Library isdigit() function is officially locale-dependent and, for -/// example, returns true for superscript 1 (¹) in locales where encoding -/// contains it in lower 8 bits. Also avoids crashes in case c is below -/// 0 or above 255: library functions are officially defined as accepting -/// only EOF and unsigned char values (otherwise it is undefined behaviour) -/// what may be used for some optimizations (e.g. simple `return -/// isdigit_table[c];`). -static inline bool ascii_isdigit(int c) -{ - return c >= '0' && c <= '9'; -} - -/// Checks if `c` is a hexadecimal digit, that is, one of 0-9, a-f, A-F. -/// -/// @see {ascii_isdigit} -static inline bool ascii_isxdigit(int c) -{ - return (c >= '0' && c <= '9') - || (c >= 'a' && c <= 'f') - || (c >= 'A' && c <= 'F'); -} - -/// Checks if `c` is an “identifier” character -/// -/// That is, whether it is alphanumeric character or underscore. -static inline bool ascii_isident(int c) -{ - return ASCII_ISALNUM(c) || c == '_'; -} - -/// Checks if `c` is a binary digit, that is, 0-1. -/// -/// @see {ascii_isdigit} -static inline bool ascii_isbdigit(int c) -{ - return (c == '0' || c == '1'); -} - -/// Checks if `c` is an octal digit, that is, 0-7. -/// -/// @see {ascii_isdigit} -static inline bool ascii_isodigit(int c) -{ - return (c >= '0' && c <= '7'); -} - -/// Checks if `c` is a white-space character, that is, -/// one of \f, \n, \r, \t, \v. -/// -/// @see {ascii_isdigit} -static inline bool ascii_isspace(int c) -{ - return (c >= 9 && c <= 13) || c == ' '; -} diff --git a/src/nvim/ascii_defs.h b/src/nvim/ascii_defs.h new file mode 100644 index 0000000000..4125336796 --- /dev/null +++ b/src/nvim/ascii_defs.h @@ -0,0 +1,185 @@ +#pragma once + +#include + +#include "nvim/func_attr.h" +#include "nvim/macros_defs.h" +#include "nvim/os/os_defs.h" + +// Definitions of various common control characters. + +#define CHAR_ORD(x) ((uint8_t)(x) < 'a' \ + ? (uint8_t)(x) - 'A' \ + : (uint8_t)(x) - 'a') +#define CHAR_ORD_LOW(x) ((uint8_t)(x) - 'a') +#define CHAR_ORD_UP(x) ((uint8_t)(x) - 'A') +#define ROT13(c, a) (((((c) - (a)) + 13) % 26) + (a)) + +#define NUL '\000' +#define BELL '\007' +#define BS '\010' +#define TAB '\011' +#define NL '\012' +#define NL_STR "\012" +#define FF '\014' +#define CAR '\015' // CR is used by Mac OS X +#define ESC '\033' +#define ESC_STR "\033" +#define DEL 0x7f +#define DEL_STR "\177" +#define CSI 0x9b // Control Sequence Introducer +#define CSI_STR "\233" +#define DCS 0x90 // Device Control String +#define STERM 0x9c // String Terminator + +#define POUND 0xA3 + +#define CTRL_CHR(x) (TOUPPER_ASC(x) ^ 0x40) // '?' -> DEL, '@' -> ^@, etc. +#define META(x) ((x) | 0x80) + +#define CTRL_F_STR "\006" +#define CTRL_H_STR "\010" +#define CTRL_V_STR "\026" + +#define Ctrl_AT 0 // @ +#define Ctrl_A 1 +#define Ctrl_B 2 +#define Ctrl_C 3 +#define Ctrl_D 4 +#define Ctrl_E 5 +#define Ctrl_F 6 +#define Ctrl_G 7 +#define Ctrl_H 8 +#define Ctrl_I 9 +#define Ctrl_J 10 +#define Ctrl_K 11 +#define Ctrl_L 12 +#define Ctrl_M 13 +#define Ctrl_N 14 +#define Ctrl_O 15 +#define Ctrl_P 16 +#define Ctrl_Q 17 +#define Ctrl_R 18 +#define Ctrl_S 19 +#define Ctrl_T 20 +#define Ctrl_U 21 +#define Ctrl_V 22 +#define Ctrl_W 23 +#define Ctrl_X 24 +#define Ctrl_Y 25 +#define Ctrl_Z 26 +// CTRL- [ Left Square Bracket == ESC +#define Ctrl_BSL 28 // \ BackSLash +#define Ctrl_RSB 29 // ] Right Square Bracket +#define Ctrl_HAT 30 // ^ +#define Ctrl__ 31 + +// Character that separates dir names in a path. +#ifdef BACKSLASH_IN_FILENAME +# define PATHSEP psepc +# define PATHSEPSTR pseps +#else +# define PATHSEP '/' +# define PATHSEPSTR "/" +#endif + +static inline bool ascii_iswhite(int c) + REAL_FATTR_CONST + REAL_FATTR_ALWAYS_INLINE; + +static inline bool ascii_iswhite_or_nul(int c) + REAL_FATTR_CONST + REAL_FATTR_ALWAYS_INLINE; + +static inline bool ascii_isdigit(int c) + REAL_FATTR_CONST + REAL_FATTR_ALWAYS_INLINE; + +static inline bool ascii_isxdigit(int c) + REAL_FATTR_CONST + REAL_FATTR_ALWAYS_INLINE; + +static inline bool ascii_isident(int c) + REAL_FATTR_CONST + REAL_FATTR_ALWAYS_INLINE; + +static inline bool ascii_isbdigit(int c) + REAL_FATTR_CONST + REAL_FATTR_ALWAYS_INLINE; + +static inline bool ascii_isspace(int c) + REAL_FATTR_CONST + REAL_FATTR_ALWAYS_INLINE; + +/// Checks if `c` is a space or tab character. +/// +/// @see {ascii_isdigit} +static inline bool ascii_iswhite(int c) +{ + return c == ' ' || c == '\t'; +} + +/// Checks if `c` is a space or tab character or NUL. +/// +/// @see {ascii_isdigit} +static inline bool ascii_iswhite_or_nul(int c) +{ + return ascii_iswhite(c) || c == NUL; +} + +/// Check whether character is a decimal digit. +/// +/// Library isdigit() function is officially locale-dependent and, for +/// example, returns true for superscript 1 (¹) in locales where encoding +/// contains it in lower 8 bits. Also avoids crashes in case c is below +/// 0 or above 255: library functions are officially defined as accepting +/// only EOF and unsigned char values (otherwise it is undefined behaviour) +/// what may be used for some optimizations (e.g. simple `return +/// isdigit_table[c];`). +static inline bool ascii_isdigit(int c) +{ + return c >= '0' && c <= '9'; +} + +/// Checks if `c` is a hexadecimal digit, that is, one of 0-9, a-f, A-F. +/// +/// @see {ascii_isdigit} +static inline bool ascii_isxdigit(int c) +{ + return (c >= '0' && c <= '9') + || (c >= 'a' && c <= 'f') + || (c >= 'A' && c <= 'F'); +} + +/// Checks if `c` is an “identifier” character +/// +/// That is, whether it is alphanumeric character or underscore. +static inline bool ascii_isident(int c) +{ + return ASCII_ISALNUM(c) || c == '_'; +} + +/// Checks if `c` is a binary digit, that is, 0-1. +/// +/// @see {ascii_isdigit} +static inline bool ascii_isbdigit(int c) +{ + return (c == '0' || c == '1'); +} + +/// Checks if `c` is an octal digit, that is, 0-7. +/// +/// @see {ascii_isdigit} +static inline bool ascii_isodigit(int c) +{ + return (c >= '0' && c <= '7'); +} + +/// Checks if `c` is a white-space character, that is, +/// one of \f, \n, \r, \t, \v. +/// +/// @see {ascii_isdigit} +static inline bool ascii_isspace(int c) +{ + return (c >= 9 && c <= 13) || c == ' '; +} diff --git a/src/nvim/assert.h b/src/nvim/assert.h deleted file mode 100644 index cfc27ee994..0000000000 --- a/src/nvim/assert.h +++ /dev/null @@ -1,167 +0,0 @@ -#pragma once - -#include "auto/config.h" -#include "nvim/log.h" - -// support static asserts (aka compile-time asserts) - -// some compilers don't properly support short-circuiting apparently, giving -// ugly syntax errors when using things like defined(__clang__) && -// defined(__has_feature) && __has_feature(...). Therefore we define Clang's -// __has_feature and __has_extension macro's before referring to them. -#ifndef __has_feature -# define __has_feature(x) 0 -#endif - -#ifndef __has_extension -# define __has_extension __has_feature -#endif - -/// @def STATIC_ASSERT -/// @brief Assert at compile time if condition is not satisfied. -/// -/// Should be put on its own line, followed by a semicolon. -/// -/// Example: -/// -/// STATIC_ASSERT(sizeof(void *) == 8, "Expected 64-bit mode"); -/// -/// @param[in] condition Condition to check, should be an integer constant -/// expression. -/// @param[in] message Message which will be given if check fails. - -/// @def STATIC_ASSERT_EXPR -/// @brief Like #STATIC_ASSERT, but can be used where expressions are used. -/// -/// STATIC_ASSERT_EXPR may be put in brace initializer lists. Error message -/// given in this case is not very nice with the current implementation though -/// and `message` argument is ignored. - -// define STATIC_ASSERT as C11's _Static_assert whenever either C11 mode is -// detected or the compiler is known to support it. Note that Clang in C99 -// mode defines __has_feature(c_static_assert) as false and -// __has_extension(c_static_assert) as true. Meaning it does support it, but -// warns. A similar thing goes for gcc, which warns when it's not compiling -// as C11 but does support _Static_assert since 4.6. Since we prefer the -// clearer messages we get from _Static_assert, we suppress the warnings -// temporarily. - -#define STATIC_ASSERT_PRAGMA_START -#define STATIC_ASSERT_PRAGMA_END -#define STATIC_ASSERT(cond, msg) \ - do { \ - STATIC_ASSERT_PRAGMA_START \ - STATIC_ASSERT_STATEMENT(cond, msg); \ - STATIC_ASSERT_PRAGMA_END \ - } while (0) - -// the easiest case, when the mode is C11 (generic compiler) or Clang -// advertises explicit support for c_static_assert, meaning it won't warn. -#if __STDC_VERSION__ >= 201112 || __has_feature(c_static_assert) -# define STATIC_ASSERT_STATEMENT(cond, msg) _Static_assert(cond, msg) -// if we're dealing with gcc >= 4.6 in C99 mode, we can still use -// _Static_assert but we need to suppress warnings, this is pretty ugly. -#elif (!defined(__clang__) && !defined(__INTEL_COMPILER)) && /* NOLINT(whitespace/parens)*/ \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - -# define STATIC_ASSERT_STATEMENT(cond, msg) _Static_assert(cond, msg) - -# undef STATIC_ASSERT_PRAGMA_START - -# if __GNUC__ >= 6 -# define STATIC_ASSERT_PRAGMA_START \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wpedantic\"") -# else -# define STATIC_ASSERT_PRAGMA_START \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-pedantic\"") -# endif - -# undef STATIC_ASSERT_PRAGMA_END -# define STATIC_ASSERT_PRAGMA_END \ - _Pragma("GCC diagnostic pop") - -// the same goes for clang in C99 mode, but we suppress a different warning -#elif defined(__clang__) && __has_extension(c_static_assert) - -# define STATIC_ASSERT_STATEMENT(cond, msg) _Static_assert(cond, msg) - -# undef STATIC_ASSERT_PRAGMA_START -# define STATIC_ASSERT_PRAGMA_START \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wc11-extensions\"") - -# undef STATIC_ASSERT_PRAGMA_END -# define STATIC_ASSERT_PRAGMA_END \ - _Pragma("clang diagnostic pop") - -// TODO(aktau): verify that this works, don't have MSVC on hand. -#elif _MSC_VER >= 1600 - -# define STATIC_ASSERT_STATEMENT(cond, msg) static_assert(cond, msg) - -// fallback for compilers that don't support _Static_assert or static_assert -// not as pretty but gets the job done. Credit goes to Pádraig Brady and -// contributors. -#else -# define STATIC_ASSERT_STATEMENT STATIC_ASSERT_EXPR -#endif - -#define ASSERT_CONCAT_(a, b) a##b -#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b) -// These can't be used after statements in c89. -#ifdef __COUNTER__ -# define STATIC_ASSERT_EXPR(e, m) \ - ((enum { ASSERT_CONCAT(static_assert_, __COUNTER__) = 1/(!!(e)), }) 0) -#else -// This can't be used twice on the same line so ensure if using in headers -// that the headers are not included twice (by wrapping in #ifndef...#endif) -// Note it doesn't cause an issue when used on same line of separate modules -// compiled with gcc -combine -fwhole-program. -# define STATIC_ASSERT_EXPR(e, m) \ - ((enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)), }) 0) -#endif - -/// @def STRICT_ADD -/// @brief Adds (a + b) and stores result in `c`. Aborts on overflow. -/// -/// Requires GCC 5+ and Clang 3.8+ -/// https://clang.llvm.org/docs/LanguageExtensions.html -/// https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html -/// -/// Alternative for compilers without __builtin_xx_overflow ? -/// https://stackoverflow.com/a/44830670/152142 -/// -/// @param a Operand 1. -/// @param b Operand 2. -/// @param c Where to store the result. -/// @param t Result type. Not used if compiler supports __builtin_add_overflow. -#ifdef HAVE_BUILTIN_ADD_OVERFLOW -# define STRICT_ADD(a, b, c, t) \ - do { \ - if (__builtin_add_overflow(a, b, c)) { \ - ELOG("STRICT_ADD overflow"); \ - abort(); \ - } \ - } while (0) -#else -# define STRICT_ADD(a, b, c, t) \ - do { *(c) = (t)((a) + (b)); } while (0) -#endif - -/// @def STRICT_SUB -/// @brief Subtracts (a - b) and stores result in `c`. Aborts on overflow. -/// @see STRICT_ADD -#ifdef HAVE_BUILTIN_ADD_OVERFLOW -# define STRICT_SUB(a, b, c, t) \ - do { \ - if (__builtin_sub_overflow(a, b, c)) { \ - ELOG("STRICT_SUB overflow"); \ - abort(); \ - } \ - } while (0) -#else -# define STRICT_SUB(a, b, c, t) \ - do { *(c) = (t)((a) - (b)); } while (0) -#endif diff --git a/src/nvim/assert_defs.h b/src/nvim/assert_defs.h new file mode 100644 index 0000000000..cfc27ee994 --- /dev/null +++ b/src/nvim/assert_defs.h @@ -0,0 +1,167 @@ +#pragma once + +#include "auto/config.h" +#include "nvim/log.h" + +// support static asserts (aka compile-time asserts) + +// some compilers don't properly support short-circuiting apparently, giving +// ugly syntax errors when using things like defined(__clang__) && +// defined(__has_feature) && __has_feature(...). Therefore we define Clang's +// __has_feature and __has_extension macro's before referring to them. +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + +#ifndef __has_extension +# define __has_extension __has_feature +#endif + +/// @def STATIC_ASSERT +/// @brief Assert at compile time if condition is not satisfied. +/// +/// Should be put on its own line, followed by a semicolon. +/// +/// Example: +/// +/// STATIC_ASSERT(sizeof(void *) == 8, "Expected 64-bit mode"); +/// +/// @param[in] condition Condition to check, should be an integer constant +/// expression. +/// @param[in] message Message which will be given if check fails. + +/// @def STATIC_ASSERT_EXPR +/// @brief Like #STATIC_ASSERT, but can be used where expressions are used. +/// +/// STATIC_ASSERT_EXPR may be put in brace initializer lists. Error message +/// given in this case is not very nice with the current implementation though +/// and `message` argument is ignored. + +// define STATIC_ASSERT as C11's _Static_assert whenever either C11 mode is +// detected or the compiler is known to support it. Note that Clang in C99 +// mode defines __has_feature(c_static_assert) as false and +// __has_extension(c_static_assert) as true. Meaning it does support it, but +// warns. A similar thing goes for gcc, which warns when it's not compiling +// as C11 but does support _Static_assert since 4.6. Since we prefer the +// clearer messages we get from _Static_assert, we suppress the warnings +// temporarily. + +#define STATIC_ASSERT_PRAGMA_START +#define STATIC_ASSERT_PRAGMA_END +#define STATIC_ASSERT(cond, msg) \ + do { \ + STATIC_ASSERT_PRAGMA_START \ + STATIC_ASSERT_STATEMENT(cond, msg); \ + STATIC_ASSERT_PRAGMA_END \ + } while (0) + +// the easiest case, when the mode is C11 (generic compiler) or Clang +// advertises explicit support for c_static_assert, meaning it won't warn. +#if __STDC_VERSION__ >= 201112 || __has_feature(c_static_assert) +# define STATIC_ASSERT_STATEMENT(cond, msg) _Static_assert(cond, msg) +// if we're dealing with gcc >= 4.6 in C99 mode, we can still use +// _Static_assert but we need to suppress warnings, this is pretty ugly. +#elif (!defined(__clang__) && !defined(__INTEL_COMPILER)) && /* NOLINT(whitespace/parens)*/ \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) + +# define STATIC_ASSERT_STATEMENT(cond, msg) _Static_assert(cond, msg) + +# undef STATIC_ASSERT_PRAGMA_START + +# if __GNUC__ >= 6 +# define STATIC_ASSERT_PRAGMA_START \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wpedantic\"") +# else +# define STATIC_ASSERT_PRAGMA_START \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-pedantic\"") +# endif + +# undef STATIC_ASSERT_PRAGMA_END +# define STATIC_ASSERT_PRAGMA_END \ + _Pragma("GCC diagnostic pop") + +// the same goes for clang in C99 mode, but we suppress a different warning +#elif defined(__clang__) && __has_extension(c_static_assert) + +# define STATIC_ASSERT_STATEMENT(cond, msg) _Static_assert(cond, msg) + +# undef STATIC_ASSERT_PRAGMA_START +# define STATIC_ASSERT_PRAGMA_START \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wc11-extensions\"") + +# undef STATIC_ASSERT_PRAGMA_END +# define STATIC_ASSERT_PRAGMA_END \ + _Pragma("clang diagnostic pop") + +// TODO(aktau): verify that this works, don't have MSVC on hand. +#elif _MSC_VER >= 1600 + +# define STATIC_ASSERT_STATEMENT(cond, msg) static_assert(cond, msg) + +// fallback for compilers that don't support _Static_assert or static_assert +// not as pretty but gets the job done. Credit goes to Pádraig Brady and +// contributors. +#else +# define STATIC_ASSERT_STATEMENT STATIC_ASSERT_EXPR +#endif + +#define ASSERT_CONCAT_(a, b) a##b +#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b) +// These can't be used after statements in c89. +#ifdef __COUNTER__ +# define STATIC_ASSERT_EXPR(e, m) \ + ((enum { ASSERT_CONCAT(static_assert_, __COUNTER__) = 1/(!!(e)), }) 0) +#else +// This can't be used twice on the same line so ensure if using in headers +// that the headers are not included twice (by wrapping in #ifndef...#endif) +// Note it doesn't cause an issue when used on same line of separate modules +// compiled with gcc -combine -fwhole-program. +# define STATIC_ASSERT_EXPR(e, m) \ + ((enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)), }) 0) +#endif + +/// @def STRICT_ADD +/// @brief Adds (a + b) and stores result in `c`. Aborts on overflow. +/// +/// Requires GCC 5+ and Clang 3.8+ +/// https://clang.llvm.org/docs/LanguageExtensions.html +/// https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html +/// +/// Alternative for compilers without __builtin_xx_overflow ? +/// https://stackoverflow.com/a/44830670/152142 +/// +/// @param a Operand 1. +/// @param b Operand 2. +/// @param c Where to store the result. +/// @param t Result type. Not used if compiler supports __builtin_add_overflow. +#ifdef HAVE_BUILTIN_ADD_OVERFLOW +# define STRICT_ADD(a, b, c, t) \ + do { \ + if (__builtin_add_overflow(a, b, c)) { \ + ELOG("STRICT_ADD overflow"); \ + abort(); \ + } \ + } while (0) +#else +# define STRICT_ADD(a, b, c, t) \ + do { *(c) = (t)((a) + (b)); } while (0) +#endif + +/// @def STRICT_SUB +/// @brief Subtracts (a - b) and stores result in `c`. Aborts on overflow. +/// @see STRICT_ADD +#ifdef HAVE_BUILTIN_ADD_OVERFLOW +# define STRICT_SUB(a, b, c, t) \ + do { \ + if (__builtin_sub_overflow(a, b, c)) { \ + ELOG("STRICT_SUB overflow"); \ + abort(); \ + } \ + } while (0) +#else +# define STRICT_SUB(a, b, c, t) \ + do { *(c) = (t)((a) - (b)); } while (0) +#endif diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index b6c853bd66..585fac1228 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -9,7 +9,7 @@ #include "klib/kvec.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/charset.h" @@ -33,7 +33,7 @@ #include "nvim/insexpand.h" #include "nvim/lua/executor.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" @@ -52,7 +52,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/ui_compositor.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #include "nvim/winfloat.h" diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h index a0a060c5b0..259a56cf5c 100644 --- a/src/nvim/autocmd.h +++ b/src/nvim/autocmd.h @@ -10,7 +10,7 @@ #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 2a3cebc0ae..4d553cc91f 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -29,8 +29,8 @@ #include "klib/kvec.h" #include "nvim/api/private/helpers.h" #include "nvim/arglist.h" -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_updates.h" @@ -65,7 +65,7 @@ #include "nvim/indent.h" #include "nvim/indent_c.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/mapping.h" #include "nvim/mark.h" #include "nvim/mbyte.h" @@ -100,7 +100,7 @@ #include "nvim/undo.h" #include "nvim/usercmd.h" #include "nvim/version.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #include "nvim/winfloat.h" diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index b93681ac14..36e70d1927 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -9,7 +9,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/func_attr.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memline.h" #include "nvim/memline_defs.h" #include "nvim/pos_defs.h" diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 0269060c2f..e0119d2add 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -23,7 +23,7 @@ typedef struct { #include "nvim/grid_defs.h" #include "nvim/hashtab_defs.h" #include "nvim/highlight_defs.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/mapping_defs.h" #include "nvim/mark_defs.h" #include "nvim/marktree.h" diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c index 26e321f956..6a96f715af 100644 --- a/src/nvim/buffer_updates.c +++ b/src/nvim/buffer_updates.c @@ -7,7 +7,7 @@ #include "nvim/api/buffer.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/assert.h" +#include "nvim/assert_defs.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/buffer_updates.h" diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 8fd39582d6..0525e9ccc4 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -10,7 +10,7 @@ #include #include "auto/config.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -27,9 +27,9 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight_defs.h" -#include "nvim/iconv.h" +#include "nvim/iconv_defs.h" #include "nvim/input.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -46,7 +46,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" static const char *err_readonly = "is read-only (cannot override: \"W\" in 'cpoptions')"; static const char e_patchmode_cant_touch_empty_original_file[] diff --git a/src/nvim/change.c b/src/nvim/change.c index 2949ebaf62..20cc034638 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -5,8 +5,8 @@ #include #include -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -28,7 +28,7 @@ #include "nvim/indent.h" #include "nvim/indent_c.h" #include "nvim/insexpand.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -47,7 +47,7 @@ #include "nvim/textformat.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "change.c.generated.h" diff --git a/src/nvim/channel.h b/src/nvim/channel.h index 53666b0501..5c9d708ac2 100644 --- a/src/nvim/channel.h +++ b/src/nvim/channel.h @@ -11,9 +11,9 @@ #include "nvim/event/socket.h" #include "nvim/event/stream.h" #include "nvim/garray_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/msgpack_rpc/channel_defs.h" #include "nvim/os/pty_process.h" #include "nvim/terminal.h" diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 515c06f2d8..48a9808b31 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -12,7 +12,7 @@ #include "auto/config.h" #include "klib/kvec.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cursor.h" @@ -20,14 +20,14 @@ #include "nvim/garray.h" #include "nvim/globals.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/option.h" #include "nvim/path.h" #include "nvim/pos_defs.h" #include "nvim/strings.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "charset.c.generated.h" diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 57d79dc420..275b284392 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -11,7 +11,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/charset.h" @@ -40,7 +40,7 @@ #include "nvim/keycodes.h" #include "nvim/log.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/mbyte.h" #include "nvim/memory.h" @@ -65,7 +65,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/usercmd.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" /// Type used by call_user_expand_func diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 742a98b58c..4556b74396 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -7,7 +7,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" #include "nvim/cmdhist.h" @@ -18,14 +18,14 @@ #include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option_vars.h" #include "nvim/regexp.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "cmdhist.c.generated.h" diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index 9434f33ae5..1110fe1e64 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -3,15 +3,15 @@ #include #include -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/buffer_defs.h" #include "nvim/change.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" #include "nvim/fold.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -22,7 +22,7 @@ #include "nvim/plines.h" #include "nvim/pos_defs.h" #include "nvim/state.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "cursor.c.generated.h" diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 970b84029f..82068ce9c5 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -4,7 +4,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/cursor_shape.h" #include "nvim/ex_getln.h" @@ -13,11 +13,11 @@ #include "nvim/globals.h" #include "nvim/highlight_group.h" #include "nvim/log.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/option_vars.h" #include "nvim/strings.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "cursor_shape.c.generated.h" diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 17e88c7962..dd248ca58e 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -7,7 +7,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" #include "nvim/debugger.h" @@ -24,7 +24,7 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/os/os.h" @@ -32,7 +32,7 @@ #include "nvim/pos_defs.h" #include "nvim/regexp.h" #include "nvim/runtime.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// batch mode debugging: don't save and restore typeahead. static bool debug_greedy = false; diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h index b8107811a4..829046f1b9 100644 --- a/src/nvim/decoration.h +++ b/src/nvim/decoration.h @@ -8,7 +8,7 @@ #include "nvim/buffer_defs.h" #include "nvim/decoration_defs.h" // IWYU pragma: export #include "nvim/extmark_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/marktree.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" diff --git a/src/nvim/decoration_provider.h b/src/nvim/decoration_provider.h index 09ef4773c1..90bd9e6a41 100644 --- a/src/nvim/decoration_provider.h +++ b/src/nvim/decoration_provider.h @@ -5,7 +5,7 @@ #include "klib/kvec.h" #include "nvim/buffer_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/types_defs.h" #define DP_MAX_ERROR 3 diff --git a/src/nvim/diff.c b/src/nvim/diff.c index cf4c98e5f9..0b7f6f266b 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -16,7 +16,7 @@ #include #include "auto/config.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/bufwrite.h" @@ -56,7 +56,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #include "xdiff/xdiff.h" diff --git a/src/nvim/diff.h b/src/nvim/diff.h index 944523430b..8b58887890 100644 --- a/src/nvim/diff.h +++ b/src/nvim/diff.h @@ -3,7 +3,7 @@ #include #include "nvim/ex_cmds_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/pos_defs.h" // Value set from 'diffopt'. diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index a45417ca1e..647ab26441 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -7,7 +7,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/digraph.h" @@ -34,7 +34,7 @@ #include "nvim/runtime.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" typedef int result_T; diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index e4f4e4cbca..5b90231a62 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -9,7 +9,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/charset.h" #include "nvim/cursor.h" @@ -46,7 +46,7 @@ #include "nvim/terminal.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #define MB_FILLER_CHAR '<' // character used when a double-width character // doesn't fit. diff --git a/src/nvim/drawline.h b/src/nvim/drawline.h index 20072e4103..6a9c6d5597 100644 --- a/src/nvim/drawline.h +++ b/src/nvim/drawline.h @@ -6,7 +6,7 @@ #include "klib/kvec.h" #include "nvim/decoration_provider.h" #include "nvim/fold.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index addf3b0b91..8873dc01b1 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -61,7 +61,7 @@ #include "klib/kvec.h" #include "nvim/api/private/defs.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/charset.h" @@ -110,7 +110,7 @@ #include "nvim/ui.h" #include "nvim/ui_compositor.h" #include "nvim/version.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" /// corner value flags for hsep_connected and vsep_connected diff --git a/src/nvim/drawscreen.h b/src/nvim/drawscreen.h index 8640f7b7fc..565b01bcd1 100644 --- a/src/nvim/drawscreen.h +++ b/src/nvim/drawscreen.h @@ -4,7 +4,7 @@ #include "nvim/buffer_defs.h" #include "nvim/drawline.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" /// flags for update_screen() /// The higher the value, the higher the priority diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 16b9a64dfb..77065f95e9 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -7,7 +7,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/autocmd_defs.h" #include "nvim/buffer.h" @@ -35,7 +35,7 @@ #include "nvim/indent_c.h" #include "nvim/insexpand.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/mark.h" #include "nvim/mbyte.h" @@ -62,7 +62,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" typedef struct insert_state { diff --git a/src/nvim/eval.c b/src/nvim/eval.c index e7fe7e17bc..f4479d06a6 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -13,7 +13,7 @@ #include "nvim/api/private/converter.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/channel.h" @@ -48,9 +48,9 @@ #include "nvim/keycodes.h" #include "nvim/lib/queue.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -82,7 +82,7 @@ #include "nvim/ui_compositor.h" #include "nvim/usercmd.h" #include "nvim/version.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" // TODO(ZyX-I): Remove DICT_MAXNEST, make users be non-recursive instead diff --git a/src/nvim/eval.h b/src/nvim/eval.h index b4d6c34405..b8104cf82a 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -12,7 +12,7 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/globals.h" #include "nvim/hashtab_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/os/fileio.h" #include "nvim/os/stdpaths_defs.h" diff --git a/src/nvim/eval/buffer.c b/src/nvim/eval/buffer.c index ce67429d90..c60a104381 100644 --- a/src/nvim/eval/buffer.c +++ b/src/nvim/eval/buffer.c @@ -3,7 +3,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -16,7 +16,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/func_attr.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/move.h" @@ -25,7 +25,7 @@ #include "nvim/sign.h" #include "nvim/types_defs.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" typedef struct { win_T *cob_curwin_save; diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index dde990d693..03f79fca84 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -7,7 +7,7 @@ #include #include "klib/kvec.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/eval.h" #include "nvim/eval/decode.h" @@ -17,12 +17,12 @@ #include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// Helper structure for container_struct typedef struct { diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index f8bf53cf0c..8505c30fad 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -14,7 +14,7 @@ #include "klib/kvec.h" #include "msgpack/pack.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/eval.h" #include "nvim/eval/encode.h" #include "nvim/eval/typval.h" @@ -22,14 +22,14 @@ #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/hashtab.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/math.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" // For _() +#include "nvim/vim_defs.h" // For _() const char *const encode_bool_var_names[] = { [kBoolVarTrue] = "v:true", diff --git a/src/nvim/eval/executor.c b/src/nvim/eval/executor.c index 70ab5e1aae..dc23fcdc72 100644 --- a/src/nvim/eval/executor.c +++ b/src/nvim/eval/executor.c @@ -12,7 +12,7 @@ #include "nvim/message.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "eval/executor.c.generated.h" // IWYU pragma: export diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 56958224ca..13425b21d1 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -24,8 +24,8 @@ #include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/api/vim.h" -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -72,7 +72,7 @@ #include "nvim/insexpand.h" #include "nvim/keycodes.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/mark.h" #include "nvim/math.h" @@ -114,7 +114,7 @@ #include "nvim/tag.h" #include "nvim/ui.h" #include "nvim/version.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" /// Describe data to return from find_some_match() diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 25be8ecd62..069cdced34 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -7,8 +7,8 @@ #include #include -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/charset.h" #include "nvim/eval.h" #include "nvim/eval/encode.h" @@ -25,7 +25,7 @@ #include "nvim/hashtab.h" #include "nvim/lib/queue.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/mbyte_defs.h" #include "nvim/memory.h" @@ -34,7 +34,7 @@ #include "nvim/pos_defs.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// struct storing information about current sort typedef struct { diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index b8466b6943..58f74a9796 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -12,7 +12,7 @@ #include "nvim/gettext.h" #include "nvim/hashtab.h" #include "nvim/lib/queue.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte_defs.h" #include "nvim/message.h" #include "nvim/types_defs.h" diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index a859b8a94d..23b3c4e1b2 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -8,7 +8,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" @@ -32,7 +32,7 @@ #include "nvim/insexpand.h" #include "nvim/keycodes.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" @@ -46,7 +46,7 @@ #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "eval/userfunc.c.generated.h" diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index 75274d41af..2968f75f4d 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -9,7 +9,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" @@ -30,7 +30,7 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/hashtab.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/ops.h" @@ -41,7 +41,7 @@ #include "nvim/search.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index 387f524cbb..e0abbad477 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -18,13 +18,13 @@ #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #include "nvim/winfloat.h" diff --git a/src/nvim/eval/window.h b/src/nvim/eval/window.h index aa3becf30b..ed879c895a 100644 --- a/src/nvim/eval/window.h +++ b/src/nvim/eval/window.h @@ -13,7 +13,7 @@ #include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/pos_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" /// Structure used by switch_win() to pass values to restore_win() diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c index da6d595741..73828a2271 100644 --- a/src/nvim/event/rstream.c +++ b/src/nvim/event/rstream.c @@ -10,7 +10,7 @@ #include "nvim/event/stream.h" #include "nvim/func_attr.h" #include "nvim/log.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/os/os_defs.h" #include "nvim/rbuffer.h" diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index f6a950d4ef..e787e023f0 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -5,7 +5,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/event/loop.h" #include "nvim/event/socket.h" diff --git a/src/nvim/event/wstream.c b/src/nvim/event/wstream.c index d7e5d7a9f3..e8f757874b 100644 --- a/src/nvim/event/wstream.c +++ b/src/nvim/event/wstream.c @@ -6,7 +6,7 @@ #include "nvim/event/stream.h" #include "nvim/event/wstream.h" #include "nvim/func_attr.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #define DEFAULT_MAXMEM 1024 * 1024 * 2000 diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index a11d3f0bca..974631d61f 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -16,7 +16,7 @@ #include "auto/config.h" #include "klib/kvec.h" #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -52,7 +52,7 @@ #include "nvim/highlight_group.h" #include "nvim/indent.h" #include "nvim/input.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/mark.h" #include "nvim/mbyte.h" @@ -84,7 +84,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" /// Case matching style to use for :substitute diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 3f5047db8b..a00124ea30 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -9,7 +9,7 @@ #include #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/bufwrite.h" @@ -27,7 +27,7 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/memory.h" #include "nvim/message.h" @@ -40,7 +40,7 @@ #include "nvim/quickfix.h" #include "nvim/runtime.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index e0777a48e5..381e23b27d 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -13,7 +13,7 @@ #include "auto/config.h" #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -49,7 +49,7 @@ #include "nvim/input.h" #include "nvim/keycodes.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/mark.h" #include "nvim/mbyte.h" @@ -84,7 +84,7 @@ #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/usercmd.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #include "nvim/winfloat.h" diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 16bfdc1dc0..d2a1d53b78 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -8,7 +8,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/debugger.h" #include "nvim/eval.h" @@ -27,7 +27,7 @@ #include "nvim/regexp.h" #include "nvim/runtime.h" #include "nvim/strings.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ex_eval.c.generated.h" diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 37af6b6a44..b078f77b98 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -15,7 +15,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/api/vim.h" #include "nvim/arabic.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/charset.h" @@ -42,8 +42,8 @@ #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/mapping.h" #include "nvim/mark.h" #include "nvim/mbyte.h" @@ -72,7 +72,7 @@ #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/usercmd.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/viml/parser/expressions.h" #include "nvim/viml/parser/parser.h" #include "nvim/window.h" diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index faacadb5a4..71c01922bc 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -10,7 +10,7 @@ #include #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/eval.h" #include "nvim/ex_cmds_defs.h" @@ -24,7 +24,7 @@ #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/memory.h" #include "nvim/message.h" @@ -35,7 +35,7 @@ #include "nvim/path.h" #include "nvim/pos_defs.h" #include "nvim/runtime.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 0bacb2cd4c..794a76907c 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -34,7 +34,7 @@ #include "nvim/extmark.h" #include "nvim/extmark_defs.h" #include "nvim/globals.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/marktree.h" #include "nvim/memline.h" #include "nvim/pos_defs.h" diff --git a/src/nvim/extmark.h b/src/nvim/extmark.h index 303ae77a59..53a8215882 100644 --- a/src/nvim/extmark.h +++ b/src/nvim/extmark.h @@ -8,7 +8,7 @@ #include "nvim/buffer_defs.h" #include "nvim/decoration.h" #include "nvim/extmark_defs.h" // IWYU pragma: export -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/marktree.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 8316d0449f..460cd48fc5 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -49,14 +49,14 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/file_search.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" @@ -67,7 +67,7 @@ #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/strings.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" static char *ff_expand_buffer = NULL; // used for expanding filenames diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index edebe779d9..303776b2eb 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -16,7 +16,7 @@ #include #include "auto/config.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -38,9 +38,9 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight_defs.h" -#include "nvim/iconv.h" +#include "nvim/iconv_defs.h" #include "nvim/log.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memfile.h" #include "nvim/memline.h" @@ -64,7 +64,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef BACKSLASH_IN_FILENAME # include "nvim/charset.h" diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 3452a7ae50..69857d2628 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -13,7 +13,7 @@ #include "nvim/api/extmark.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/buffer_updates.h" #include "nvim/change.h" @@ -49,7 +49,7 @@ #include "nvim/syntax.h" #include "nvim/types_defs.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // local declarations. {{{1 // typedef fold_T {{{2 diff --git a/src/nvim/fold.h b/src/nvim/fold.h index f902c8c322..3a70c11792 100644 --- a/src/nvim/fold.h +++ b/src/nvim/fold.h @@ -5,7 +5,7 @@ #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/fold_defs.h" // IWYU pragma: export #include "nvim/garray_defs.h" // IWYU pragma: keep -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" diff --git a/src/nvim/func_attr.h b/src/nvim/func_attr.h index 9bb4500f43..15370dcb3e 100644 --- a/src/nvim/func_attr.h +++ b/src/nvim/func_attr.h @@ -41,7 +41,7 @@ // $ gcc -E -dM - #include "nvim/arglist_defs.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/event/loop.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval_defs.h" #include "nvim/getchar_defs.h" -#include "nvim/iconv.h" -#include "nvim/macros.h" +#include "nvim/iconv_defs.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/menu_defs.h" #include "nvim/os/os_defs.h" diff --git a/src/nvim/grid.c b/src/nvim/grid.c index 029912c8ea..e5b870e6b0 100644 --- a/src/nvim/grid.c +++ b/src/nvim/grid.c @@ -16,20 +16,20 @@ #include "nvim/api/private/defs.h" #include "nvim/arabic.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/decoration.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" #include "nvim/log.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option_vars.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "grid.c.generated.h" diff --git a/src/nvim/grid.h b/src/nvim/grid.h index 565fd02806..9d8e395dae 100644 --- a/src/nvim/grid.h +++ b/src/nvim/grid.h @@ -6,7 +6,7 @@ #include "nvim/buffer_defs.h" #include "nvim/grid_defs.h" // IWYU pragma: export -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/pos_defs.h" diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index 10ce5a083a..475666be5e 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -23,13 +23,13 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/hashtab.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // Magic value for algorithm that walks through the array. #define PERTURB_SHIFT 5 diff --git a/src/nvim/help.c b/src/nvim/help.c index 0e388d923c..c23dc7fd9d 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/change.h" #include "nvim/charset.h" @@ -21,7 +21,7 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/help.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -40,7 +40,7 @@ #include "nvim/syntax.h" #include "nvim/tag.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index 9f58890ae0..6cd966c3b4 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -19,15 +19,15 @@ #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" #include "nvim/popupmenu.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "highlight.c.generated.h" diff --git a/src/nvim/highlight_defs.h b/src/nvim/highlight_defs.h index 704c798488..24070199ee 100644 --- a/src/nvim/highlight_defs.h +++ b/src/nvim/highlight_defs.h @@ -2,7 +2,7 @@ #include -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/types_defs.h" typedef int32_t RgbValue; diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index e32d16cd1d..3f1758894e 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -13,7 +13,7 @@ #include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" @@ -31,8 +31,8 @@ #include "nvim/highlight.h" #include "nvim/highlight_group.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" @@ -42,7 +42,7 @@ #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// \addtogroup SG_SET /// @{ diff --git a/src/nvim/iconv.h b/src/nvim/iconv.h deleted file mode 100644 index b6456b94ba..0000000000 --- a/src/nvim/iconv.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include - -// define some missing constants if necessary -#ifndef EILSEQ -# define EILSEQ 123 -#endif -#define ICONV_ERRNO errno -#define ICONV_E2BIG E2BIG -#define ICONV_EINVAL EINVAL -#define ICONV_EILSEQ EILSEQ diff --git a/src/nvim/iconv_defs.h b/src/nvim/iconv_defs.h new file mode 100644 index 0000000000..b6456b94ba --- /dev/null +++ b/src/nvim/iconv_defs.h @@ -0,0 +1,13 @@ +#pragma once + +#include +#include + +// define some missing constants if necessary +#ifndef EILSEQ +# define EILSEQ 123 +#endif +#define ICONV_ERRNO errno +#define ICONV_E2BIG E2BIG +#define ICONV_EINVAL EINVAL +#define ICONV_EILSEQ EILSEQ diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 2984a0abef..e3ba395164 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -4,8 +4,8 @@ #include #include -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/buffer.h" #include "nvim/change.h" #include "nvim/charset.h" @@ -40,7 +40,7 @@ #include "nvim/textformat.h" #include "nvim/types_defs.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "indent.c.generated.h" diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index a6d01be197..77851bfaac 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -4,7 +4,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cursor.h" @@ -13,7 +13,7 @@ #include "nvim/globals.h" #include "nvim/indent.h" #include "nvim/indent_c.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -23,7 +23,7 @@ #include "nvim/pos_defs.h" #include "nvim/search.h" #include "nvim/strings.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // Find result cache for cpp_baseclass typedef struct { diff --git a/src/nvim/input.c b/src/nvim/input.c index 08116c5e4f..e3fe17fcf9 100644 --- a/src/nvim/input.c +++ b/src/nvim/input.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/event/multiqueue.h" #include "nvim/getchar.h" #include "nvim/gettext.h" @@ -20,7 +20,7 @@ #include "nvim/mouse.h" #include "nvim/os/input.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "input.c.generated.h" // IWYU pragma: export diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 3f5c860326..e1a6b1fbf3 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -9,7 +9,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/change.h" @@ -34,7 +34,7 @@ #include "nvim/indent_c.h" #include "nvim/insexpand.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -60,7 +60,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" // Definitions used for CTRL-X submode. diff --git a/src/nvim/insexpand.h b/src/nvim/insexpand.h index 39584321ef..121d5568ff 100644 --- a/src/nvim/insexpand.h +++ b/src/nvim/insexpand.h @@ -1,10 +1,10 @@ #pragma once -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/option_defs.h" // IWYU pragma: keep #include "nvim/pos_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "insexpand.h.generated.h" diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c index dcca3d6caf..00d2ad3ec9 100644 --- a/src/nvim/keycodes.c +++ b/src/nvim/keycodes.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" @@ -14,12 +14,12 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/mouse.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "keycodes.c.generated.h" diff --git a/src/nvim/keycodes.h b/src/nvim/keycodes.h index 3b944d4680..db9ef38cc3 100644 --- a/src/nvim/keycodes.h +++ b/src/nvim/keycodes.h @@ -2,7 +2,7 @@ #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/option_defs.h" #include "nvim/option_vars.h" #include "nvim/strings.h" diff --git a/src/nvim/linematch.c b/src/nvim/linematch.c index fca62cfcc8..c34b303193 100644 --- a/src/nvim/linematch.c +++ b/src/nvim/linematch.c @@ -6,7 +6,7 @@ #include #include "nvim/linematch.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/pos_defs.h" diff --git a/src/nvim/log.c b/src/nvim/log.c index ebe119164f..aeee088cd3 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -17,7 +17,7 @@ #include #include "auto/config.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/eval.h" #include "nvim/func_attr.h" #include "nvim/globals.h" diff --git a/src/nvim/log.h b/src/nvim/log.h index b03c7dbc26..cac074d146 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -4,7 +4,7 @@ #include #include "auto/config.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" // USDT probes. Example invocation: // NVIM_PROBE(nvim_foo_bar, 1, string.data); diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index ca4812597e..4c6e38ca57 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -13,7 +13,7 @@ // FIXME: vim.h is not actually needed, but otherwise it states MAXPATHL is // redefined #include "klib/kvec.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/eval/decode.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" @@ -23,10 +23,10 @@ #include "nvim/gettext.h" #include "nvim/lua/converter.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/message.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// Determine, which keys lua table contains typedef struct { diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 7e35296995..06d16efb05 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -15,7 +15,7 @@ #include "nvim/api/extmark.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/change.h" #include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" @@ -41,7 +41,7 @@ #include "nvim/lua/executor.h" #include "nvim/lua/stdlib.h" #include "nvim/lua/treesitter.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -58,7 +58,7 @@ #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/usercmd.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" static int in_fast_callback = 0; diff --git a/src/nvim/lua/executor.h b/src/nvim/lua/executor.h index 6caad4bd7a..b38faddbb3 100644 --- a/src/nvim/lua/executor.h +++ b/src/nvim/lua/executor.h @@ -6,14 +6,14 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/assert.h" +#include "nvim/assert_defs.h" #include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/func_attr.h" #include "nvim/lua/converter.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/types_defs.h" #include "nvim/usercmd.h" diff --git a/src/nvim/lua/spell.c b/src/nvim/lua/spell.c index 8f4a684219..c261c5105e 100644 --- a/src/nvim/lua/spell.c +++ b/src/nvim/lua/spell.c @@ -5,7 +5,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 14658a6bc1..9c46179269 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -16,7 +16,7 @@ #include "mpack/lmpack.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/eval/typval.h" #include "nvim/eval/vars.h" @@ -29,7 +29,7 @@ #include "nvim/lua/spell.h" #include "nvim/lua/stdlib.h" #include "nvim/lua/xdiff.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -37,7 +37,7 @@ #include "nvim/regexp.h" #include "nvim/runtime.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "lua/stdlib.c.generated.h" diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index fcdd0540e0..008b3f2e95 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -20,8 +20,8 @@ #include "nvim/buffer_defs.h" #include "nvim/globals.h" #include "nvim/lua/treesitter.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/pos_defs.h" diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c index 6ce88400d1..93c8933649 100644 --- a/src/nvim/lua/xdiff.c +++ b/src/nvim/lua/xdiff.c @@ -11,10 +11,10 @@ #include "nvim/lua/converter.h" #include "nvim/lua/executor.h" #include "nvim/lua/xdiff.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/pos_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "xdiff/xdiff.h" #define COMPARED_BUFFER0 (1 << 0) diff --git a/src/nvim/macros.h b/src/nvim/macros.h deleted file mode 100644 index a7af2f91c3..0000000000 --- a/src/nvim/macros.h +++ /dev/null @@ -1,212 +0,0 @@ -#pragma once - -#include "auto/config.h" - -// EXTERN is only defined in main.c. That's where global variables are -// actually defined and initialized. -#ifndef EXTERN -# define EXTERN extern -# define INIT(...) -#else -# ifndef INIT -# define INIT(...) __VA_ARGS__ -# endif -#endif - -#ifndef MIN -# define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) -#endif -#ifndef MAX -# define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) -#endif - -/// String with length -/// -/// For use in functions which accept (char *s, size_t len) pair in arguments. -/// -/// @param[in] s Static string. -/// -/// @return `s, sizeof(s) - 1` -#define S_LEN(s) (s), (sizeof(s) - 1) - -/// LINEEMPTY() - return true if the line is empty -#define LINEEMPTY(p) (*ml_get(p) == NUL) - -// toupper() and tolower() that use the current locale. -// Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the -// range 0 - 255. toupper()/tolower() on some systems can't handle others. -// Note: It is often better to use mb_tolower() and mb_toupper(), because many -// toupper() and tolower() implementations only work for ASCII. -#define TOUPPER_LOC toupper -#define TOLOWER_LOC tolower - -// toupper() and tolower() for ASCII only and ignore the current locale. -#define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A')) -#define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A')) - -// Like isalpha() but reject non-ASCII characters. Can't be used with a -// special key (negative value). -#define ASCII_ISLOWER(c) ((unsigned)(c) >= 'a' && (unsigned)(c) <= 'z') -#define ASCII_ISUPPER(c) ((unsigned)(c) >= 'A' && (unsigned)(c) <= 'Z') -#define ASCII_ISALPHA(c) (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) -#define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || ascii_isdigit(c)) - -// Returns empty string if it is NULL. -#define EMPTY_IF_NULL(x) ((x) ? (x) : "") - -/// Adjust chars in a language according to 'langmap' option. -/// NOTE that there is no noticeable overhead if 'langmap' is not set. -/// When set the overhead for characters < 256 is small. -/// Don't apply 'langmap' if the character comes from the Stuff buffer or from a -/// mapping and the langnoremap option was set. -/// The do-while is just to ignore a ';' after the macro. -#define LANGMAP_ADJUST(c, condition) \ - do { \ - if (*p_langmap \ - && (condition) \ - && (p_lrm || (vgetc_busy ? typebuf_maplen() == 0 : KeyTyped)) \ - && !KeyStuffed \ - && (c) >= 0) \ - { \ - if ((c) < 256) \ - c = langmap_mapchar[c]; \ - else \ - c = langmap_adjust_mb(c); \ - } \ - } while (0) - -#define WRITEBIN "wb" // no CR-LF translation -#define READBIN "rb" -#define APPENDBIN "ab" - -#define REPLACE_NORMAL(s) (((s)& REPLACE_FLAG) && !((s)& VREPLACE_FLAG)) - -// MB_PTR_ADV(): advance a pointer to the next character, taking care of -// multi-byte characters if needed. Skip over composing chars. -#define MB_PTR_ADV(p) (p += utfc_ptr2len((char *)p)) - -// Advance multi-byte pointer, do not skip over composing chars. -#define MB_CPTR_ADV(p) (p += utf_ptr2len((char *)p)) - -// MB_PTR_BACK(): backup a pointer to the previous character, taking care of -// multi-byte characters if needed. Only use with "p" > "s" ! -#define MB_PTR_BACK(s, p) \ - (p -= utf_head_off((char *)(s), (char *)(p) - 1) + 1) - -// MB_CHAR2BYTES(): convert character to bytes and advance pointer to bytes -#define MB_CHAR2BYTES(c, b) ((b) += utf_char2bytes((c), ((char *)b))) - -#define RESET_BINDING(wp) \ - do { \ - (wp)->w_p_scb = false; \ - (wp)->w_p_crb = false; \ - } while (0) - -/// Calculate the length of a C array -/// -/// This should be called with a real array. Calling this with a pointer is an -/// error. A mechanism to detect many (though not all) of those errors at -/// compile time is implemented. It works by the second division producing -/// a division by zero in those cases (-Wdiv-by-zero in GCC). -#define ARRAY_SIZE(arr) \ - ((sizeof(arr)/sizeof((arr)[0])) \ - / ((size_t)(!(sizeof(arr) % sizeof((arr)[0]))))) - -/// Get last array entry -/// -/// This should be called with a real array. Calling this with a pointer is an -/// error. -#define ARRAY_LAST_ENTRY(arr) (arr)[ARRAY_SIZE(arr) - 1] - -// Duplicated in os/win_defs.h to avoid include-order sensitivity. -#define RGB_(r, g, b) (((r) << 16) | ((g) << 8) | (b)) - -#define STR_(x) #x -#define STR(x) STR_(x) - -#ifndef __has_include -# define NVIM_HAS_INCLUDE(x) 0 -#else -# define NVIM_HAS_INCLUDE __has_include -#endif - -#ifndef __has_attribute -# define NVIM_HAS_ATTRIBUTE(x) 0 -#elif defined(__clang__) && __clang__ == 1 \ - && (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ <= 5)) -// Starting in Clang 3.6, __has_attribute was fixed to only report true for -// GNU-style attributes. Prior to that, it reported true if _any_ backend -// supported the attribute. -# define NVIM_HAS_ATTRIBUTE(x) 0 -#else -# define NVIM_HAS_ATTRIBUTE __has_attribute -#endif - -#if NVIM_HAS_ATTRIBUTE(fallthrough) \ - && (!defined(__apple_build_version__) || __apple_build_version__ >= 7000000) -# define FALLTHROUGH {} __attribute__((fallthrough)) -#else -# define FALLTHROUGH -#endif - -#if defined(__clang__) || defined(__GNUC__) -# define UNREACHABLE __builtin_unreachable() -#elif defined(_MSVC_VER) -# define UNREACHABLE __assume(false) -#else -# define UNREACHABLE -#endif - -// Type of uv_buf_t.len is platform-dependent. -// Related: https://github.com/libuv/libuv/pull/1236 -#if defined(MSWIN) -# define UV_BUF_LEN(x) (ULONG)(x) -#else -# define UV_BUF_LEN(x) (x) -#endif - -// Type of read()/write() `count` param is platform-dependent. -#if defined(MSWIN) -# define IO_COUNT(x) (unsigned)(x) -#else -# define IO_COUNT(x) (x) -#endif - -/// -/// PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES -/// -#if defined(__clang__) && __clang__ == 1 -# define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wmissing-prototypes\"") -# ifdef HAVE_WIMPLICIT_FALLTHROUGH_FLAG -# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wimplicit-fallthrough\"") -# else -# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \ - _Pragma("clang diagnostic push") -# endif -# define PRAGMA_DIAG_POP \ - _Pragma("clang diagnostic pop") -#elif defined(__GNUC__) -# define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wmissing-prototypes\"") -# ifdef HAVE_WIMPLICIT_FALLTHROUGH_FLAG -# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") -# else -# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \ - _Pragma("GCC diagnostic push") -# endif -# define PRAGMA_DIAG_POP \ - _Pragma("GCC diagnostic pop") -#else -# define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES -# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH -# define PRAGMA_DIAG_POP -#endif - -#define EMPTY_POS(a) ((a).lnum == 0 && (a).col == 0 && (a).coladd == 0) diff --git a/src/nvim/macros_defs.h b/src/nvim/macros_defs.h new file mode 100644 index 0000000000..a7af2f91c3 --- /dev/null +++ b/src/nvim/macros_defs.h @@ -0,0 +1,212 @@ +#pragma once + +#include "auto/config.h" + +// EXTERN is only defined in main.c. That's where global variables are +// actually defined and initialized. +#ifndef EXTERN +# define EXTERN extern +# define INIT(...) +#else +# ifndef INIT +# define INIT(...) __VA_ARGS__ +# endif +#endif + +#ifndef MIN +# define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) +#endif +#ifndef MAX +# define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) +#endif + +/// String with length +/// +/// For use in functions which accept (char *s, size_t len) pair in arguments. +/// +/// @param[in] s Static string. +/// +/// @return `s, sizeof(s) - 1` +#define S_LEN(s) (s), (sizeof(s) - 1) + +/// LINEEMPTY() - return true if the line is empty +#define LINEEMPTY(p) (*ml_get(p) == NUL) + +// toupper() and tolower() that use the current locale. +// Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the +// range 0 - 255. toupper()/tolower() on some systems can't handle others. +// Note: It is often better to use mb_tolower() and mb_toupper(), because many +// toupper() and tolower() implementations only work for ASCII. +#define TOUPPER_LOC toupper +#define TOLOWER_LOC tolower + +// toupper() and tolower() for ASCII only and ignore the current locale. +#define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A')) +#define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A')) + +// Like isalpha() but reject non-ASCII characters. Can't be used with a +// special key (negative value). +#define ASCII_ISLOWER(c) ((unsigned)(c) >= 'a' && (unsigned)(c) <= 'z') +#define ASCII_ISUPPER(c) ((unsigned)(c) >= 'A' && (unsigned)(c) <= 'Z') +#define ASCII_ISALPHA(c) (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) +#define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || ascii_isdigit(c)) + +// Returns empty string if it is NULL. +#define EMPTY_IF_NULL(x) ((x) ? (x) : "") + +/// Adjust chars in a language according to 'langmap' option. +/// NOTE that there is no noticeable overhead if 'langmap' is not set. +/// When set the overhead for characters < 256 is small. +/// Don't apply 'langmap' if the character comes from the Stuff buffer or from a +/// mapping and the langnoremap option was set. +/// The do-while is just to ignore a ';' after the macro. +#define LANGMAP_ADJUST(c, condition) \ + do { \ + if (*p_langmap \ + && (condition) \ + && (p_lrm || (vgetc_busy ? typebuf_maplen() == 0 : KeyTyped)) \ + && !KeyStuffed \ + && (c) >= 0) \ + { \ + if ((c) < 256) \ + c = langmap_mapchar[c]; \ + else \ + c = langmap_adjust_mb(c); \ + } \ + } while (0) + +#define WRITEBIN "wb" // no CR-LF translation +#define READBIN "rb" +#define APPENDBIN "ab" + +#define REPLACE_NORMAL(s) (((s)& REPLACE_FLAG) && !((s)& VREPLACE_FLAG)) + +// MB_PTR_ADV(): advance a pointer to the next character, taking care of +// multi-byte characters if needed. Skip over composing chars. +#define MB_PTR_ADV(p) (p += utfc_ptr2len((char *)p)) + +// Advance multi-byte pointer, do not skip over composing chars. +#define MB_CPTR_ADV(p) (p += utf_ptr2len((char *)p)) + +// MB_PTR_BACK(): backup a pointer to the previous character, taking care of +// multi-byte characters if needed. Only use with "p" > "s" ! +#define MB_PTR_BACK(s, p) \ + (p -= utf_head_off((char *)(s), (char *)(p) - 1) + 1) + +// MB_CHAR2BYTES(): convert character to bytes and advance pointer to bytes +#define MB_CHAR2BYTES(c, b) ((b) += utf_char2bytes((c), ((char *)b))) + +#define RESET_BINDING(wp) \ + do { \ + (wp)->w_p_scb = false; \ + (wp)->w_p_crb = false; \ + } while (0) + +/// Calculate the length of a C array +/// +/// This should be called with a real array. Calling this with a pointer is an +/// error. A mechanism to detect many (though not all) of those errors at +/// compile time is implemented. It works by the second division producing +/// a division by zero in those cases (-Wdiv-by-zero in GCC). +#define ARRAY_SIZE(arr) \ + ((sizeof(arr)/sizeof((arr)[0])) \ + / ((size_t)(!(sizeof(arr) % sizeof((arr)[0]))))) + +/// Get last array entry +/// +/// This should be called with a real array. Calling this with a pointer is an +/// error. +#define ARRAY_LAST_ENTRY(arr) (arr)[ARRAY_SIZE(arr) - 1] + +// Duplicated in os/win_defs.h to avoid include-order sensitivity. +#define RGB_(r, g, b) (((r) << 16) | ((g) << 8) | (b)) + +#define STR_(x) #x +#define STR(x) STR_(x) + +#ifndef __has_include +# define NVIM_HAS_INCLUDE(x) 0 +#else +# define NVIM_HAS_INCLUDE __has_include +#endif + +#ifndef __has_attribute +# define NVIM_HAS_ATTRIBUTE(x) 0 +#elif defined(__clang__) && __clang__ == 1 \ + && (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ <= 5)) +// Starting in Clang 3.6, __has_attribute was fixed to only report true for +// GNU-style attributes. Prior to that, it reported true if _any_ backend +// supported the attribute. +# define NVIM_HAS_ATTRIBUTE(x) 0 +#else +# define NVIM_HAS_ATTRIBUTE __has_attribute +#endif + +#if NVIM_HAS_ATTRIBUTE(fallthrough) \ + && (!defined(__apple_build_version__) || __apple_build_version__ >= 7000000) +# define FALLTHROUGH {} __attribute__((fallthrough)) +#else +# define FALLTHROUGH +#endif + +#if defined(__clang__) || defined(__GNUC__) +# define UNREACHABLE __builtin_unreachable() +#elif defined(_MSVC_VER) +# define UNREACHABLE __assume(false) +#else +# define UNREACHABLE +#endif + +// Type of uv_buf_t.len is platform-dependent. +// Related: https://github.com/libuv/libuv/pull/1236 +#if defined(MSWIN) +# define UV_BUF_LEN(x) (ULONG)(x) +#else +# define UV_BUF_LEN(x) (x) +#endif + +// Type of read()/write() `count` param is platform-dependent. +#if defined(MSWIN) +# define IO_COUNT(x) (unsigned)(x) +#else +# define IO_COUNT(x) (x) +#endif + +/// +/// PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES +/// +#if defined(__clang__) && __clang__ == 1 +# define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wmissing-prototypes\"") +# ifdef HAVE_WIMPLICIT_FALLTHROUGH_FLAG +# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wimplicit-fallthrough\"") +# else +# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \ + _Pragma("clang diagnostic push") +# endif +# define PRAGMA_DIAG_POP \ + _Pragma("clang diagnostic pop") +#elif defined(__GNUC__) +# define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wmissing-prototypes\"") +# ifdef HAVE_WIMPLICIT_FALLTHROUGH_FLAG +# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") +# else +# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \ + _Pragma("GCC diagnostic push") +# endif +# define PRAGMA_DIAG_POP \ + _Pragma("GCC diagnostic pop") +#else +# define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES +# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH +# define PRAGMA_DIAG_POP +#endif + +#define EMPTY_POS(a) ((a).lnum == 0 && (a).col == 0 && (a).coladd == 0) diff --git a/src/nvim/main.c b/src/nvim/main.c index bed7ae61c8..3d8f33628f 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -18,7 +18,7 @@ #endif // uncrustify:off -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // uncrustify:on #include "auto/config.h" // IWYU pragma: keep @@ -27,7 +27,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/api/ui.h" #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -61,7 +61,7 @@ #include "nvim/log.h" #include "nvim/lua/executor.h" #include "nvim/lua/secure.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/mark.h" #include "nvim/memline.h" diff --git a/src/nvim/map.c b/src/nvim/map.c index 9af13182e5..be6bf58daa 100644 --- a/src/nvim/map.c +++ b/src/nvim/map.c @@ -9,7 +9,7 @@ #include #include "auto/config.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #define equal_simple(x, y) ((x) == (y)) diff --git a/src/nvim/map.h b/src/nvim/map.h deleted file mode 100644 index 38f9107efd..0000000000 --- a/src/nvim/map.h +++ /dev/null @@ -1,226 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "nvim/api/private/defs.h" -#include "nvim/assert.h" -#include "nvim/highlight_defs.h" -#include "nvim/types_defs.h" - -#if defined(__NetBSD__) -# undef uint64_t -# define uint64_t uint64_t -#endif - -typedef const char *cstr_t; -typedef void *ptr_t; - -// when used as a key, String doesn't need to be NUL terminated, -// and can also contain embedded NUL:s as part of the data. -static inline uint32_t hash_String(String s) -{ - uint32_t h = 0; - for (size_t i = 0; i < s.size; i++) { - h = (h << 5) - h + (uint8_t)s.data[i]; - } - return h; -} - -static inline bool equal_String(String a, String b) -{ - if (a.size != b.size) { - return false; - } - return memcmp(a.data, b.data, a.size) == 0; -} - -#define Set(type) Set_##type -#define Map(T, U) Map_##T##U -#define PMap(T) Map(T, ptr_t) - -static const int value_init_int = 0; -static const ptr_t value_init_ptr_t = NULL; -static const ssize_t value_init_ssize_t = -1; -static const uint32_t value_init_uint32_t = 0; -static const uint64_t value_init_uint64_t = 0; -static const int64_t value_init_int64_t = 0; -static const String value_init_String = STRING_INIT; -static const ColorItem value_init_ColorItem = COLOR_ITEM_INITIALIZER; - -// layer 0: type non-specific code - -typedef struct { - uint32_t n_buckets; - uint32_t size; - uint32_t n_occupied; - uint32_t upper_bound; - uint32_t n_keys; // this is almost always "size", but keys[] could contain ded items.. - uint32_t keys_capacity; - uint32_t *hash; -} MapHash; - -#define MAPHASH_INIT { 0, 0, 0, 0, 0, 0, NULL } -#define SET_INIT { MAPHASH_INIT, NULL } -#define MAP_INIT { SET_INIT, NULL } - -#define MH_TOMBSTONE UINT32_MAX - -#define mh_is_empty(h, i) ((h)->hash[i] == 0) -#define mh_is_del(h, i) ((h)->hash[i] == MH_TOMBSTONE) -#define mh_is_either(h, i) ((uint32_t)((h)->hash[i] + 1U) <= 1U) - -typedef enum { - kMHExisting = 0, - kMHNewKeyDidFit, - kMHNewKeyRealloc, -} MHPutStatus; - -void mh_clear(MapHash *h); -void mh_realloc(MapHash *h, uint32_t n_min_buckets); - -// layer 1: key type specific defs -// This is all need for sets. - -#define MH_DECLS(T, K, K_query) \ - typedef struct { \ - MapHash h; \ - K *keys; \ - } Set(T); \ - \ - uint32_t mh_find_bucket_##T(Set(T) *set, K_query key, bool put); \ - uint32_t mh_get_##T(Set(T) *set, K_query key); \ - void mh_rehash_##T(Set(T) *set); \ - uint32_t mh_put_##T(Set(T) *set, K_query key, MHPutStatus *new); \ - -#define KEY_DECLS(T) \ - MH_DECLS(T, T, T) \ - uint32_t mh_delete_##T(Set(T) *set, T *key); \ - static inline bool set_put_##T(Set(T) *set, T key, T **key_alloc) { \ - MHPutStatus status; \ - uint32_t k = mh_put_##T(set, key, &status); \ - if (key_alloc) { \ - *key_alloc = &set->keys[k]; \ - } \ - return status != kMHExisting; \ - } \ - static inline T set_del_##T(Set(T) *set, T key) \ - { \ - mh_delete_##T(set, &key); \ - return key; \ - } \ - static inline bool set_has_##T(Set(T) *set, T key) { \ - return mh_get_##T(set, key) != MH_TOMBSTONE; \ - } \ - -// layer 2: key+value specific defs -// now we finally get Maps - -#define MAP_DECLS(T, U) \ - typedef struct { \ - Set(T) set; \ - U *values; \ - } Map(T, U); \ - static inline U map_get_##T##U(Map(T, U) *map, T key) \ - { \ - uint32_t k = mh_get_##T(&map->set, key); \ - return k == MH_TOMBSTONE ? value_init_##U : map->values[k]; \ - } \ - U *map_ref_##T##U(Map(T, U) *map, T key, T **key_alloc); \ - U *map_put_ref_##T##U(Map(T, U) *map, T key, T **key_alloc, bool *new_item); \ - static inline void map_put_##T##U(Map(T, U) *map, T key, U value) \ - { \ - U *val = map_put_ref_##T##U(map, key, NULL, NULL); \ - *val = value; \ - } \ - U map_del_##T##U(Map(T, U) *map, T key, T *key_alloc); \ - -// NOTE: Keys AND values must be allocated! Map and Set does not make a copy. - -#define quasiquote(x, y) x##y - -MH_DECLS(glyph, char, String) -KEY_DECLS(int) -KEY_DECLS(cstr_t) -KEY_DECLS(ptr_t) -KEY_DECLS(uint64_t) -KEY_DECLS(int64_t) -KEY_DECLS(uint32_t) -KEY_DECLS(String) -KEY_DECLS(HlEntry) -KEY_DECLS(ColorKey) - -MAP_DECLS(int, int) -MAP_DECLS(int, ptr_t) -MAP_DECLS(cstr_t, ptr_t) -MAP_DECLS(cstr_t, int) -MAP_DECLS(ptr_t, ptr_t) -MAP_DECLS(uint32_t, ptr_t) -MAP_DECLS(uint64_t, ptr_t) -MAP_DECLS(uint64_t, ssize_t) -MAP_DECLS(uint64_t, uint64_t) -MAP_DECLS(int64_t, int64_t) -MAP_DECLS(int64_t, ptr_t) -MAP_DECLS(uint32_t, uint32_t) -MAP_DECLS(String, int) -MAP_DECLS(int, String) -MAP_DECLS(ColorKey, ColorItem) - -#define set_has(T, set, key) set_has_##T(set, key) -#define set_put(T, set, key) set_put_##T(set, key, NULL) -#define set_put_ref(T, set, key, key_alloc) set_put_##T(set, key, key_alloc) -#define set_put_idx(T, set, key, status) mh_put_##T(set, key, status) -#define set_del(T, set, key) set_del_##T(set, key) -#define set_destroy(T, set) (xfree((set)->keys), xfree((set)->h.hash)) -#define set_clear(T, set) mh_clear(&(set)->h) -#define set_size(set) ((set)->h.size) - -#define map_get(T, U) map_get_##T##U -#define map_has(T, map, key) set_has(T, &(map)->set, key) -#define map_put(T, U) map_put_##T##U -#define map_ref(T, U) map_ref_##T##U -#define map_put_ref(T, U) map_put_ref_##T##U -#define map_del(T, U) map_del_##T##U -#define map_destroy(T, map) (set_destroy(T, &(map)->set), xfree((map)->values)) -#define map_clear(T, map) set_clear(T, &(map)->set) -#define map_size(map) set_size(&(map)->set) - -#define pmap_get(T) map_get(T, ptr_t) -#define pmap_put(T) map_put(T, ptr_t) -#define pmap_ref(T) map_ref(T, ptr_t) -#define pmap_put_ref(T) map_put_ref(T, ptr_t) -/// @see pmap_del2 -#define pmap_del(T) map_del(T, ptr_t) - -#define set_foreach(set, key, block) \ - { \ - uint32_t __i; \ - for (__i = 0; __i < (set)->h.n_keys; __i++) { \ - (key) = (set)->keys[__i]; \ - block; \ - } \ - } - -#define map_foreach_key(map, key, block) set_foreach(&(map)->set, key, block) - -#define map_foreach(map, key, value, code) \ - { \ - uint32_t __i; \ - for (__i = 0; __i < (map)->set.h.n_keys; __i++) { \ - (key) = (map)->set.keys[__i]; \ - (value) = (map)->values[__i]; \ - code; \ - } \ - } - -#define map_foreach_value(map, value, code) \ - { \ - uint32_t __i; \ - for (__i = 0; __i < (map)->set.h.n_keys; __i++) { \ - (value) = (map)->values[__i]; \ - code; \ - } \ - } - -void pmap_del2(PMap(cstr_t) *map, const char *key); diff --git a/src/nvim/map_defs.h b/src/nvim/map_defs.h new file mode 100644 index 0000000000..147c03327a --- /dev/null +++ b/src/nvim/map_defs.h @@ -0,0 +1,226 @@ +#pragma once + +#include +#include +#include + +#include "nvim/api/private/defs.h" +#include "nvim/assert_defs.h" +#include "nvim/highlight_defs.h" +#include "nvim/types_defs.h" + +#if defined(__NetBSD__) +# undef uint64_t +# define uint64_t uint64_t +#endif + +typedef const char *cstr_t; +typedef void *ptr_t; + +// when used as a key, String doesn't need to be NUL terminated, +// and can also contain embedded NUL:s as part of the data. +static inline uint32_t hash_String(String s) +{ + uint32_t h = 0; + for (size_t i = 0; i < s.size; i++) { + h = (h << 5) - h + (uint8_t)s.data[i]; + } + return h; +} + +static inline bool equal_String(String a, String b) +{ + if (a.size != b.size) { + return false; + } + return memcmp(a.data, b.data, a.size) == 0; +} + +#define Set(type) Set_##type +#define Map(T, U) Map_##T##U +#define PMap(T) Map(T, ptr_t) + +static const int value_init_int = 0; +static const ptr_t value_init_ptr_t = NULL; +static const ssize_t value_init_ssize_t = -1; +static const uint32_t value_init_uint32_t = 0; +static const uint64_t value_init_uint64_t = 0; +static const int64_t value_init_int64_t = 0; +static const String value_init_String = STRING_INIT; +static const ColorItem value_init_ColorItem = COLOR_ITEM_INITIALIZER; + +// layer 0: type non-specific code + +typedef struct { + uint32_t n_buckets; + uint32_t size; + uint32_t n_occupied; + uint32_t upper_bound; + uint32_t n_keys; // this is almost always "size", but keys[] could contain ded items.. + uint32_t keys_capacity; + uint32_t *hash; +} MapHash; + +#define MAPHASH_INIT { 0, 0, 0, 0, 0, 0, NULL } +#define SET_INIT { MAPHASH_INIT, NULL } +#define MAP_INIT { SET_INIT, NULL } + +#define MH_TOMBSTONE UINT32_MAX + +#define mh_is_empty(h, i) ((h)->hash[i] == 0) +#define mh_is_del(h, i) ((h)->hash[i] == MH_TOMBSTONE) +#define mh_is_either(h, i) ((uint32_t)((h)->hash[i] + 1U) <= 1U) + +typedef enum { + kMHExisting = 0, + kMHNewKeyDidFit, + kMHNewKeyRealloc, +} MHPutStatus; + +void mh_clear(MapHash *h); +void mh_realloc(MapHash *h, uint32_t n_min_buckets); + +// layer 1: key type specific defs +// This is all need for sets. + +#define MH_DECLS(T, K, K_query) \ + typedef struct { \ + MapHash h; \ + K *keys; \ + } Set(T); \ + \ + uint32_t mh_find_bucket_##T(Set(T) *set, K_query key, bool put); \ + uint32_t mh_get_##T(Set(T) *set, K_query key); \ + void mh_rehash_##T(Set(T) *set); \ + uint32_t mh_put_##T(Set(T) *set, K_query key, MHPutStatus *new); \ + +#define KEY_DECLS(T) \ + MH_DECLS(T, T, T) \ + uint32_t mh_delete_##T(Set(T) *set, T *key); \ + static inline bool set_put_##T(Set(T) *set, T key, T **key_alloc) { \ + MHPutStatus status; \ + uint32_t k = mh_put_##T(set, key, &status); \ + if (key_alloc) { \ + *key_alloc = &set->keys[k]; \ + } \ + return status != kMHExisting; \ + } \ + static inline T set_del_##T(Set(T) *set, T key) \ + { \ + mh_delete_##T(set, &key); \ + return key; \ + } \ + static inline bool set_has_##T(Set(T) *set, T key) { \ + return mh_get_##T(set, key) != MH_TOMBSTONE; \ + } \ + +// layer 2: key+value specific defs +// now we finally get Maps + +#define MAP_DECLS(T, U) \ + typedef struct { \ + Set(T) set; \ + U *values; \ + } Map(T, U); \ + static inline U map_get_##T##U(Map(T, U) *map, T key) \ + { \ + uint32_t k = mh_get_##T(&map->set, key); \ + return k == MH_TOMBSTONE ? value_init_##U : map->values[k]; \ + } \ + U *map_ref_##T##U(Map(T, U) *map, T key, T **key_alloc); \ + U *map_put_ref_##T##U(Map(T, U) *map, T key, T **key_alloc, bool *new_item); \ + static inline void map_put_##T##U(Map(T, U) *map, T key, U value) \ + { \ + U *val = map_put_ref_##T##U(map, key, NULL, NULL); \ + *val = value; \ + } \ + U map_del_##T##U(Map(T, U) *map, T key, T *key_alloc); \ + +// NOTE: Keys AND values must be allocated! Map and Set does not make a copy. + +#define quasiquote(x, y) x##y + +MH_DECLS(glyph, char, String) +KEY_DECLS(int) +KEY_DECLS(cstr_t) +KEY_DECLS(ptr_t) +KEY_DECLS(uint64_t) +KEY_DECLS(int64_t) +KEY_DECLS(uint32_t) +KEY_DECLS(String) +KEY_DECLS(HlEntry) +KEY_DECLS(ColorKey) + +MAP_DECLS(int, int) +MAP_DECLS(int, ptr_t) +MAP_DECLS(cstr_t, ptr_t) +MAP_DECLS(cstr_t, int) +MAP_DECLS(ptr_t, ptr_t) +MAP_DECLS(uint32_t, ptr_t) +MAP_DECLS(uint64_t, ptr_t) +MAP_DECLS(uint64_t, ssize_t) +MAP_DECLS(uint64_t, uint64_t) +MAP_DECLS(int64_t, int64_t) +MAP_DECLS(int64_t, ptr_t) +MAP_DECLS(uint32_t, uint32_t) +MAP_DECLS(String, int) +MAP_DECLS(int, String) +MAP_DECLS(ColorKey, ColorItem) + +#define set_has(T, set, key) set_has_##T(set, key) +#define set_put(T, set, key) set_put_##T(set, key, NULL) +#define set_put_ref(T, set, key, key_alloc) set_put_##T(set, key, key_alloc) +#define set_put_idx(T, set, key, status) mh_put_##T(set, key, status) +#define set_del(T, set, key) set_del_##T(set, key) +#define set_destroy(T, set) (xfree((set)->keys), xfree((set)->h.hash)) +#define set_clear(T, set) mh_clear(&(set)->h) +#define set_size(set) ((set)->h.size) + +#define map_get(T, U) map_get_##T##U +#define map_has(T, map, key) set_has(T, &(map)->set, key) +#define map_put(T, U) map_put_##T##U +#define map_ref(T, U) map_ref_##T##U +#define map_put_ref(T, U) map_put_ref_##T##U +#define map_del(T, U) map_del_##T##U +#define map_destroy(T, map) (set_destroy(T, &(map)->set), xfree((map)->values)) +#define map_clear(T, map) set_clear(T, &(map)->set) +#define map_size(map) set_size(&(map)->set) + +#define pmap_get(T) map_get(T, ptr_t) +#define pmap_put(T) map_put(T, ptr_t) +#define pmap_ref(T) map_ref(T, ptr_t) +#define pmap_put_ref(T) map_put_ref(T, ptr_t) +/// @see pmap_del2 +#define pmap_del(T) map_del(T, ptr_t) + +#define set_foreach(set, key, block) \ + { \ + uint32_t __i; \ + for (__i = 0; __i < (set)->h.n_keys; __i++) { \ + (key) = (set)->keys[__i]; \ + block; \ + } \ + } + +#define map_foreach_key(map, key, block) set_foreach(&(map)->set, key, block) + +#define map_foreach(map, key, value, code) \ + { \ + uint32_t __i; \ + for (__i = 0; __i < (map)->set.h.n_keys; __i++) { \ + (key) = (map)->set.keys[__i]; \ + (value) = (map)->values[__i]; \ + code; \ + } \ + } + +#define map_foreach_value(map, value, code) \ + { \ + uint32_t __i; \ + for (__i = 0; __i < (map)->set.h.n_keys; __i++) { \ + (value) = (map)->values[__i]; \ + code; \ + } \ + } + +void pmap_del2(PMap(cstr_t) *map, const char *key); diff --git a/src/nvim/map_glyph_cache.c b/src/nvim/map_glyph_cache.c index ba3ee49499..5efa87b960 100644 --- a/src/nvim/map_glyph_cache.c +++ b/src/nvim/map_glyph_cache.c @@ -13,9 +13,9 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/ascii_defs.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" uint32_t mh_find_bucket_glyph(Set(glyph) *set, String key, bool put) diff --git a/src/nvim/map_key_impl.c.h b/src/nvim/map_key_impl.c.h index 4d060f5fb8..5568c049ab 100644 --- a/src/nvim/map_key_impl.c.h +++ b/src/nvim/map_key_impl.c.h @@ -1,4 +1,4 @@ -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #ifndef KEY_NAME diff --git a/src/nvim/map_value_impl.c.h b/src/nvim/map_value_impl.c.h index 8f07bd8fa7..d93856c25d 100644 --- a/src/nvim/map_value_impl.c.h +++ b/src/nvim/map_value_impl.c.h @@ -1,5 +1,5 @@ -#include "nvim/assert.h" -#include "nvim/map.h" +#include "nvim/assert_defs.h" +#include "nvim/map_defs.h" #if !defined(KEY_NAME) || !defined(VAL_NAME) // Don't error out. it is nice to type-check the file in isolation, in clangd or otherwise diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 7a39838c7e..6fc9c04194 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -14,7 +14,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" @@ -32,7 +32,7 @@ #include "nvim/highlight_defs.h" #include "nvim/keycodes.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/mbyte.h" #include "nvim/memory.h" @@ -47,7 +47,7 @@ #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// List used for abbreviations. static mapblock_T *first_abbr = NULL; // first entry in abbrlist diff --git a/src/nvim/mark.c b/src/nvim/mark.c index e576253c89..8bc9965b50 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" @@ -36,7 +36,7 @@ #include "nvim/quickfix.h" #include "nvim/strings.h" #include "nvim/textobject.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // This file contains routines to maintain and manipulate marks. diff --git a/src/nvim/mark.h b/src/nvim/mark.h index d338871df0..3237ae541e 100644 --- a/src/nvim/mark.h +++ b/src/nvim/mark.h @@ -3,12 +3,12 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/extmark_defs.h" #include "nvim/func_attr.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark_defs.h" // IWYU pragma: export #include "nvim/memory.h" #include "nvim/os/time.h" diff --git a/src/nvim/mark_defs.h b/src/nvim/mark_defs.h index c488cf2e1a..67532d030f 100644 --- a/src/nvim/mark_defs.h +++ b/src/nvim/mark_defs.h @@ -1,7 +1,7 @@ #pragma once #include "nvim/eval/typval_defs.h" -#include "nvim/os/time.h" +#include "nvim/os/time_defs.h" #include "nvim/pos_defs.h" // marks: positions in a file diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index 7a06d9d453..b555b3b4ae 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -58,7 +58,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/garray_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #define T MT_BRANCH_FACTOR #define ILEN (sizeof(MTNode) + (2 * T) * sizeof(void *)) diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h index 128c6dcf63..37119048ae 100644 --- a/src/nvim/marktree.h +++ b/src/nvim/marktree.h @@ -6,10 +6,10 @@ #include #include "klib/kvec.h" -#include "nvim/assert.h" +#include "nvim/assert_defs.h" #include "nvim/decoration_defs.h" #include "nvim/garray_defs.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" // only for debug functions: diff --git a/src/nvim/match.c b/src/nvim/match.c index 4599619a6f..0a7c264d4f 100644 --- a/src/nvim/match.c +++ b/src/nvim/match.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/drawscreen.h" @@ -21,7 +21,7 @@ #include "nvim/globals.h" #include "nvim/highlight.h" #include "nvim/highlight_group.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/match.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -33,7 +33,7 @@ #include "nvim/regexp.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "match.c.generated.h" diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 9443511640..f2883cc5c7 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -37,7 +37,7 @@ #include "auto/config.h" #include "nvim/arabic.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" @@ -49,9 +49,9 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/grid.h" -#include "nvim/iconv.h" +#include "nvim/iconv_defs.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/mbyte_defs.h" @@ -64,7 +64,7 @@ #include "nvim/pos_defs.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" typedef struct { int rangeStart; diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h index 6e27679198..49c323282d 100644 --- a/src/nvim/mbyte.h +++ b/src/nvim/mbyte.h @@ -8,7 +8,7 @@ #include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/func_attr.h" #include "nvim/mbyte_defs.h" // IWYU pragma: export -#include "nvim/os/os_defs.h" +#include "nvim/os/os_defs.h" // IWYU pragma: export #include "nvim/types_defs.h" // IWYU pragma: keep // Return byte length of character that starts with byte "b". diff --git a/src/nvim/mbyte_defs.h b/src/nvim/mbyte_defs.h index bd73694f97..c5c973c71a 100644 --- a/src/nvim/mbyte_defs.h +++ b/src/nvim/mbyte_defs.h @@ -2,7 +2,7 @@ #include -#include "nvim/iconv.h" +#include "nvim/iconv_defs.h" /// max length of an unicode char enum { MB_MAXCHAR = 6, }; diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 9fc6492dad..d989600d45 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -44,12 +44,12 @@ #include #include -#include "nvim/assert.h" +#include "nvim/assert_defs.h" #include "nvim/buffer_defs.h" #include "nvim/fileio.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/memfile.h" #include "nvim/memfile_defs.h" #include "nvim/memline.h" @@ -60,7 +60,7 @@ #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/pos_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #define MEMFILE_PAGE_SIZE 4096 /// default page size diff --git a/src/nvim/memfile_defs.h b/src/nvim/memfile_defs.h index dd7d4324e1..db68ecf039 100644 --- a/src/nvim/memfile_defs.h +++ b/src/nvim/memfile_defs.h @@ -4,7 +4,7 @@ #include #include -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 5b3534ec91..3ecbcaad1e 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -45,7 +45,7 @@ #include "auto/config.h" #include "klib/kvec.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -62,9 +62,9 @@ #include "nvim/globals.h" #include "nvim/highlight_defs.h" #include "nvim/input.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memfile.h" @@ -86,7 +86,7 @@ #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/version.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifndef UNIX // it's in os/unix_defs.h for Unix # include diff --git a/src/nvim/memory.c b/src/nvim/memory.c index c6b741fd00..5eb4a548fb 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -10,7 +10,7 @@ #include "nvim/api/extmark.h" #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_updates.h" #include "nvim/context.h" #include "nvim/decoration_provider.h" @@ -32,7 +32,7 @@ #include "nvim/sign.h" #include "nvim/ui.h" #include "nvim/usercmd.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef UNIT_TESTING # define malloc(size) mem_malloc(size) diff --git a/src/nvim/memory.h b/src/nvim/memory.h index 18bcf11111..c37866ebc5 100644 --- a/src/nvim/memory.h +++ b/src/nvim/memory.h @@ -1,11 +1,10 @@ #pragma once #include -#include -#include -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory_defs.h" // IWYU pragma: export /// `malloc()` function signature diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 3d154f53d1..fb42913bfe 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" @@ -22,7 +22,7 @@ #include "nvim/globals.h" #include "nvim/highlight_defs.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/menu.h" @@ -35,7 +35,7 @@ #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #define MENUDEPTH 10 // maximum depth of menus diff --git a/src/nvim/message.c b/src/nvim/message.c index fcfaf636e6..4bf099d1fa 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -11,7 +11,7 @@ #include #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/channel.h" #include "nvim/charset.h" @@ -54,7 +54,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/ui_compositor.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // To be able to scroll back at the "more" and "hit-enter" prompts we need to // store the displayed text and remember where screen lines start. diff --git a/src/nvim/message.h b/src/nvim/message.h index 1e6e1dec70..04ea1a76ff 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -8,7 +8,7 @@ #include "nvim/api/private/defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/grid_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/types_defs.h" /// Types of dialogs passed to do_dialog(). diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index b3cbe371ed..b07163d1f8 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -4,7 +4,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" @@ -20,7 +20,7 @@ #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -42,7 +42,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/ui_compositor.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/mouse.h b/src/nvim/mouse.h index 0e38f279aa..5d2475005e 100644 --- a/src/nvim/mouse.h +++ b/src/nvim/mouse.h @@ -4,7 +4,7 @@ #include "nvim/buffer_defs.h" #include "nvim/normal.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" /// jump_to_mouse() returns one of first five these values, possibly with diff --git a/src/nvim/move.c b/src/nvim/move.c index 6451080eae..9ed3978490 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -13,7 +13,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/cursor.h" #include "nvim/diff.h" @@ -28,7 +28,7 @@ #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -44,7 +44,7 @@ #include "nvim/sign_defs.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #include "nvim/winfloat.h" diff --git a/src/nvim/move.h b/src/nvim/move.h index 137940f87e..ab8fb2b386 100644 --- a/src/nvim/move.h +++ b/src/nvim/move.h @@ -5,7 +5,7 @@ #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "move.h.generated.h" diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 57c9e64b3b..0fb1ebf931 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -24,7 +24,7 @@ #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/msgpack_rpc/channel.h" diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h index e8ea71173a..818bee8318 100644 --- a/src/nvim/msgpack_rpc/channel.h +++ b/src/nvim/msgpack_rpc/channel.h @@ -8,7 +8,7 @@ #include "nvim/event/process.h" #include "nvim/event/socket.h" #include "nvim/event/wstream.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory_defs.h" // IWYU pragma: keep #include "nvim/msgpack_rpc/channel_defs.h" // IWYU pragma: export diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 1eb57ec4dc..20b8a89afb 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -9,7 +9,7 @@ #include "nvim/api/private/dispatch.h" #include "nvim/event/process.h" #include "nvim/event/socket.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" typedef struct Channel Channel; typedef struct Unpacker Unpacker; diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 3aac2618c0..1fdfc9e536 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -9,7 +9,7 @@ #include "klib/kvec.h" #include "msgpack/pack.h" #include "nvim/api/private/helpers.h" -#include "nvim/assert.h" +#include "nvim/assert_defs.h" #include "nvim/func_attr.h" #include "nvim/memory.h" #include "nvim/msgpack_rpc/helpers.h" diff --git a/src/nvim/msgpack_rpc/unpacker.c b/src/nvim/msgpack_rpc/unpacker.c index 9fd80e506a..38263381bf 100644 --- a/src/nvim/msgpack_rpc/unpacker.c +++ b/src/nvim/msgpack_rpc/unpacker.c @@ -5,9 +5,9 @@ #include "klib/kvec.h" #include "mpack/conv.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/grid.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/msgpack_rpc/channel_defs.h" #include "nvim/msgpack_rpc/helpers.h" diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 10463aacb7..503b3671fa 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -15,7 +15,7 @@ #include #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -42,7 +42,7 @@ #include "nvim/help.h" #include "nvim/highlight_defs.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/mark.h" #include "nvim/mbyte.h" @@ -73,7 +73,7 @@ #include "nvim/textobject.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" typedef struct normal_state { diff --git a/src/nvim/normal.h b/src/nvim/normal.h index e9c506253b..9fb332d320 100644 --- a/src/nvim/normal.h +++ b/src/nvim/normal.h @@ -2,8 +2,8 @@ #include -#include "nvim/buffer_defs.h" -#include "nvim/macros.h" +#include "nvim/buffer_defs.h" // IWYU pragma: keep +#include "nvim/macros_defs.h" #include "nvim/pos_defs.h" // Values for find_ident_under_cursor() diff --git a/src/nvim/ops.c b/src/nvim/ops.c index e31f126834..e66f46945e 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -12,8 +12,8 @@ #include #include "nvim/api/private/defs.h" -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/change.h" @@ -36,7 +36,7 @@ #include "nvim/indent.h" #include "nvim/indent_c.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -60,7 +60,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" static yankreg_T y_regs[NUM_REGISTERS] = { 0 }; diff --git a/src/nvim/ops.h b/src/nvim/ops.h index 85a6f66011..106e59f383 100644 --- a/src/nvim/ops.h +++ b/src/nvim/ops.h @@ -4,11 +4,11 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/extmark.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/normal.h" #include "nvim/option_defs.h" #include "nvim/os/time.h" diff --git a/src/nvim/option.c b/src/nvim/option.c index eda8ccbfb7..ec974aaa7a 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -30,7 +30,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/change.h" @@ -61,7 +61,7 @@ #include "nvim/keycodes.h" #include "nvim/log.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/mbyte.h" #include "nvim/memfile.h" @@ -95,7 +95,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef BACKSLASH_IN_FILENAME diff --git a/src/nvim/option_vars.h b/src/nvim/option_vars.h index bffdfb25ef..0907df59c9 100644 --- a/src/nvim/option_vars.h +++ b/src/nvim/option_vars.h @@ -1,6 +1,6 @@ #pragma once -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/types_defs.h" // option_vars.h: definition of global variables for settable options diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index da9f0ae350..281ec86171 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -3,7 +3,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" @@ -26,7 +26,7 @@ #include "nvim/indent.h" #include "nvim/indent_c.h" #include "nvim/insexpand.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -44,7 +44,7 @@ #include "nvim/spellsuggest.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 2b1907b025..8620c79069 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -9,7 +9,7 @@ #include #include "auto/config.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" @@ -18,8 +18,8 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/log.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option_vars.h" @@ -28,7 +28,7 @@ #include "nvim/path.h" #include "nvim/strings.h" #include "nvim/version.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef MSWIN # include "nvim/mbyte.h" diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index 4aad4c39c6..79d6ac08e7 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -15,7 +15,7 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/log.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/os/fileio.h" diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 16151086c7..3fc9e0ab69 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -33,18 +33,18 @@ # include #endif -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/log.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option_vars.h" #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef HAVE_SYS_UIO_H # include diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 296433d782..5ae24c89ab 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -6,7 +6,7 @@ #include #include "nvim/api/private/defs.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" @@ -18,7 +18,7 @@ #include "nvim/globals.h" #include "nvim/keycodes.h" #include "nvim/log.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/msgpack_rpc/channel.h" #include "nvim/option_vars.h" @@ -28,7 +28,7 @@ #include "nvim/profile.h" #include "nvim/rbuffer.h" #include "nvim/state.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #define READ_BUFFER_SIZE 0xfff #define INPUT_BUFFER_SIZE (READ_BUFFER_SIZE * 4) diff --git a/src/nvim/os/input.h b/src/nvim/os/input.h index b077f80860..4b104b0b50 100644 --- a/src/nvim/os/input.h +++ b/src/nvim/os/input.h @@ -5,7 +5,7 @@ #include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/event/multiqueue.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" EXTERN bool used_stdin INIT( = false); diff --git a/src/nvim/os/lang.c b/src/nvim/os/lang.c index e6db41a8ac..17d179a56a 100644 --- a/src/nvim/os/lang.c +++ b/src/nvim/os/lang.c @@ -12,7 +12,7 @@ #include #include "auto/config.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" @@ -20,7 +20,7 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/garray.h" #include "nvim/gettext.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" @@ -29,7 +29,7 @@ #include "nvim/os/shell.h" #include "nvim/path.h" #include "nvim/profile.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/lang.c.generated.h" diff --git a/src/nvim/os/os_win_console.c b/src/nvim/os/os_win_console.c index 784f97e58b..1a5ecefaa9 100644 --- a/src/nvim/os/os_win_console.c +++ b/src/nvim/os/os_win_console.c @@ -2,7 +2,7 @@ #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/os_win_console.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/os_win_console.c.generated.h" diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c index 7b47ba7020..d9ec3a7a8a 100644 --- a/src/nvim/os/process.c +++ b/src/nvim/os/process.c @@ -28,7 +28,7 @@ #if defined(__APPLE__) || defined(BSD) # include -# include "nvim/macros.h" +# include "nvim/macros_defs.h" #endif #if defined(__linux__) diff --git a/src/nvim/os/pty_conpty_win.c b/src/nvim/os/pty_conpty_win.c index 819b6fcf77..53169c0ef8 100644 --- a/src/nvim/os/pty_conpty_win.c +++ b/src/nvim/os/pty_conpty_win.c @@ -2,7 +2,7 @@ #include "nvim/os/os.h" #include "nvim/os/pty_conpty_win.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifndef EXTENDED_STARTUPINFO_PRESENT # define EXTENDED_STARTUPINFO_PRESENT 0x00080000 diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index 19eedd14cd..ca2dce36ea 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -2,7 +2,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/eval/typval.h" #include "nvim/mbyte.h" #include "nvim/memory.h" diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 817448d0d2..0aaa7be2b8 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -7,7 +7,7 @@ #include "auto/config.h" #include "klib/kvec.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" @@ -23,7 +23,7 @@ #include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -43,7 +43,7 @@ #include "nvim/tag.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #define DYNAMIC_BUFFER_INIT { NULL, 0, 0 } #define NS_1_SECOND 1000000000U // 1 second, in nanoseconds diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 3bb23dcfdc..7691aa5122 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -2,7 +2,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/fileio.h" #include "nvim/func_attr.h" #include "nvim/globals.h" diff --git a/src/nvim/os/time.h b/src/nvim/os/time.h index fa9989c757..2748ba6953 100644 --- a/src/nvim/os/time.h +++ b/src/nvim/os/time.h @@ -1,10 +1,9 @@ #pragma once #include // IWYU pragma: keep -#include #include // IWYU pragma: keep -typedef uint64_t Timestamp; +#include "nvim/os/time_defs.h" // IWYU pragma: export #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/time.h.generated.h" diff --git a/src/nvim/os/time_defs.h b/src/nvim/os/time_defs.h new file mode 100644 index 0000000000..9b71a6764d --- /dev/null +++ b/src/nvim/os/time_defs.h @@ -0,0 +1,4 @@ +#pragma once + +#include +typedef uint64_t Timestamp; diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index f0666435cc..5f77b5a6ee 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -6,12 +6,12 @@ #include #include "auto/config.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/cmdexpand_defs.h" #include "nvim/garray.h" #include "nvim/memory.h" #include "nvim/os/os.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef HAVE_PWD_FUNCS # include #endif diff --git a/src/nvim/path.c b/src/nvim/path.c index c7ec8eccd6..c7212c7ade 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -7,7 +7,7 @@ #include #include "auto/config.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" #include "nvim/eval.h" @@ -20,7 +20,7 @@ #include "nvim/garray_defs.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" @@ -33,7 +33,7 @@ #include "nvim/path.h" #include "nvim/regexp.h" #include "nvim/strings.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" enum { diff --git a/src/nvim/plines.c b/src/nvim/plines.c index f4a0daffd6..5ad453043b 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -5,7 +5,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/decoration.h" #include "nvim/diff.h" @@ -13,7 +13,7 @@ #include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/indent.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -24,7 +24,7 @@ #include "nvim/pos_defs.h" #include "nvim/state.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "plines.c.generated.h" diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index 37c36ac1a2..5f2faf01b7 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -8,7 +8,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/charset.h" #include "nvim/drawscreen.h" @@ -34,7 +34,7 @@ #include "nvim/strings.h" #include "nvim/ui.h" #include "nvim/ui_compositor.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" static pumitem_T *pum_array = NULL; // items of displayed pum diff --git a/src/nvim/popupmenu.h b/src/nvim/popupmenu.h index 8f2b665174..24a3f8713a 100644 --- a/src/nvim/popupmenu.h +++ b/src/nvim/popupmenu.h @@ -4,7 +4,7 @@ #include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/grid_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/menu_defs.h" // IWYU pragma: keep /// Used for popup menu items. diff --git a/src/nvim/profile.c b/src/nvim/profile.c index 8c98700ee2..53ff57dacb 100644 --- a/src/nvim/profile.c +++ b/src/nvim/profile.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" #include "nvim/debugger.h" diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 6e4d6f39db..eee0296ad6 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -11,7 +11,7 @@ #include #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/charset.h" @@ -36,7 +36,7 @@ #include "nvim/help.h" #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -59,7 +59,7 @@ #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" struct dir_stack_T { diff --git a/src/nvim/rbuffer.c b/src/nvim/rbuffer.c index 5745f303aa..f74f68adb6 100644 --- a/src/nvim/rbuffer.c +++ b/src/nvim/rbuffer.c @@ -4,7 +4,7 @@ #include #include "nvim/func_attr.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/rbuffer.h" diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 3e6c7c159b..3536196a3b 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -15,7 +15,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/eval.h" @@ -26,7 +26,7 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -41,7 +41,7 @@ #include "nvim/regexp_defs.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // Structure used to save the current input state, when it needs to be // restored after trying a match. Used by reg_save() and reg_restore(). diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index d5c076d914..a0926865e6 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -15,7 +15,7 @@ #include "klib/kvec.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" @@ -33,8 +33,8 @@ #include "nvim/globals.h" #include "nvim/hashtab.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -54,7 +54,7 @@ #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/usercmd.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// Structure used to store info for each sourced file. /// It is shared between do_source() and getsourceline(). diff --git a/src/nvim/search.c b/src/nvim/search.c index f40705ff5d..4c790a50a1 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -8,7 +8,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -31,7 +31,7 @@ #include "nvim/highlight_defs.h" #include "nvim/indent_c.h" #include "nvim/insexpand.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -52,7 +52,7 @@ #include "nvim/search.h" #include "nvim/strings.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/search.h b/src/nvim/search.h index 949bb41859..c86bb2700f 100644 --- a/src/nvim/search.h +++ b/src/nvim/search.h @@ -9,7 +9,7 @@ #include "nvim/os/time.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // Values for the find_pattern_in_path() function args 'type' and 'action': #define FIND_ANY 1 diff --git a/src/nvim/sha256.c b/src/nvim/sha256.c index d179a0c279..1a07c0856d 100644 --- a/src/nvim/sha256.c +++ b/src/nvim/sha256.c @@ -16,7 +16,7 @@ #include #include "nvim/sha256.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "sha256.c.generated.h" diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 8078f950c7..be898142f0 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -15,7 +15,7 @@ #include "auto/config.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/cmdhist.h" #include "nvim/eval.h" @@ -30,8 +30,8 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/hashtab.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memory.h" @@ -52,7 +52,7 @@ #include "nvim/shada.h" #include "nvim/strings.h" #include "nvim/version.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef HAVE_BE64TOH # define _BSD_SOURCE 1 // NOLINT(bugprone-reserved-identifier) diff --git a/src/nvim/sign.c b/src/nvim/sign.c index b4cc6a8cea..62dc450ff5 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -11,7 +11,7 @@ #include "nvim/api/extmark.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" @@ -31,8 +31,8 @@ #include "nvim/globals.h" #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" -#include "nvim/macros.h" -#include "nvim/map.h" +#include "nvim/macros_defs.h" +#include "nvim/map_defs.h" #include "nvim/marktree.h" #include "nvim/mbyte.h" #include "nvim/memory.h" @@ -43,7 +43,7 @@ #include "nvim/sign_defs.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" static PMap(cstr_t) sign_map INIT( = MAP_INIT); diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 8033e3d46e..0b4f363d64 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -61,7 +61,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/change.h" @@ -81,7 +81,7 @@ #include "nvim/highlight_defs.h" #include "nvim/insexpand.h" #include "nvim/log.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -105,7 +105,7 @@ #include "nvim/syntax.h" #include "nvim/types_defs.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" // Result values. Lower number is accepted over higher one. diff --git a/src/nvim/spell.h b/src/nvim/spell.h index 17e7dd6c40..f3977fdaf2 100644 --- a/src/nvim/spell.h +++ b/src/nvim/spell.h @@ -5,7 +5,7 @@ #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/globals.h" #include "nvim/spell_defs.h" // IWYU pragma: export -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// First language that is loaded, start of the linked list of loaded languages. extern slang_T *first_lang; diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index b30e595b2f..2607fddc31 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -235,7 +235,7 @@ #include #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/charset.h" #include "nvim/drawscreen.h" @@ -246,7 +246,7 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/hashtab.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -267,7 +267,7 @@ #include "nvim/strings.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // Special byte values for . Some are only used in the tree for // postponed prefixes, some only in the other trees. This is a bit messy... diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index af9f4db45a..0a48e613ed 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -9,7 +9,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/change.h" #include "nvim/charset.h" @@ -26,7 +26,7 @@ #include "nvim/hashtab.h" #include "nvim/highlight_defs.h" #include "nvim/input.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -46,7 +46,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // Use this to adjust the score after finding suggestions, based on the // suggested word sounding like the bad word. This is much faster than doing diff --git a/src/nvim/state.c b/src/nvim/state.c index 76d75cf1fb..91258a5c8b 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -1,7 +1,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" @@ -14,7 +14,7 @@ #include "nvim/insexpand.h" #include "nvim/keycodes.h" #include "nvim/log.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/option.h" #include "nvim/option_vars.h" @@ -23,7 +23,7 @@ #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "state.c.generated.h" // IWYU pragma: export diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 6acc328be3..d42a180948 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -8,7 +8,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" @@ -23,7 +23,7 @@ #include "nvim/grid.h" #include "nvim/highlight.h" #include "nvim/highlight_group.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -41,7 +41,7 @@ #include "nvim/strings.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" // Determines how deeply nested %{} blocks will be evaluated in statusline. diff --git a/src/nvim/statusline.h b/src/nvim/statusline.h index 79ae84c5ce..eab7c1aa47 100644 --- a/src/nvim/statusline.h +++ b/src/nvim/statusline.h @@ -3,7 +3,7 @@ #include #include "nvim/buffer_defs.h" // IWYU pragma: keep -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/statusline_defs.h" // IWYU pragma: export /// Array defining what should be done when tabline is clicked diff --git a/src/nvim/statusline_defs.h b/src/nvim/statusline_defs.h index e0beff9528..c1a54f4f54 100644 --- a/src/nvim/statusline_defs.h +++ b/src/nvim/statusline_defs.h @@ -4,7 +4,7 @@ #include #include "nvim/fold_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/os/os_defs.h" #include "nvim/sign_defs.h" diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 06f5166864..1533a486bc 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -9,8 +9,8 @@ #include #include "auto/config.h" -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/charset.h" #include "nvim/eval/encode.h" #include "nvim/eval/typval.h" @@ -19,7 +19,7 @@ #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/math.h" #include "nvim/mbyte.h" #include "nvim/memory.h" @@ -28,7 +28,7 @@ #include "nvim/plines.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" static const char e_cannot_mix_positional_and_non_positional_str[] = N_("E1500: Cannot mix positional and non-positional arguments: %s"); diff --git a/src/nvim/strings.h b/src/nvim/strings.h index 4e6c37d585..f71396817d 100644 --- a/src/nvim/strings.h +++ b/src/nvim/strings.h @@ -1,11 +1,11 @@ #pragma once #include // IWYU pragma: keep -#include #include #include "klib/kvec.h" #include "nvim/eval/typval_defs.h" // IWYU pragma: keep +#include "nvim/func_attr.h" #include "nvim/types_defs.h" // IWYU pragma: keep /// Append string to string and return pointer to the next byte diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index cf59b14a9a..33d0d46d94 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -7,7 +7,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -28,7 +28,7 @@ #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" #include "nvim/indent_c.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -44,7 +44,7 @@ #include "nvim/strings.h" #include "nvim/syntax.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" static bool did_syntax_onoff = false; diff --git a/src/nvim/syntax.h b/src/nvim/syntax.h index 9ead4aa89a..4e9c7a27dc 100644 --- a/src/nvim/syntax.h +++ b/src/nvim/syntax.h @@ -6,7 +6,7 @@ #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/syntax_defs.h" // IWYU pragma: export #define HL_CONTAINED 0x01 // not used on toplevel diff --git a/src/nvim/tag.c b/src/nvim/tag.c index b936ca618f..3b6a1bfe85 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -8,7 +8,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/charset.h" @@ -32,7 +32,7 @@ #include "nvim/highlight_defs.h" #include "nvim/input.h" #include "nvim/insexpand.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memory.h" @@ -55,7 +55,7 @@ #include "nvim/strings.h" #include "nvim/tag.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" // Structure to hold pointers to various items in a tag line. diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 4cbba9a14f..1527738165 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -45,7 +45,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -65,9 +65,9 @@ #include "nvim/highlight.h" #include "nvim/highlight_group.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -84,7 +84,7 @@ #include "nvim/terminal.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" typedef struct terminal_state { VimState state; diff --git a/src/nvim/testing.c b/src/nvim/testing.c index 5cc8e0c31d..cada04d276 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/eval.h" #include "nvim/eval/encode.h" #include "nvim/eval/typval.h" @@ -17,7 +17,7 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/hashtab.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" @@ -26,7 +26,7 @@ #include "nvim/strings.h" #include "nvim/testing.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// Type of assert_* check being performed typedef enum { diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index d9ee406c75..25a197d401 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -4,7 +4,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/change.h" #include "nvim/charset.h" @@ -19,7 +19,7 @@ #include "nvim/globals.h" #include "nvim/indent.h" #include "nvim/indent_c.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -37,7 +37,7 @@ #include "nvim/textformat.h" #include "nvim/textobject.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index d5025fde6b..3a0a3cc659 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -5,7 +5,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" #include "nvim/edit.h" @@ -14,7 +14,7 @@ #include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/indent.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -26,7 +26,7 @@ #include "nvim/search.h" #include "nvim/strings.h" #include "nvim/textobject.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "textobject.c.generated.h" diff --git a/src/nvim/textobject.h b/src/nvim/textobject.h index 9e78a98d4a..2ca5be43b7 100644 --- a/src/nvim/textobject.h +++ b/src/nvim/textobject.h @@ -2,7 +2,7 @@ #include "nvim/normal.h" #include "nvim/pos_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "textobject.h.generated.h" diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 923421b00d..bdbb5e4872 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -8,9 +8,9 @@ #include "nvim/api/private/helpers.h" #include "nvim/event/defs.h" #include "nvim/func_attr.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #include "nvim/option_vars.h" #include "nvim/os/os.h" diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index ff636fb839..3cf9650428 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -7,7 +7,7 @@ #include "klib/kvec.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/memory.h" #include "nvim/strings.h" diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 3b00afed40..197bbcabb5 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -13,7 +13,7 @@ #include "klib/kvec.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/cursor_shape.h" #include "nvim/event/loop.h" #include "nvim/event/signal.h" @@ -23,7 +23,7 @@ #include "nvim/grid.h" #include "nvim/highlight_defs.h" #include "nvim/log.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/mbyte.h" #include "nvim/memory.h" diff --git a/src/nvim/ui.c b/src/nvim/ui.c index a2791be583..3cc07b835e 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -10,7 +10,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" #include "nvim/api/ui.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/cursor_shape.h" @@ -23,7 +23,7 @@ #include "nvim/highlight_defs.h" #include "nvim/log.h" #include "nvim/lua/executor.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" @@ -33,7 +33,7 @@ #include "nvim/ui.h" #include "nvim/ui_client.h" #include "nvim/ui_compositor.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #include "nvim/winfloat.h" diff --git a/src/nvim/ui.h b/src/nvim/ui.h index 0dc53e4ecc..666a869c89 100644 --- a/src/nvim/ui.h +++ b/src/nvim/ui.h @@ -8,7 +8,7 @@ #include "nvim/event/multiqueue.h" #include "nvim/globals.h" #include "nvim/highlight_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/types_defs.h" diff --git a/src/nvim/ui_client.h b/src/nvim/ui_client.h index 48dd9a0835..93170ed86d 100644 --- a/src/nvim/ui_client.h +++ b/src/nvim/ui_client.h @@ -6,7 +6,7 @@ #include "nvim/api/private/defs.h" #include "nvim/grid_defs.h" // IWYU pragma: keep -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/types_defs.h" typedef struct { diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c index 18234818f3..9b6dafae98 100644 --- a/src/nvim/ui_compositor.c +++ b/src/nvim/ui_compositor.c @@ -13,13 +13,13 @@ #include "klib/kvec.h" #include "nvim/api/private/defs.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" #include "nvim/highlight_group.h" #include "nvim/log.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option_vars.h" @@ -27,7 +27,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/ui_compositor.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ui_compositor.c.generated.h" diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 9b6e2d7939..b60211941f 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -83,7 +83,7 @@ #include "auto/config.h" #include "klib/kvec.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_updates.h" @@ -105,7 +105,7 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -125,7 +125,7 @@ #include "nvim/types_defs.h" #include "nvim/undo.h" #include "nvim/undo_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" /// Structure passed around between undofile functions. typedef struct { diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index c7b09ff299..e277bfb829 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -10,7 +10,7 @@ #include "auto/config.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" @@ -23,7 +23,7 @@ #include "nvim/highlight_defs.h" #include "nvim/keycodes.h" #include "nvim/lua/executor.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/mbyte.h" #include "nvim/memory.h" @@ -34,7 +34,7 @@ #include "nvim/runtime.h" #include "nvim/strings.h" #include "nvim/usercmd.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/version.c b/src/nvim/version.c index 22ba6523a4..d6fcfaaf1f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -15,7 +15,7 @@ #include "auto/versiondef_git.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/charset.h" #include "nvim/drawscreen.h" @@ -32,7 +32,7 @@ #include "nvim/option_vars.h" #include "nvim/strings.h" #include "nvim/version.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // for ":version", ":intro", and "nvim --version" #ifndef NVIM_VERSION_MEDIUM diff --git a/src/nvim/version.h b/src/nvim/version.h index 6e5862501a..94219aaddc 100644 --- a/src/nvim/version.h +++ b/src/nvim/version.h @@ -1,7 +1,7 @@ #pragma once #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep -#include "nvim/macros.h" +#include "nvim/macros_defs.h" // defined in version.c extern char *Version; diff --git a/src/nvim/vim.h b/src/nvim/vim.h deleted file mode 100644 index 8de59aa2f9..0000000000 --- a/src/nvim/vim.h +++ /dev/null @@ -1,204 +0,0 @@ -#pragma once - -#include "nvim/pos_defs.h" -#include "nvim/types_defs.h" - -// Some defines from the old feature.h -#define SESSION_FILE "Session.vim" -#define MAX_MSG_HIST_LEN 200 -#define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim" -#define RUNTIME_DIRNAME "runtime" - -#include "auto/config.h" -#define HAVE_PATHDEF - -// Some file names are stored in pathdef.c, which is generated from the -// Makefile to make their value depend on the Makefile. -#ifdef HAVE_PATHDEF -extern char *default_vim_dir; -extern char *default_vimruntime_dir; -extern char *default_lib_dir; -#endif - -// Check if configure correctly managed to find sizeof(int). If this failed, -// it becomes zero. This is likely a problem of not being able to run the -// test program. Other items from configure may also be wrong then! -#if (SIZEOF_INT == 0) -# error Configure did not run properly. -#endif - -#include "nvim/os/os_defs.h" // bring lots of system header files - -/// length of a buffer to store a number in ASCII (64 bits binary + NUL) -enum { NUMBUFLEN = 65, }; - -#define MAX_TYPENR 65535 - -#define ROOT_UID 0 - -#include "nvim/gettext.h" -#include "nvim/keycodes.h" -#include "nvim/macros.h" - -// special attribute addition: Put message in history -#define MSG_HIST 0x1000 - -// Values for State -// -// The lower bits up to 0x80 are used to distinguish normal/visual/op_pending -// /cmdline/insert/replace/terminal mode. This is used for mapping. If none -// of these bits are set, no mapping is done. See the comment above do_map(). -// The upper bits are used to distinguish between other states and variants of -// the base modes. - -#define MODE_NORMAL 0x01 // Normal mode, command expected -#define MODE_VISUAL 0x02 // Visual mode - use get_real_state() -#define MODE_OP_PENDING 0x04 // Normal mode, operator is pending - use - // get_real_state() -#define MODE_CMDLINE 0x08 // Editing the command line -#define MODE_INSERT 0x10 // Insert mode, also for Replace mode -#define MODE_LANGMAP 0x20 // Language mapping, can be combined with - // MODE_INSERT and MODE_CMDLINE -#define MODE_SELECT 0x40 // Select mode, use get_real_state() -#define MODE_TERMINAL 0x80 // Terminal mode - -#define MAP_ALL_MODES 0xff // all mode bits used for mapping - -#define REPLACE_FLAG 0x100 // Replace mode flag -#define MODE_REPLACE (REPLACE_FLAG | MODE_INSERT) -#define VREPLACE_FLAG 0x200 // Virtual-replace mode flag -#define MODE_VREPLACE (REPLACE_FLAG | VREPLACE_FLAG | MODE_INSERT) -#define MODE_LREPLACE (REPLACE_FLAG | MODE_LANGMAP) - -#define MODE_NORMAL_BUSY (0x1000 | MODE_NORMAL) // Normal mode, busy with a command -#define MODE_HITRETURN (0x2000 | MODE_NORMAL) // waiting for return or command -#define MODE_ASKMORE 0x3000 // Asking if you want --more-- -#define MODE_SETWSIZE 0x4000 // window size has changed -#define MODE_EXTERNCMD 0x5000 // executing an external command -#define MODE_SHOWMATCH (0x6000 | MODE_INSERT) // show matching paren -#define MODE_CONFIRM 0x7000 // ":confirm" prompt - -/// Directions. -typedef enum { - kDirectionNotSet = 0, - FORWARD = 1, - BACKWARD = (-1), - FORWARD_FILE = 3, - BACKWARD_FILE = (-3), -} Direction; - -// return values for functions -#if !(defined(OK) && (OK == 1)) -// OK already defined to 1 in MacOS X curses, skip this -# define OK 1 -#endif -#define FAIL 0 -#define NOTDONE 2 // not OK or FAIL but skipped - -// Minimal size for block 0 of a swap file. -// NOTE: This depends on size of struct block0! It's not done with a sizeof(), -// because struct block0 is defined in memline.c (Sorry). -// The maximal block size is arbitrary. -#define MIN_SWAP_PAGE_SIZE 1048 -#define MAX_SWAP_PAGE_SIZE 50000 - -#define STATUS_HEIGHT 1 // height of a status line under a window -#define QF_WINHEIGHT 10 // default height for quickfix window - -// Buffer sizes - -#ifndef CMDBUFFSIZE -# define CMDBUFFSIZE 256 // size of the command processing buffer -#endif - -#define LSIZE 512 // max. size of a line in the tags file - -#define DIALOG_MSG_SIZE 1000 // buffer size for dialog_msg() - -enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext() - -// Maximum length of key sequence to be mapped. -// Must be able to hold an Amiga resize report. - -#define MAXMAPLEN 50 - -// Size in bytes of the hash used in the undo file. -#define UNDO_HASH_SIZE 32 - -#define CLEAR_FIELD(field) memset(&(field), 0, sizeof(field)) -#define CLEAR_POINTER(ptr) memset((ptr), 0, sizeof(*(ptr))) - -// (vim_strchr() is now in strings.c) - -#ifndef HAVE_STRNLEN -# define strnlen xstrnlen // Older versions of SunOS may not have strnlen -#endif - -#define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) // NOLINT(runtime/printf) -#ifdef HAVE_STRCASECMP -# define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s)) -#else -# ifdef HAVE_STRICMP -# define STRICMP(d, s) stricmp((char *)(d), (char *)(s)) -# else -# define STRICMP(d, s) vim_stricmp((char *)(d), (char *)(s)) -# endif -#endif - -// Like strcpy() but allows overlapped source and destination. -#define STRMOVE(d, s) memmove((d), (s), strlen(s) + 1) - -#ifdef HAVE_STRNCASECMP -# define STRNICMP(d, s, n) strncasecmp((char *)(d), (char *)(s), (size_t)(n)) -#else -# ifdef HAVE_STRNICMP -# define STRNICMP(d, s, n) strnicmp((char *)(d), (char *)(s), (size_t)(n)) -# else -# define STRNICMP(d, s, n) vim_strnicmp((char *)(d), (char *)(s), (size_t)(n)) -# endif -#endif - -#define STRCAT(d, s) strcat((char *)(d), (char *)(s)) // NOLINT(runtime/printf) - -// Character used as separated in autoload function/variable names. -#define AUTOLOAD_CHAR '#' - -#include "nvim/message.h" - -// Prefer using semsg(), because perror() may send the output to the wrong -// destination and mess up the screen. -#define PERROR(msg) (void)semsg("%s: %s", (msg), strerror(errno)) - -#include "nvim/path.h" - -// Enums need a typecast to be used as array index. -#define HL_ATTR(n) hl_attr_active[(int)(n)] - -/// Maximum number of bytes in a multi-byte character. It can be one 32-bit -/// character of up to 6 bytes, or one 16-bit character of up to three bytes -/// plus six following composing characters of three bytes each. -#define MB_MAXBYTES 21 - -#ifndef MSWIN -/// Headless (no UI) error message handler. -# define os_errmsg(str) fprintf(stderr, "%s", (str)) -/// Headless (no UI) message handler. -# define os_msg(str) printf("%s", (str)) -#endif - -#include "nvim/buffer_defs.h" // buffer and windows -#include "nvim/ex_cmds_defs.h" // Ex command defines -#include "nvim/globals.h" // global variables and messages - -// Lowest number used for window ID. Cannot have this many windows per tab. -#define LOWEST_WIN_ID 1000 - -// BSD is supposed to cover FreeBSD and similar systems. -#if (defined(BSD) || defined(__FreeBSD_kernel__)) \ - && (defined(S_ISCHR) || defined(S_IFCHR)) -# define OPEN_CHR_FILES -#endif - -// Replacement for nchar used by nv_replace(). -#define REPLACE_CR_NCHAR (-1) -#define REPLACE_NL_NCHAR (-2) diff --git a/src/nvim/vim_defs.h b/src/nvim/vim_defs.h new file mode 100644 index 0000000000..42358fe4cb --- /dev/null +++ b/src/nvim/vim_defs.h @@ -0,0 +1,204 @@ +#pragma once + +#include "nvim/pos_defs.h" +#include "nvim/types_defs.h" + +// Some defines from the old feature.h +#define SESSION_FILE "Session.vim" +#define MAX_MSG_HIST_LEN 200 +#define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim" +#define RUNTIME_DIRNAME "runtime" + +#include "auto/config.h" +#define HAVE_PATHDEF + +// Some file names are stored in pathdef.c, which is generated from the +// Makefile to make their value depend on the Makefile. +#ifdef HAVE_PATHDEF +extern char *default_vim_dir; +extern char *default_vimruntime_dir; +extern char *default_lib_dir; +#endif + +// Check if configure correctly managed to find sizeof(int). If this failed, +// it becomes zero. This is likely a problem of not being able to run the +// test program. Other items from configure may also be wrong then! +#if (SIZEOF_INT == 0) +# error Configure did not run properly. +#endif + +#include "nvim/os/os_defs.h" // bring lots of system header files + +/// length of a buffer to store a number in ASCII (64 bits binary + NUL) +enum { NUMBUFLEN = 65, }; + +#define MAX_TYPENR 65535 + +#define ROOT_UID 0 + +#include "nvim/gettext.h" +#include "nvim/keycodes.h" +#include "nvim/macros_defs.h" + +// special attribute addition: Put message in history +#define MSG_HIST 0x1000 + +// Values for State +// +// The lower bits up to 0x80 are used to distinguish normal/visual/op_pending +// /cmdline/insert/replace/terminal mode. This is used for mapping. If none +// of these bits are set, no mapping is done. See the comment above do_map(). +// The upper bits are used to distinguish between other states and variants of +// the base modes. + +#define MODE_NORMAL 0x01 // Normal mode, command expected +#define MODE_VISUAL 0x02 // Visual mode - use get_real_state() +#define MODE_OP_PENDING 0x04 // Normal mode, operator is pending - use + // get_real_state() +#define MODE_CMDLINE 0x08 // Editing the command line +#define MODE_INSERT 0x10 // Insert mode, also for Replace mode +#define MODE_LANGMAP 0x20 // Language mapping, can be combined with + // MODE_INSERT and MODE_CMDLINE +#define MODE_SELECT 0x40 // Select mode, use get_real_state() +#define MODE_TERMINAL 0x80 // Terminal mode + +#define MAP_ALL_MODES 0xff // all mode bits used for mapping + +#define REPLACE_FLAG 0x100 // Replace mode flag +#define MODE_REPLACE (REPLACE_FLAG | MODE_INSERT) +#define VREPLACE_FLAG 0x200 // Virtual-replace mode flag +#define MODE_VREPLACE (REPLACE_FLAG | VREPLACE_FLAG | MODE_INSERT) +#define MODE_LREPLACE (REPLACE_FLAG | MODE_LANGMAP) + +#define MODE_NORMAL_BUSY (0x1000 | MODE_NORMAL) // Normal mode, busy with a command +#define MODE_HITRETURN (0x2000 | MODE_NORMAL) // waiting for return or command +#define MODE_ASKMORE 0x3000 // Asking if you want --more-- +#define MODE_SETWSIZE 0x4000 // window size has changed +#define MODE_EXTERNCMD 0x5000 // executing an external command +#define MODE_SHOWMATCH (0x6000 | MODE_INSERT) // show matching paren +#define MODE_CONFIRM 0x7000 // ":confirm" prompt + +/// Directions. +typedef enum { + kDirectionNotSet = 0, + FORWARD = 1, + BACKWARD = (-1), + FORWARD_FILE = 3, + BACKWARD_FILE = (-3), +} Direction; + +// return values for functions +#if !(defined(OK) && (OK == 1)) +// OK already defined to 1 in MacOS X curses, skip this +# define OK 1 +#endif +#define FAIL 0 +#define NOTDONE 2 // not OK or FAIL but skipped + +// Minimal size for block 0 of a swap file. +// NOTE: This depends on size of struct block0! It's not done with a sizeof(), +// because struct block0 is defined in memline.c (Sorry). +// The maximal block size is arbitrary. +#define MIN_SWAP_PAGE_SIZE 1048 +#define MAX_SWAP_PAGE_SIZE 50000 + +#define STATUS_HEIGHT 1 // height of a status line under a window +#define QF_WINHEIGHT 10 // default height for quickfix window + +// Buffer sizes + +#ifndef CMDBUFFSIZE +# define CMDBUFFSIZE 256 // size of the command processing buffer +#endif + +#define LSIZE 512 // max. size of a line in the tags file + +#define DIALOG_MSG_SIZE 1000 // buffer size for dialog_msg() + +enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext() + +// Maximum length of key sequence to be mapped. +// Must be able to hold an Amiga resize report. + +#define MAXMAPLEN 50 + +// Size in bytes of the hash used in the undo file. +#define UNDO_HASH_SIZE 32 + +#define CLEAR_FIELD(field) memset(&(field), 0, sizeof(field)) +#define CLEAR_POINTER(ptr) memset((ptr), 0, sizeof(*(ptr))) + +// (vim_strchr() is now in strings.c) + +#ifndef HAVE_STRNLEN +# define strnlen xstrnlen // Older versions of SunOS may not have strnlen +#endif + +#define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) // NOLINT(runtime/printf) +#ifdef HAVE_STRCASECMP +# define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s)) +#else +# ifdef HAVE_STRICMP +# define STRICMP(d, s) stricmp((char *)(d), (char *)(s)) +# else +# define STRICMP(d, s) vim_stricmp((char *)(d), (char *)(s)) +# endif +#endif + +// Like strcpy() but allows overlapped source and destination. +#define STRMOVE(d, s) memmove((d), (s), strlen(s) + 1) + +#ifdef HAVE_STRNCASECMP +# define STRNICMP(d, s, n) strncasecmp((char *)(d), (char *)(s), (size_t)(n)) +#else +# ifdef HAVE_STRNICMP +# define STRNICMP(d, s, n) strnicmp((char *)(d), (char *)(s), (size_t)(n)) +# else +# define STRNICMP(d, s, n) vim_strnicmp((char *)(d), (char *)(s), (size_t)(n)) +# endif +#endif + +#define STRCAT(d, s) strcat((char *)(d), (char *)(s)) // NOLINT(runtime/printf) + +// Character used as separated in autoload function/variable names. +#define AUTOLOAD_CHAR '#' + +#include "nvim/message.h" + +// Prefer using semsg(), because perror() may send the output to the wrong +// destination and mess up the screen. +#define PERROR(msg) (void)semsg("%s: %s", (msg), strerror(errno)) + +#include "nvim/path.h" + +// Enums need a typecast to be used as array index. +#define HL_ATTR(n) hl_attr_active[(int)(n)] + +/// Maximum number of bytes in a multi-byte character. It can be one 32-bit +/// character of up to 6 bytes, or one 16-bit character of up to three bytes +/// plus six following composing characters of three bytes each. +#define MB_MAXBYTES 21 + +#ifndef MSWIN +/// Headless (no UI) error message handler. +# define os_errmsg(str) fprintf(stderr, "%s", (str)) +/// Headless (no UI) message handler. +# define os_msg(str) printf("%s", (str)) +#endif + +#include "nvim/buffer_defs.h" // buffer and windows +#include "nvim/ex_cmds_defs.h" // Ex command defines +#include "nvim/globals.h" // global variables and messages + +// Lowest number used for window ID. Cannot have this many windows per tab. +#define LOWEST_WIN_ID 1000 + +// BSD is supposed to cover FreeBSD and similar systems. +#if (defined(BSD) || defined(__FreeBSD_kernel__)) \ + && (defined(S_ISCHR) || defined(S_IFCHR)) +# define OPEN_CHR_FILES +#endif + +// Replacement for nchar used by nv_replace(). +#define REPLACE_CR_NCHAR (-1) +#define REPLACE_NL_NCHAR (-2) diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 804f78b2b7..914f9ef445 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -55,17 +55,17 @@ #include #include "klib/kvec.h" -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/charset.h" #include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/viml/parser/expressions.h" #include "nvim/viml/parser/parser.h" diff --git a/src/nvim/window.c b/src/nvim/window.c index d4cb692148..ff62531dc7 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -11,7 +11,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -41,9 +41,9 @@ #include "nvim/grid.h" #include "nvim/hashtab.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/mapping.h" // IWYU pragma: keep (langmap_adjust_mb) #include "nvim/mark.h" #include "nvim/match.h" @@ -72,7 +72,7 @@ #include "nvim/ui.h" #include "nvim/ui_compositor.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #include "nvim/winfloat.h" diff --git a/src/nvim/window.h b/src/nvim/window.h index 9f82f3c4a8..39dd7f8766 100644 --- a/src/nvim/window.h +++ b/src/nvim/window.h @@ -4,7 +4,7 @@ #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/garray_defs.h" // IWYU pragma: keep -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/option_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep diff --git a/src/nvim/winfloat.c b/src/nvim/winfloat.c index d4082b5a8d..44f0e2fc0b 100644 --- a/src/nvim/winfloat.c +++ b/src/nvim/winfloat.c @@ -6,13 +6,13 @@ #include "klib/kvec.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/drawscreen.h" #include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/grid.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/mouse.h" #include "nvim/move.h" @@ -21,7 +21,7 @@ #include "nvim/pos_defs.h" #include "nvim/strings.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #include "nvim/winfloat.h" -- cgit