diff options
author | bfredl <bjorn.linse@gmail.com> | 2024-06-13 12:00:58 +0200 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2024-07-13 12:30:49 +0200 |
commit | 7dffc36e61c46e6adc92cff5944e876446f3c40e (patch) | |
tree | 99278b5578dbcf5cbe5e53ca158bfc0de5df58d1 /src/nvim/viml | |
parent | b0f39f3ef5502c037b5bdb0da3d45d312b7fdc2a (diff) | |
download | rneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.tar.gz rneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.tar.bz2 rneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.zip |
refactor(declarations): also generate prototypes for functions in headers
Before this change, "static inline" functions in headers needed to have
their function attributes specified in a completely different way. The
prototype had to be duplicated, and REAL_FATTR_ had to be used instead
of the public FUNC_ATTR_ names.
TODO: need a check that a "header.h.inline.generated.h" file is not
forgotten when the first "static inline" function with attributes
is added to a header (they would just be silently missing).
Diffstat (limited to 'src/nvim/viml')
-rw-r--r-- | src/nvim/viml/parser/parser.h | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h index 31decdc798..c4ebc1589a 100644 --- a/src/nvim/viml/parser/parser.h +++ b/src/nvim/viml/parser/parser.h @@ -5,13 +5,13 @@ #include <stddef.h> #include "klib/kvec.h" -#include "nvim/func_attr.h" #include "nvim/mbyte_defs.h" #include "nvim/viml/parser/parser_defs.h" // IWYU pragma: keep -static inline void viml_parser_init(ParserState *ret_pstate, ParserLineGetter get_line, - void *cookie, ParserHighlight *colors) - REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ARG(1, 2); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "viml/parser/parser.h.generated.h" +# include "viml/parser/parser.h.inline.generated.h" +#endif /// Initialize a new parser state instance /// @@ -22,6 +22,7 @@ static inline void viml_parser_init(ParserState *ret_pstate, ParserLineGetter ge /// needed. static inline void viml_parser_init(ParserState *const ret_pstate, const ParserLineGetter get_line, void *const cookie, ParserHighlight *const colors) + FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ARG(1, 2) { *ret_pstate = (ParserState) { .reader = { @@ -37,9 +38,6 @@ static inline void viml_parser_init(ParserState *const ret_pstate, const ParserL kvi_init(ret_pstate->stack); } -static inline void viml_parser_advance(ParserState *pstate, size_t len) - REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL; - /// Advance position by a given number of bytes /// /// At maximum advances to the next line. @@ -47,6 +45,7 @@ static inline void viml_parser_advance(ParserState *pstate, size_t len) /// @param pstate Parser state to advance. /// @param[in] len Number of bytes to advance. static inline void viml_parser_advance(ParserState *const pstate, const size_t len) + FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL { assert(pstate->pos.line == kv_size(pstate->reader.lines) - 1); const ParserLine pline = kv_last(pstate->reader.lines); @@ -58,10 +57,6 @@ static inline void viml_parser_advance(ParserState *const pstate, const size_t l } } -static inline void viml_parser_highlight(ParserState *pstate, ParserPosition start, size_t len, - const char *group) - REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL; - /// Record highlighting of some region of text /// /// @param pstate Parser state to work with. @@ -70,6 +65,7 @@ static inline void viml_parser_highlight(ParserState *pstate, ParserPosition sta /// @param[in] group Highlight group. static inline void viml_parser_highlight(ParserState *const pstate, const ParserPosition start, const size_t len, const char *const group) + FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL { if (pstate->colors == NULL || len == 0) { return; @@ -83,7 +79,3 @@ static inline void viml_parser_highlight(ParserState *const pstate, const Parser .group = group, })); } - -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "viml/parser/parser.h.generated.h" -#endif |