aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mbyte.h
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-06-13 12:00:58 +0200
committerbfredl <bjorn.linse@gmail.com>2024-07-13 12:30:49 +0200
commit7dffc36e61c46e6adc92cff5944e876446f3c40e (patch)
tree99278b5578dbcf5cbe5e53ca158bfc0de5df58d1 /src/nvim/mbyte.h
parentb0f39f3ef5502c037b5bdb0da3d45d312b7fdc2a (diff)
downloadrneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.tar.gz
rneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.tar.bz2
rneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.zip
refactor(declarations): also generate prototypes for functions in headers
Before this change, "static inline" functions in headers needed to have their function attributes specified in a completely different way. The prototype had to be duplicated, and REAL_FATTR_ had to be used instead of the public FUNC_ATTR_ names. TODO: need a check that a "header.h.inline.generated.h" file is not forgotten when the first "static inline" function with attributes is added to a header (they would just be silently missing).
Diffstat (limited to 'src/nvim/mbyte.h')
-rw-r--r--src/nvim/mbyte.h17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h
index ddac040aae..6cbfbcbc3c 100644
--- a/src/nvim/mbyte.h
+++ b/src/nvim/mbyte.h
@@ -7,13 +7,13 @@
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
-#include "nvim/func_attr.h"
#include "nvim/macros_defs.h"
#include "nvim/mbyte_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "mbyte.h.generated.h"
+# include "mbyte.h.inline.generated.h"
#endif
enum {
@@ -53,18 +53,14 @@ extern const uint8_t utf8len_tab[256];
(p -= utf_head_off((char *)(s), (char *)(p) - 1) + 1)
/// Check whether a given UTF-8 byte is a trailing byte (10xx.xxxx).
-static inline bool utf_is_trail_byte(uint8_t byte)
- REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE;
static inline bool utf_is_trail_byte(uint8_t const byte)
+ FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{
// uint8_t is for clang to use smaller cmp
return (uint8_t)(byte & 0xC0U) == 0x80U;
}
-static inline CharInfo utf_ptr2CharInfo(char const *p_in)
- REAL_FATTR_NONNULL_ALL REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE;
-
/// Convert a UTF-8 byte sequence to a Unicode code point.
/// Handles ascii, multibyte sequiences and illegal sequences.
///
@@ -73,6 +69,7 @@ static inline CharInfo utf_ptr2CharInfo(char const *p_in)
/// @return information abouth the character. When the sequence is illegal,
/// "value" is negative, "len" is 1.
static inline CharInfo utf_ptr2CharInfo(char const *const p_in)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE
{
uint8_t const *const p = (uint8_t const *)p_in;
uint8_t const first = *p;
@@ -88,14 +85,12 @@ static inline CharInfo utf_ptr2CharInfo(char const *const p_in)
}
}
-static inline StrCharInfo utfc_next(StrCharInfo cur)
- REAL_FATTR_NONNULL_ALL REAL_FATTR_ALWAYS_INLINE REAL_FATTR_PURE;
-
/// Return information about the next character.
/// Composing and combining characters are considered a part of the current character.
///
/// @param[in] cur Information about the current character in the string.
static inline StrCharInfo utfc_next(StrCharInfo cur)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE
{
int32_t prev_code = cur.chr.value;
uint8_t *next = (uint8_t *)(cur.ptr + cur.chr.len);
@@ -122,9 +117,7 @@ static inline StrCharInfo utfc_next(StrCharInfo cur)
}
static inline StrCharInfo utf_ptr2StrCharInfo(char *ptr)
- REAL_FATTR_NONNULL_ALL REAL_FATTR_ALWAYS_INLINE REAL_FATTR_PURE;
-
-static inline StrCharInfo utf_ptr2StrCharInfo(char *ptr)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE
{
return (StrCharInfo){ .ptr = ptr, .chr = utf_ptr2CharInfo(ptr) };
}