aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ascii_defs.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/ascii_defs.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/ascii_defs.h')
-rw-r--r--src/nvim/ascii_defs.h37
1 files changed, 12 insertions, 25 deletions
diff --git a/src/nvim/ascii_defs.h b/src/nvim/ascii_defs.h
index 0cd7ccfec4..155a18fb95 100644
--- a/src/nvim/ascii_defs.h
+++ b/src/nvim/ascii_defs.h
@@ -2,9 +2,12 @@
#include <stdbool.h>
-#include "nvim/func_attr.h"
#include "nvim/os/os_defs.h"
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "ascii_defs.h.inline.generated.h"
+#endif
+
// Definitions of various common control characters.
#define CHAR_ORD(x) ((uint8_t)(x) < 'a' \
@@ -82,31 +85,24 @@
# define PATHSEPSTR "/"
#endif
-static inline bool ascii_iswhite(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)
+ FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{
return c == ' ' || c == '\t';
}
-static inline bool ascii_iswhite_or_nul(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is a space or tab character or NUL.
///
/// @see {ascii_isdigit}
static inline bool ascii_iswhite_or_nul(int c)
+ FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{
return ascii_iswhite(c) || c == NUL;
}
-static inline bool ascii_isdigit(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
/// Check whether character is a decimal digit.
///
/// Library isdigit() function is officially locale-dependent and, for
@@ -117,64 +113,55 @@ static inline bool ascii_isdigit(int c)
/// what may be used for some optimizations (e.g. simple `return
/// isdigit_table[c];`).
static inline bool ascii_isdigit(int c)
+ FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{
return c >= '0' && c <= '9';
}
-static inline bool ascii_isxdigit(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
/// 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)
+ FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{
return (c >= '0' && c <= '9')
|| (c >= 'a' && c <= 'f')
|| (c >= 'A' && c <= 'F');
}
-static inline bool ascii_isident(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is an “identifier” character
///
/// That is, whether it is alphanumeric character or underscore.
static inline bool ascii_isident(int c)
+ FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{
return ASCII_ISALNUM(c) || c == '_';
}
-static inline bool ascii_isbdigit(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is a binary digit, that is, 0-1.
///
/// @see {ascii_isdigit}
static inline bool ascii_isbdigit(int c)
+ FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{
return (c == '0' || c == '1');
}
-static inline bool ascii_isodigit(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is an octal digit, that is, 0-7.
///
/// @see {ascii_isdigit}
static inline bool ascii_isodigit(int c)
+ FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{
return (c >= '0' && c <= '7');
}
-static inline bool ascii_isspace(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
/// 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)
+ FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{
return (c >= 9 && c <= 13) || c == ' ';
}