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).
This commit is contained in:
bfredl
2024-06-13 12:00:58 +02:00
parent b0f39f3ef5
commit 7dffc36e61
20 changed files with 187 additions and 245 deletions

View File

@@ -895,6 +895,7 @@ def CheckIncludes(filename, lines, error):
if (not name.endswith('.h.generated.h') and if (not name.endswith('.h.generated.h') and
not name.endswith('/defs.h') and not name.endswith('/defs.h') and
not name.endswith('_defs.h') and not name.endswith('_defs.h') and
not name.endswith('h.inline.generated.h') and
not name.endswith('_defs.generated.h') and not name.endswith('_defs.generated.h') and
not name.endswith('_enum.generated.h')): not name.endswith('_enum.generated.h')):
error(filename, i, 'build/include_defs', 5, error(filename, i, 'build/include_defs', 5,

View File

@@ -391,6 +391,7 @@ foreach(subdir
event event
eval eval
lua lua
lib
viml viml
viml/parser viml/parser
) )
@@ -428,6 +429,21 @@ endforeach()
list(REMOVE_ITEM NVIM_SOURCES ${to_remove}) list(REMOVE_ITEM NVIM_SOURCES ${to_remove})
foreach(hfile ${NVIM_HEADERS})
get_filename_component(f ${hfile} NAME)
if(WIN32 AND ${f} MATCHES "^(unix_defs.h)$")
list(APPEND to_remove_h ${hfile})
endif()
if(WIN32 AND ${f} MATCHES "^(pty_process_unix.h)$")
list(APPEND to_remove_h ${hfile})
endif()
if(NOT WIN32 AND ${f} MATCHES "^(win_defs.h)$")
list(APPEND to_remove_h ${hfile})
endif()
endforeach()
list(REMOVE_ITEM NVIM_HEADERS ${to_remove_h})
# xdiff, mpack, lua-cjson, termkey: inlined external project, we don't maintain it. #9306 # xdiff, mpack, lua-cjson, termkey: inlined external project, we don't maintain it. #9306
if(MSVC) if(MSVC)
set_source_files_properties( set_source_files_properties(
@@ -511,6 +527,7 @@ set(LUA_GEN_DEPS ${GENERATOR_PRELOAD} $<TARGET_FILE:nlua0>)
# NVIM_GENERATED_FOR_SOURCES: generated headers to be included in sources # NVIM_GENERATED_FOR_SOURCES: generated headers to be included in sources
# These lists must be mutually exclusive. # These lists must be mutually exclusive.
foreach(sfile ${NVIM_SOURCES} foreach(sfile ${NVIM_SOURCES}
${NVIM_HEADERS}
${GENERATED_API_DISPATCH} ${GENERATED_API_DISPATCH}
"${GENERATED_UI_EVENTS_CALL}" "${GENERATED_UI_EVENTS_CALL}"
"${GENERATED_UI_EVENTS_REMOTE}" "${GENERATED_UI_EVENTS_REMOTE}"
@@ -523,13 +540,25 @@ foreach(sfile ${NVIM_SOURCES}
endif() endif()
get_filename_component(f ${sfile} NAME) get_filename_component(f ${sfile} NAME)
get_filename_component(r ${sfile} NAME_WE) get_filename_component(r ${sfile} NAME_WE)
get_filename_component(ext ${sfile} EXT)
if(NOT ${d} EQUAL ".") if(NOT ${d} EQUAL ".")
set(f "${d}/${f}") set(f "${d}/${f}")
set(r "${d}/${r}") set(r "${d}/${r}")
endif() endif()
set (gf_basename "")
if ("${ext}" STREQUAL ".c.h")
continue() # .c.h files are sussy baka, skip
elseif(${sfile} IN_LIST NVIM_HEADERS)
set(gf_basename "${r}.h.inline.generated.h")
set(gf_c_h "${GENERATED_INCLUDES_DIR}/${r}.h.inline.generated.h")
set(gf_h_h "SKIP")
set(gf_h_h_out "")
else()
set(gf_c_h "${GENERATED_DIR}/${r}.c.generated.h") set(gf_c_h "${GENERATED_DIR}/${r}.c.generated.h")
set(gf_h_h "${GENERATED_INCLUDES_DIR}/${r}.h.generated.h") set(gf_h_h "${GENERATED_INCLUDES_DIR}/${r}.h.generated.h")
set(gf_i "${GENERATED_DIR}/${r}.i") set(gf_h_h_out "${gf_h_h}")
endif()
set(gf_i "${GENERATED_DIR}/${f}.i")
if(MSVC) if(MSVC)
set(PREPROC_OUTPUT /P /Fi${gf_i} /nologo) set(PREPROC_OUTPUT /P /Fi${gf_i} /nologo)
@@ -543,15 +572,17 @@ foreach(sfile ${NVIM_SOURCES}
list(APPEND depends update_version_stamp "${NVIM_VERSION_GIT_H}" "${NVIM_VERSION_DEF_H}") list(APPEND depends update_version_stamp "${NVIM_VERSION_GIT_H}" "${NVIM_VERSION_DEF_H}")
endif() endif()
add_custom_command( add_custom_command(
OUTPUT "${gf_c_h}" "${gf_h_h}" OUTPUT "${gf_c_h}" ${gf_h_h_out}
COMMAND ${CMAKE_C_COMPILER} ${sfile} ${PREPROC_OUTPUT} ${gen_cflags} COMMAND ${CMAKE_C_COMPILER} ${sfile} ${PREPROC_OUTPUT} ${gen_cflags}
COMMAND ${LUA_GEN} "${HEADER_GENERATOR}" "${sfile}" "${gf_c_h}" "${gf_h_h}" "${gf_i}" COMMAND ${LUA_GEN} "${HEADER_GENERATOR}" "${sfile}" "${gf_c_h}" "${gf_h_h}" "${gf_i}" "${gf_basename}"
DEPENDS ${depends}) DEPENDS ${depends})
list(APPEND NVIM_GENERATED_FOR_SOURCES "${gf_c_h}") list(APPEND NVIM_GENERATED_FOR_SOURCES "${gf_c_h}")
if (NOT ${sfile} IN_LIST NVIM_HEADERS)
list(APPEND NVIM_GENERATED_FOR_HEADERS "${gf_h_h}") list(APPEND NVIM_GENERATED_FOR_HEADERS "${gf_h_h}")
if(${d} MATCHES "^api$" AND NOT ${f} MATCHES "^api/helpers.c$") if(${d} MATCHES "^api$" AND NOT ${f} MATCHES "^api/helpers.c$")
list(APPEND API_HEADERS ${gf_h_h}) list(APPEND API_HEADERS ${gf_h_h})
endif() endif()
endif()
endforeach() endforeach()
add_custom_command(OUTPUT ${GENERATED_UNICODE_TABLES} add_custom_command(OUTPUT ${GENERATED_UNICODE_TABLES}

View File

@@ -5,7 +5,6 @@
#include <string.h> #include <string.h>
#include "klib/kvec.h" #include "klib/kvec.h"
#include "nvim/func_attr.h"
#include "nvim/types_defs.h" #include "nvim/types_defs.h"
#define ARRAY_DICT_INIT KV_INITIAL_VALUE #define ARRAY_DICT_INIT KV_INITIAL_VALUE
@@ -20,6 +19,7 @@
# define ArrayOf(...) Array # define ArrayOf(...) Array
# define DictionaryOf(...) Dictionary # define DictionaryOf(...) Dictionary
# define Dict(name) KeyDict_##name # define Dict(name) KeyDict_##name
# include "api/private/defs.h.inline.generated.h"
#endif #endif
// Basic types // Basic types
@@ -47,15 +47,13 @@ typedef enum {
/// Internal call from Lua code /// Internal call from Lua code
#define LUA_INTERNAL_CALL (VIML_INTERNAL_CALL + 1) #define LUA_INTERNAL_CALL (VIML_INTERNAL_CALL + 1)
static inline bool is_internal_call(uint64_t channel_id)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_CONST;
/// Check whether call is internal /// Check whether call is internal
/// ///
/// @param[in] channel_id Channel id. /// @param[in] channel_id Channel id.
/// ///
/// @return true if channel_id refers to internal channel. /// @return true if channel_id refers to internal channel.
static inline bool is_internal_call(const uint64_t channel_id) static inline bool is_internal_call(const uint64_t channel_id)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST
{ {
return !!(channel_id & INTERNAL_CALL_MASK); return !!(channel_id & INTERNAL_CALL_MASK);
} }

View File

@@ -2,9 +2,12 @@
#include <stdbool.h> #include <stdbool.h>
#include "nvim/func_attr.h"
#include "nvim/os/os_defs.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. // Definitions of various common control characters.
#define CHAR_ORD(x) ((uint8_t)(x) < 'a' \ #define CHAR_ORD(x) ((uint8_t)(x) < 'a' \
@@ -82,31 +85,24 @@
# define PATHSEPSTR "/" # define PATHSEPSTR "/"
#endif #endif
static inline bool ascii_iswhite(int c)
REAL_FATTR_CONST
REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is a space or tab character. /// Checks if `c` is a space or tab character.
/// ///
/// @see {ascii_isdigit} /// @see {ascii_isdigit}
static inline bool ascii_iswhite(int c) static inline bool ascii_iswhite(int c)
FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{ {
return c == ' ' || c == '\t'; 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. /// Checks if `c` is a space or tab character or NUL.
/// ///
/// @see {ascii_isdigit} /// @see {ascii_isdigit}
static inline bool ascii_iswhite_or_nul(int c) static inline bool ascii_iswhite_or_nul(int c)
FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{ {
return ascii_iswhite(c) || c == NUL; 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. /// Check whether character is a decimal digit.
/// ///
/// Library isdigit() function is officially locale-dependent and, for /// 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 /// what may be used for some optimizations (e.g. simple `return
/// isdigit_table[c];`). /// isdigit_table[c];`).
static inline bool ascii_isdigit(int c) static inline bool ascii_isdigit(int c)
FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{ {
return c >= '0' && c <= '9'; 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. /// Checks if `c` is a hexadecimal digit, that is, one of 0-9, a-f, A-F.
/// ///
/// @see {ascii_isdigit} /// @see {ascii_isdigit}
static inline bool ascii_isxdigit(int c) static inline bool ascii_isxdigit(int c)
FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{ {
return (c >= '0' && c <= '9') return (c >= '0' && c <= '9')
|| (c >= 'a' && c <= 'f') || (c >= 'a' && c <= 'f')
|| (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 /// Checks if `c` is an “identifier” character
/// ///
/// That is, whether it is alphanumeric character or underscore. /// That is, whether it is alphanumeric character or underscore.
static inline bool ascii_isident(int c) static inline bool ascii_isident(int c)
FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{ {
return ASCII_ISALNUM(c) || c == '_'; 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. /// Checks if `c` is a binary digit, that is, 0-1.
/// ///
/// @see {ascii_isdigit} /// @see {ascii_isdigit}
static inline bool ascii_isbdigit(int c) static inline bool ascii_isbdigit(int c)
FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{ {
return (c == '0' || c == '1'); 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. /// Checks if `c` is an octal digit, that is, 0-7.
/// ///
/// @see {ascii_isdigit} /// @see {ascii_isdigit}
static inline bool ascii_isodigit(int c) static inline bool ascii_isodigit(int c)
FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{ {
return (c >= '0' && c <= '7'); 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, /// Checks if `c` is a white-space character, that is,
/// one of \f, \n, \r, \t, \v. /// one of \f, \n, \r, \t, \v.
/// ///
/// @see {ascii_isdigit} /// @see {ascii_isdigit}
static inline bool ascii_isspace(int c) static inline bool ascii_isspace(int c)
FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{ {
return (c >= 9 && c <= 13) || c == ' '; return (c >= 9 && c <= 13) || c == ' ';
} }

View File

@@ -5,7 +5,6 @@
#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/buffer_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h" #include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/func_attr.h"
#include "nvim/gettext_defs.h" // IWYU pragma: keep #include "nvim/gettext_defs.h" // IWYU pragma: keep
#include "nvim/macros_defs.h" #include "nvim/macros_defs.h"
#include "nvim/marktree_defs.h" #include "nvim/marktree_defs.h"
@@ -76,18 +75,17 @@ EXTERN char *msg_qflist INIT( = N_("[Quickfix List]"));
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "buffer.h.generated.h" # include "buffer.h.generated.h"
# include "buffer.h.inline.generated.h"
#endif #endif
static inline varnumber_T buf_get_changedtick(const buf_T *buf)
REAL_FATTR_NONNULL_ALL REAL_FATTR_ALWAYS_INLINE REAL_FATTR_PURE
REAL_FATTR_WARN_UNUSED_RESULT;
/// Get b:changedtick value /// Get b:changedtick value
/// ///
/// Faster then querying b:. /// Faster then querying b:.
/// ///
/// @param[in] buf Buffer to get b:changedtick from. /// @param[in] buf Buffer to get b:changedtick from.
static inline varnumber_T buf_get_changedtick(const buf_T *const buf) static inline varnumber_T buf_get_changedtick(const buf_T *const buf)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE
FUNC_ATTR_WARN_UNUSED_RESULT
{ {
return buf->changedtick_di.di_tv.vval.v_number; return buf->changedtick_di.di_tv.vval.v_number;
} }

View File

@@ -8,18 +8,12 @@
#include "nvim/eval/typval_defs.h" #include "nvim/eval/typval_defs.h"
#include "nvim/event/defs.h" #include "nvim/event/defs.h"
#include "nvim/event/libuv_process.h" #include "nvim/event/libuv_process.h"
#include "nvim/func_attr.h"
#include "nvim/macros_defs.h" #include "nvim/macros_defs.h"
#include "nvim/map_defs.h" #include "nvim/map_defs.h"
#include "nvim/msgpack_rpc/channel_defs.h" #include "nvim/msgpack_rpc/channel_defs.h"
#include "nvim/os/pty_process.h" #include "nvim/os/pty_process.h"
#include "nvim/types_defs.h" #include "nvim/types_defs.h"
static inline bool callback_reader_set(CallbackReader reader)
{
return reader.cb.type != kCallbackNone || reader.self;
}
struct Channel { struct Channel {
uint64_t id; uint64_t id;
size_t refcount; size_t refcount;
@@ -49,14 +43,20 @@ struct Channel {
bool callback_scheduled; bool callback_scheduled;
}; };
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "channel.h.generated.h"
# include "channel.h.inline.generated.h"
#endif
static inline bool callback_reader_set(CallbackReader reader)
{
return reader.cb.type != kCallbackNone || reader.self;
}
EXTERN PMap(uint64_t) channels INIT( = MAP_INIT); EXTERN PMap(uint64_t) channels INIT( = MAP_INIT);
EXTERN Callback on_print INIT( = CALLBACK_INIT); EXTERN Callback on_print INIT( = CALLBACK_INIT);
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "channel.h.generated.h"
#endif
/// @returns Channel with the id or NULL if not found /// @returns Channel with the id or NULL if not found
static inline Channel *find_channel(uint64_t id) static inline Channel *find_channel(uint64_t id)
{ {
@@ -64,9 +64,7 @@ static inline Channel *find_channel(uint64_t id)
} }
static inline Stream *channel_instream(Channel *chan) static inline Stream *channel_instream(Channel *chan)
REAL_FATTR_NONNULL_ALL; FUNC_ATTR_NONNULL_ALL
static inline Stream *channel_instream(Channel *chan)
{ {
switch (chan->streamtype) { switch (chan->streamtype) {
case kChannelStreamProc: case kChannelStreamProc:
@@ -86,9 +84,7 @@ static inline Stream *channel_instream(Channel *chan)
} }
static inline RStream *channel_outstream(Channel *chan) static inline RStream *channel_outstream(Channel *chan)
REAL_FATTR_NONNULL_ALL; FUNC_ATTR_NONNULL_ALL
static inline RStream *channel_outstream(Channel *chan)
{ {
switch (chan->streamtype) { switch (chan->streamtype) {
case kChannelStreamProc: case kChannelStreamProc:

View File

@@ -3,7 +3,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "nvim/func_attr.h"
#include "nvim/option_vars.h" #include "nvim/option_vars.h"
#include "nvim/strings.h" // IWYU pragma: keep #include "nvim/strings.h" // IWYU pragma: keep
@@ -31,15 +30,13 @@ typedef enum {
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "charset.h.generated.h" # include "charset.h.generated.h"
# include "charset.h.inline.generated.h"
#endif #endif
static inline bool vim_isbreak(int c)
REAL_FATTR_CONST
REAL_FATTR_ALWAYS_INLINE;
/// Check if `c` is one of the characters in 'breakat'. /// Check if `c` is one of the characters in 'breakat'.
/// Used very often if 'linebreak' is set /// Used very often if 'linebreak' is set
static inline bool vim_isbreak(int c) static inline bool vim_isbreak(int c)
FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{ {
return breakat_flags[(uint8_t)c]; return breakat_flags[(uint8_t)c];
} }

View File

@@ -7,7 +7,6 @@
#include <string.h> #include <string.h>
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#include "nvim/func_attr.h"
#include "nvim/gettext_defs.h" #include "nvim/gettext_defs.h"
#include "nvim/hashtab.h" #include "nvim/hashtab.h"
#include "nvim/lib/queue_defs.h" #include "nvim/lib/queue_defs.h"
@@ -16,6 +15,10 @@
#include "nvim/message.h" #include "nvim/message.h"
#include "nvim/types_defs.h" #include "nvim/types_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "eval/typval.h.inline.generated.h"
#endif
// In a hashtab item "hi_key" points to "di_key" in a dictitem. // In a hashtab item "hi_key" points to "di_key" in a dictitem.
// This avoids adding a pointer to the hashtab item. // This avoids adding a pointer to the hashtab item.
@@ -23,15 +26,13 @@
#define TV_DICT_HI2DI(hi) \ #define TV_DICT_HI2DI(hi) \
((dictitem_T *)((hi)->hi_key - offsetof(dictitem_T, di_key))) ((dictitem_T *)((hi)->hi_key - offsetof(dictitem_T, di_key)))
static inline void tv_list_ref(list_T *l)
REAL_FATTR_ALWAYS_INLINE;
/// Increase reference count for a given list /// Increase reference count for a given list
/// ///
/// Does nothing for NULL lists. /// Does nothing for NULL lists.
/// ///
/// @param[in,out] l List to modify. /// @param[in,out] l List to modify.
static inline void tv_list_ref(list_T *const l) static inline void tv_list_ref(list_T *const l)
FUNC_ATTR_ALWAYS_INLINE
{ {
if (l == NULL) { if (l == NULL) {
return; return;
@@ -39,29 +40,25 @@ static inline void tv_list_ref(list_T *const l)
l->lv_refcount++; l->lv_refcount++;
} }
static inline void tv_list_set_ret(typval_T *tv, list_T *l)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ARG(1);
/// Set a list as the return value. Increments the reference count. /// Set a list as the return value. Increments the reference count.
/// ///
/// @param[out] tv Object to receive the list /// @param[out] tv Object to receive the list
/// @param[in,out] l List to pass to the object /// @param[in,out] l List to pass to the object
static inline void tv_list_set_ret(typval_T *const tv, list_T *const l) static inline void tv_list_set_ret(typval_T *const tv, list_T *const l)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ARG(1)
{ {
tv->v_type = VAR_LIST; tv->v_type = VAR_LIST;
tv->vval.v_list = l; tv->vval.v_list = l;
tv_list_ref(l); tv_list_ref(l);
} }
static inline VarLockStatus tv_list_locked(const list_T *l)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Get list lock status /// Get list lock status
/// ///
/// Returns VAR_FIXED for NULL lists. /// Returns VAR_FIXED for NULL lists.
/// ///
/// @param[in] l List to check. /// @param[in] l List to check.
static inline VarLockStatus tv_list_locked(const list_T *const l) static inline VarLockStatus tv_list_locked(const list_T *const l)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
if (l == NULL) { if (l == NULL) {
return VAR_FIXED; return VAR_FIXED;
@@ -84,9 +81,6 @@ static inline void tv_list_set_lock(list_T *const l, const VarLockStatus lock)
l->lv_lock = lock; l->lv_lock = lock;
} }
static inline void tv_list_set_copyid(list_T *l, int copyid)
REAL_FATTR_NONNULL_ALL;
/// Set list copyID /// Set list copyID
/// ///
/// Does not expect NULL list, be careful. /// Does not expect NULL list, be careful.
@@ -94,17 +88,16 @@ static inline void tv_list_set_copyid(list_T *l, int copyid)
/// @param[out] l List to modify. /// @param[out] l List to modify.
/// @param[in] copyid New copyID. /// @param[in] copyid New copyID.
static inline void tv_list_set_copyid(list_T *const l, const int copyid) static inline void tv_list_set_copyid(list_T *const l, const int copyid)
FUNC_ATTR_NONNULL_ALL
{ {
l->lv_copyID = copyid; l->lv_copyID = copyid;
} }
static inline int tv_list_len(const list_T *l)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Get the number of items in a list /// Get the number of items in a list
/// ///
/// @param[in] l List to check. /// @param[in] l List to check.
static inline int tv_list_len(const list_T *const l) static inline int tv_list_len(const list_T *const l)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
if (l == NULL) { if (l == NULL) {
return 0; return 0;
@@ -112,22 +105,17 @@ static inline int tv_list_len(const list_T *const l)
return l->lv_len; return l->lv_len;
} }
static inline int tv_list_copyid(const list_T *l)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL;
/// Get list copyID /// Get list copyID
/// ///
/// Does not expect NULL list, be careful. /// Does not expect NULL list, be careful.
/// ///
/// @param[in] l List to check. /// @param[in] l List to check.
static inline int tv_list_copyid(const list_T *const l) static inline int tv_list_copyid(const list_T *const l)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{ {
return l->lv_copyID; return l->lv_copyID;
} }
static inline list_T *tv_list_latest_copy(const list_T *l)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL;
/// Get latest list copy /// Get latest list copy
/// ///
/// Gets lv_copylist field assigned by tv_list_copy() earlier. /// Gets lv_copylist field assigned by tv_list_copy() earlier.
@@ -136,13 +124,11 @@ static inline list_T *tv_list_latest_copy(const list_T *l)
/// ///
/// @param[in] l List to check. /// @param[in] l List to check.
static inline list_T *tv_list_latest_copy(const list_T *const l) static inline list_T *tv_list_latest_copy(const list_T *const l)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{ {
return l->lv_copylist; return l->lv_copylist;
} }
static inline int tv_list_uidx(const list_T *l, int n)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Normalize index: that is, return either -1 or non-negative index /// Normalize index: that is, return either -1 or non-negative index
/// ///
/// @param[in] l List to index. Used to get length. /// @param[in] l List to index. Used to get length.
@@ -150,6 +136,7 @@ static inline int tv_list_uidx(const list_T *l, int n)
/// ///
/// @return -1 or list index in range [0, tv_list_len(l)). /// @return -1 or list index in range [0, tv_list_len(l)).
static inline int tv_list_uidx(const list_T *const l, int n) static inline int tv_list_uidx(const list_T *const l, int n)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
// Negative index is relative to the end. // Negative index is relative to the end.
if (n < 0) { if (n < 0) {
@@ -163,9 +150,6 @@ static inline int tv_list_uidx(const list_T *const l, int n)
return n; return n;
} }
static inline bool tv_list_has_watchers(const list_T *l)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Check whether list has watchers /// Check whether list has watchers
/// ///
/// E.g. is referenced by a :for loop. /// E.g. is referenced by a :for loop.
@@ -174,19 +158,18 @@ static inline bool tv_list_has_watchers(const list_T *l)
/// ///
/// @return true if there are watchers, false otherwise. /// @return true if there are watchers, false otherwise.
static inline bool tv_list_has_watchers(const list_T *const l) static inline bool tv_list_has_watchers(const list_T *const l)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
return l && l->lv_watch; return l && l->lv_watch;
} }
static inline listitem_T *tv_list_first(const list_T *l)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Get first list item /// Get first list item
/// ///
/// @param[in] l List to get item from. /// @param[in] l List to get item from.
/// ///
/// @return List item or NULL in case of an empty list. /// @return List item or NULL in case of an empty list.
static inline listitem_T *tv_list_first(const list_T *const l) static inline listitem_T *tv_list_first(const list_T *const l)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
if (l == NULL) { if (l == NULL) {
return NULL; return NULL;
@@ -194,15 +177,13 @@ static inline listitem_T *tv_list_first(const list_T *const l)
return l->lv_first; return l->lv_first;
} }
static inline listitem_T *tv_list_last(const list_T *l)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Get last list item /// Get last list item
/// ///
/// @param[in] l List to get item from. /// @param[in] l List to get item from.
/// ///
/// @return List item or NULL in case of an empty list. /// @return List item or NULL in case of an empty list.
static inline listitem_T *tv_list_last(const list_T *const l) static inline listitem_T *tv_list_last(const list_T *const l)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
if (l == NULL) { if (l == NULL) {
return NULL; return NULL;
@@ -210,14 +191,12 @@ static inline listitem_T *tv_list_last(const list_T *const l)
return l->lv_last; return l->lv_last;
} }
static inline void tv_dict_set_ret(typval_T *tv, dict_T *d)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ARG(1);
/// Set a dictionary as the return value /// Set a dictionary as the return value
/// ///
/// @param[out] tv Object to receive the dictionary /// @param[out] tv Object to receive the dictionary
/// @param[in,out] d Dictionary to pass to the object /// @param[in,out] d Dictionary to pass to the object
static inline void tv_dict_set_ret(typval_T *const tv, dict_T *const d) static inline void tv_dict_set_ret(typval_T *const tv, dict_T *const d)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ARG(1)
{ {
tv->v_type = VAR_DICT; tv->v_type = VAR_DICT;
tv->vval.v_dict = d; tv->vval.v_dict = d;
@@ -226,13 +205,11 @@ static inline void tv_dict_set_ret(typval_T *const tv, dict_T *const d)
} }
} }
static inline long tv_dict_len(const dict_T *d)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Get the number of items in a Dictionary /// Get the number of items in a Dictionary
/// ///
/// @param[in] d Dictionary to check. /// @param[in] d Dictionary to check.
static inline long tv_dict_len(const dict_T *const d) static inline long tv_dict_len(const dict_T *const d)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
if (d == NULL) { if (d == NULL) {
return 0; return 0;
@@ -240,22 +217,17 @@ static inline long tv_dict_len(const dict_T *const d)
return (long)d->dv_hashtab.ht_used; return (long)d->dv_hashtab.ht_used;
} }
static inline bool tv_dict_is_watched(const dict_T *d)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Check if dictionary is watched /// Check if dictionary is watched
/// ///
/// @param[in] d Dictionary to check. /// @param[in] d Dictionary to check.
/// ///
/// @return true if there is at least one watcher. /// @return true if there is at least one watcher.
static inline bool tv_dict_is_watched(const dict_T *const d) static inline bool tv_dict_is_watched(const dict_T *const d)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
return d && !QUEUE_EMPTY(&d->watchers); return d && !QUEUE_EMPTY(&d->watchers);
} }
static inline void tv_blob_set_ret(typval_T *tv, blob_T *b)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ARG(1);
/// Set a blob as the return value. /// Set a blob as the return value.
/// ///
/// Increments the reference count. /// Increments the reference count.
@@ -263,6 +235,7 @@ static inline void tv_blob_set_ret(typval_T *tv, blob_T *b)
/// @param[out] tv Object to receive the blob. /// @param[out] tv Object to receive the blob.
/// @param[in,out] b Blob to pass to the object. /// @param[in,out] b Blob to pass to the object.
static inline void tv_blob_set_ret(typval_T *const tv, blob_T *const b) static inline void tv_blob_set_ret(typval_T *const tv, blob_T *const b)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ARG(1)
{ {
tv->v_type = VAR_BLOB; tv->v_type = VAR_BLOB;
tv->vval.v_blob = b; tv->vval.v_blob = b;
@@ -271,13 +244,11 @@ static inline void tv_blob_set_ret(typval_T *const tv, blob_T *const b)
} }
} }
static inline int tv_blob_len(const blob_T *b)
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Get the length of the data in the blob, in bytes. /// Get the length of the data in the blob, in bytes.
/// ///
/// @param[in] b Blob to check. /// @param[in] b Blob to check.
static inline int tv_blob_len(const blob_T *const b) static inline int tv_blob_len(const blob_T *const b)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
if (b == NULL) { if (b == NULL) {
return 0; return 0;
@@ -285,9 +256,6 @@ static inline int tv_blob_len(const blob_T *const b)
return b->bv_ga.ga_len; return b->bv_ga.ga_len;
} }
static inline uint8_t tv_blob_get(const blob_T *b, int idx)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL REAL_FATTR_WARN_UNUSED_RESULT;
/// Get the byte at index `idx` in the blob. /// Get the byte at index `idx` in the blob.
/// ///
/// @param[in] b Blob to index. Cannot be NULL. /// @param[in] b Blob to index. Cannot be NULL.
@@ -295,19 +263,18 @@ static inline uint8_t tv_blob_get(const blob_T *b, int idx)
/// ///
/// @return Byte value at the given index. /// @return Byte value at the given index.
static inline uint8_t tv_blob_get(const blob_T *const b, int idx) static inline uint8_t tv_blob_get(const blob_T *const b, int idx)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{ {
return ((uint8_t *)b->bv_ga.ga_data)[idx]; return ((uint8_t *)b->bv_ga.ga_data)[idx];
} }
static inline void tv_blob_set(blob_T *blob, int idx, uint8_t c)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL;
/// Store the byte `c` at index `idx` in the blob. /// Store the byte `c` at index `idx` in the blob.
/// ///
/// @param[in] b Blob to index. Cannot be NULL. /// @param[in] b Blob to index. Cannot be NULL.
/// @param[in] idx Index in a blob. Must be valid. /// @param[in] idx Index in a blob. Must be valid.
/// @param[in] c Value to store. /// @param[in] c Value to store.
static inline void tv_blob_set(blob_T *const blob, int idx, uint8_t c) static inline void tv_blob_set(blob_T *const blob, int idx, uint8_t c)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL
{ {
((uint8_t *)blob->bv_ga.ga_data)[idx] = c; ((uint8_t *)blob->bv_ga.ga_data)[idx] = c;
} }
@@ -417,9 +384,6 @@ extern bool tv_in_free_unref_items;
} \ } \
}) })
static inline bool tv_get_float_chk(const typval_T *tv, float_T *ret_f)
REAL_FATTR_NONNULL_ALL REAL_FATTR_WARN_UNUSED_RESULT;
/// Get the float value /// Get the float value
/// ///
/// Raises an error if object is not number or floating-point. /// Raises an error if object is not number or floating-point.
@@ -429,6 +393,7 @@ static inline bool tv_get_float_chk(const typval_T *tv, float_T *ret_f)
/// ///
/// @return true in case of success, false if tv is not a number or float. /// @return true in case of success, false if tv is not a number or float.
static inline bool tv_get_float_chk(const typval_T *const tv, float_T *const ret_f) static inline bool tv_get_float_chk(const typval_T *const tv, float_T *const ret_f)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{ {
if (tv->v_type == VAR_FLOAT) { if (tv->v_type == VAR_FLOAT) {
*ret_f = tv->vval.v_float; *ret_f = tv->vval.v_float;
@@ -442,22 +407,17 @@ static inline bool tv_get_float_chk(const typval_T *const tv, float_T *const ret
return false; return false;
} }
static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL REAL_FATTR_NONNULL_RET
REAL_FATTR_NO_SANITIZE_ADDRESS REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Compute the `DictWatcher` address from a QUEUE node. /// Compute the `DictWatcher` address from a QUEUE node.
/// ///
/// This only exists for .asan-blacklist (ASAN doesn't handle QUEUE_DATA pointer /// This only exists for .asan-blacklist (ASAN doesn't handle QUEUE_DATA pointer
/// arithmetic). /// arithmetic).
static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q) static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
FUNC_ATTR_NO_SANITIZE_ADDRESS FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
return QUEUE_DATA(q, DictWatcher, node); return QUEUE_DATA(q, DictWatcher, node);
} }
static inline bool tv_is_func(typval_T tv)
REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE REAL_FATTR_CONST;
/// Check whether given typval_T contains a function /// Check whether given typval_T contains a function
/// ///
/// That is, whether it contains VAR_FUNC or VAR_PARTIAL. /// That is, whether it contains VAR_FUNC or VAR_PARTIAL.
@@ -466,6 +426,7 @@ static inline bool tv_is_func(typval_T tv)
/// ///
/// @return True if it is a function or a partial, false otherwise. /// @return True if it is a function or a partial, false otherwise.
static inline bool tv_is_func(const typval_T tv) static inline bool tv_is_func(const typval_T tv)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST
{ {
return tv.v_type == VAR_FUNC || tv.v_type == VAR_PARTIAL; return tv.v_type == VAR_FUNC || tv.v_type == VAR_PARTIAL;
} }

View File

@@ -11,7 +11,10 @@
#include "klib/kvec.h" #include "klib/kvec.h"
#include "nvim/eval/typval_defs.h" #include "nvim/eval/typval_defs.h"
#include "nvim/func_attr.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "eval/typval_encode.h.inline.generated.h"
#endif
/// Type of the stack entry /// Type of the stack entry
typedef enum { typedef enum {
@@ -62,10 +65,6 @@ typedef struct {
/// Stack used to convert Vimscript values to messagepack. /// Stack used to convert Vimscript values to messagepack.
typedef kvec_withinit_t(MPConvStackVal, 8) MPConvStack; typedef kvec_withinit_t(MPConvStackVal, 8) MPConvStack;
static inline size_t tv_strlen(const typval_T *tv)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT
REAL_FATTR_NONNULL_ALL;
/// Length of the string stored in typval_T /// Length of the string stored in typval_T
/// ///
/// @param[in] tv String for which to compute length for. Must be typval_T /// @param[in] tv String for which to compute length for. Must be typval_T
@@ -74,6 +73,8 @@ static inline size_t tv_strlen(const typval_T *tv)
/// @return Length of the string stored in typval_T, including 0 for NULL /// @return Length of the string stored in typval_T, including 0 for NULL
/// string. /// string.
static inline size_t tv_strlen(const typval_T *const tv) static inline size_t tv_strlen(const typval_T *const tv)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
FUNC_ATTR_NONNULL_ALL
{ {
assert(tv->v_type == VAR_STRING); assert(tv->v_type == VAR_STRING);
return (tv->vval.v_string == NULL ? 0 : strlen(tv->vval.v_string)); return (tv->vval.v_string == NULL ? 0 : strlen(tv->vval.v_string));

View File

@@ -2,6 +2,7 @@ local fname = arg[1]
local static_fname = arg[2] local static_fname = arg[2]
local non_static_fname = arg[3] local non_static_fname = arg[3]
local preproc_fname = arg[4] local preproc_fname = arg[4]
local static_basename = arg[5]
local lpeg = vim.lpeg local lpeg = vim.lpeg
@@ -235,6 +236,7 @@ local declendpos = 0
local curdir = nil local curdir = nil
local is_needed_file = false local is_needed_file = false
local init_is_nl = true local init_is_nl = true
local any_static = false
while init ~= nil do while init ~= nil do
if init_is_nl and text:sub(init, init) == '#' then if init_is_nl and text:sub(init, init) == '#' then
local line, dir, file = text:match(filepattern, init) local line, dir, file = text:match(filepattern, init)
@@ -276,6 +278,9 @@ while init ~= nil do
end end
declaration = declaration .. '\n' declaration = declaration .. '\n'
if declaration:sub(1, 6) == 'static' then if declaration:sub(1, 6) == 'static' then
if declaration:find('FUNC_ATTR_') then
any_static = true
end
static = static .. declaration static = static .. declaration
else else
declaration = 'DLLEXPORT ' .. declaration declaration = 'DLLEXPORT ' .. declaration
@@ -303,6 +308,18 @@ F = io.open(static_fname, 'w')
F:write(static) F:write(static)
F:close() F:close()
if non_static_fname == 'SKIP' then
F = io.open(fname, 'r')
if any_static then
local orig_text = F:read('*a')
local pat = '\n#%s?include%s+"' .. static_basename .. '"\n'
if not string.find(orig_text, pat) then
error('fail: missing include for ' .. static_basename .. ' in ' .. fname)
end
end
return -- only want static declarations
end
-- Before generating the non-static headers, check if the current file (if -- Before generating the non-static headers, check if the current file (if
-- exists) is different from the new one. If they are the same, we won't touch -- exists) is different from the new one. If they are the same, we won't touch
-- the current version to avoid triggering an unnecessary rebuilds of modules -- the current version to avoid triggering an unnecessary rebuilds of modules

View File

@@ -21,13 +21,15 @@
#include <stddef.h> #include <stddef.h>
#include "nvim/func_attr.h"
typedef struct queue { typedef struct queue {
struct queue *next; struct queue *next;
struct queue *prev; struct queue *prev;
} QUEUE; } QUEUE;
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "lib/queue_defs.h.inline.generated.h"
#endif
// Public macros. // Public macros.
#define QUEUE_DATA(ptr, type, field) \ #define QUEUE_DATA(ptr, type, field) \
((type *)((char *)(ptr) - offsetof(type, field))) ((type *)((char *)(ptr) - offsetof(type, field)))
@@ -44,29 +46,23 @@ typedef struct queue {
} }
// ffi.cdef is unable to swallow `bool` in place of `int` here. // ffi.cdef is unable to swallow `bool` in place of `int` here.
static inline int QUEUE_EMPTY(const QUEUE *q)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
static inline int QUEUE_EMPTY(const QUEUE *const q) static inline int QUEUE_EMPTY(const QUEUE *const q)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
return q == q->next; return q == q->next;
} }
#define QUEUE_HEAD(q) (q)->next #define QUEUE_HEAD(q) (q)->next
static inline void QUEUE_INIT(QUEUE *q)
REAL_FATTR_ALWAYS_INLINE;
static inline void QUEUE_INIT(QUEUE *const q) static inline void QUEUE_INIT(QUEUE *const q)
FUNC_ATTR_ALWAYS_INLINE
{ {
q->next = q; q->next = q;
q->prev = q; q->prev = q;
} }
static inline void QUEUE_ADD(QUEUE *h, QUEUE *n)
REAL_FATTR_ALWAYS_INLINE;
static inline void QUEUE_ADD(QUEUE *const h, QUEUE *const n) static inline void QUEUE_ADD(QUEUE *const h, QUEUE *const n)
FUNC_ATTR_ALWAYS_INLINE
{ {
h->prev->next = n->next; h->prev->next = n->next;
n->next->prev = h->prev; n->next->prev = h->prev;
@@ -74,10 +70,8 @@ static inline void QUEUE_ADD(QUEUE *const h, QUEUE *const n)
h->prev->next = h; h->prev->next = h;
} }
static inline void QUEUE_INSERT_HEAD(QUEUE *h, QUEUE *q)
REAL_FATTR_ALWAYS_INLINE;
static inline void QUEUE_INSERT_HEAD(QUEUE *const h, QUEUE *const q) static inline void QUEUE_INSERT_HEAD(QUEUE *const h, QUEUE *const q)
FUNC_ATTR_ALWAYS_INLINE
{ {
q->next = h->next; q->next = h->next;
q->prev = h; q->prev = h;
@@ -85,10 +79,8 @@ static inline void QUEUE_INSERT_HEAD(QUEUE *const h, QUEUE *const q)
h->next = q; h->next = q;
} }
static inline void QUEUE_INSERT_TAIL(QUEUE *h, QUEUE *q)
REAL_FATTR_ALWAYS_INLINE;
static inline void QUEUE_INSERT_TAIL(QUEUE *const h, QUEUE *const q) static inline void QUEUE_INSERT_TAIL(QUEUE *const h, QUEUE *const q)
FUNC_ATTR_ALWAYS_INLINE
{ {
q->next = h; q->next = h;
q->prev = h->prev; q->prev = h->prev;
@@ -96,10 +88,8 @@ static inline void QUEUE_INSERT_TAIL(QUEUE *const h, QUEUE *const q)
h->prev = q; h->prev = q;
} }
static inline void QUEUE_REMOVE(QUEUE *q)
REAL_FATTR_ALWAYS_INLINE;
static inline void QUEUE_REMOVE(QUEUE *const q) static inline void QUEUE_REMOVE(QUEUE *const q)
FUNC_ATTR_ALWAYS_INLINE
{ {
q->prev->next = q->next; q->prev->next = q->next;
q->next->prev = q->prev; q->next->prev = q->prev;

View File

@@ -5,19 +5,18 @@
#include "nvim/ascii_defs.h" #include "nvim/ascii_defs.h"
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/extmark_defs.h" // IWYU pragma: keep #include "nvim/extmark_defs.h" // IWYU pragma: keep
#include "nvim/func_attr.h"
#include "nvim/macros_defs.h" #include "nvim/macros_defs.h"
#include "nvim/mark_defs.h" // IWYU pragma: keep #include "nvim/mark_defs.h" // IWYU pragma: keep
#include "nvim/os/time.h" #include "nvim/os/time.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "mark.h.generated.h" # include "mark.h.generated.h"
# include "mark.h.inline.generated.h"
#endif #endif
static inline int mark_global_index(char name)
REAL_FATTR_CONST;
/// Convert mark name to the offset /// Convert mark name to the offset
static inline int mark_global_index(const char name) static inline int mark_global_index(const char name)
FUNC_ATTR_CONST
{ {
return (ASCII_ISUPPER(name) return (ASCII_ISUPPER(name)
? (name - 'A') ? (name - 'A')
@@ -26,10 +25,9 @@ static inline int mark_global_index(const char name)
: -1)); : -1));
} }
static inline int mark_local_index(char name)
REAL_FATTR_CONST;
/// Convert local mark name to the offset /// Convert local mark name to the offset
static inline int mark_local_index(const char name) static inline int mark_local_index(const char name)
FUNC_ATTR_CONST
{ {
return (ASCII_ISLOWER(name) return (ASCII_ISLOWER(name)
? (name - 'a') ? (name - 'a')

View File

@@ -3,6 +3,10 @@
#include "nvim/eval/typval_defs.h" #include "nvim/eval/typval_defs.h"
#include "nvim/os/time_defs.h" #include "nvim/os/time_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "mark_defs.h.inline.generated.h"
#endif
// marks: positions in a file // marks: positions in a file
// (a normal mark is a lnum/col pair, the same as a file position) // (a normal mark is a lnum/col pair, the same as a file position)
@@ -84,11 +88,9 @@ typedef struct {
#define INIT_XFMARK { INIT_FMARK, NULL } #define INIT_XFMARK { INIT_FMARK, NULL }
/// Set fmark using given value
static inline bool lt(pos_T a, pos_T b)
REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE;
/// Return true if position a is before (less than) position b. /// Return true if position a is before (less than) position b.
static inline bool lt(pos_T a, pos_T b) static inline bool lt(pos_T a, pos_T b)
FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
{ {
if (a.lnum != b.lnum) { if (a.lnum != b.lnum) {
return a.lnum < b.lnum; return a.lnum < b.lnum;
@@ -100,25 +102,19 @@ static inline bool lt(pos_T a, pos_T b)
} }
static inline bool equalpos(pos_T a, pos_T b) static inline bool equalpos(pos_T a, pos_T b)
REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
/// Return true if position a and b are equal.
static inline bool equalpos(pos_T a, pos_T b)
{ {
return (a.lnum == b.lnum) && (a.col == b.col) && (a.coladd == b.coladd); return (a.lnum == b.lnum) && (a.col == b.col) && (a.coladd == b.coladd);
} }
static inline bool ltoreq(pos_T a, pos_T b) static inline bool ltoreq(pos_T a, pos_T b)
REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE
/// Return true if position a is less than or equal to b.
static inline bool ltoreq(pos_T a, pos_T b)
{ {
return lt(a, b) || equalpos(a, b); return lt(a, b) || equalpos(a, b);
} }
static inline void clearpos(pos_T *a) static inline void clearpos(pos_T *a)
REAL_FATTR_ALWAYS_INLINE; FUNC_ATTR_ALWAYS_INLINE
/// Clear the pos_T structure pointed to by a.
static inline void clearpos(pos_T *a)
{ {
a->lnum = 0; a->lnum = 0;
a->col = 0; a->col = 0;

View File

@@ -7,13 +7,13 @@
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_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/macros_defs.h"
#include "nvim/mbyte_defs.h" // IWYU pragma: keep #include "nvim/mbyte_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "mbyte.h.generated.h" # include "mbyte.h.generated.h"
# include "mbyte.h.inline.generated.h"
#endif #endif
enum { enum {
@@ -53,18 +53,14 @@ extern const uint8_t utf8len_tab[256];
(p -= utf_head_off((char *)(s), (char *)(p) - 1) + 1) (p -= utf_head_off((char *)(s), (char *)(p) - 1) + 1)
/// Check whether a given UTF-8 byte is a trailing byte (10xx.xxxx). /// 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) 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 // uint8_t is for clang to use smaller cmp
return (uint8_t)(byte & 0xC0U) == 0x80U; 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. /// Convert a UTF-8 byte sequence to a Unicode code point.
/// Handles ascii, multibyte sequiences and illegal sequences. /// 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, /// @return information abouth the character. When the sequence is illegal,
/// "value" is negative, "len" is 1. /// "value" is negative, "len" is 1.
static inline CharInfo utf_ptr2CharInfo(char const *const p_in) 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 *const p = (uint8_t const *)p_in;
uint8_t const first = *p; 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. /// Return information about the next character.
/// Composing and combining characters are considered a part of the current character. /// Composing and combining characters are considered a part of the current character.
/// ///
/// @param[in] cur Information about the current character in the string. /// @param[in] cur Information about the current character in the string.
static inline StrCharInfo utfc_next(StrCharInfo cur) 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; int32_t prev_code = cur.chr.value;
uint8_t *next = (uint8_t *)(cur.ptr + cur.chr.len); 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) static inline StrCharInfo utf_ptr2StrCharInfo(char *ptr)
REAL_FATTR_NONNULL_ALL REAL_FATTR_ALWAYS_INLINE REAL_FATTR_PURE; FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE
static inline StrCharInfo utf_ptr2StrCharInfo(char *ptr)
{ {
return (StrCharInfo){ .ptr = ptr, .chr = utf_ptr2CharInfo(ptr) }; return (StrCharInfo){ .ptr = ptr, .chr = utf_ptr2CharInfo(ptr) };
} }

View File

@@ -7,7 +7,6 @@
#include "nvim/eval/typval_defs.h" #include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/extmark_defs.h" // IWYU pragma: keep #include "nvim/extmark_defs.h" // IWYU pragma: keep
#include "nvim/func_attr.h"
#include "nvim/macros_defs.h" #include "nvim/macros_defs.h"
#include "nvim/normal_defs.h" #include "nvim/normal_defs.h"
#include "nvim/option_defs.h" // IWYU pragma: keep #include "nvim/option_defs.h" // IWYU pragma: keep
@@ -121,8 +120,10 @@ typedef enum {
YREG_PUT, YREG_PUT,
} yreg_mode_t; } yreg_mode_t;
static inline int op_reg_index(int regname) #ifdef INCLUDE_GENERATED_DECLARATIONS
REAL_FATTR_CONST; # include "ops.h.generated.h"
# include "ops.h.inline.generated.h"
#endif
/// Convert register name into register index /// Convert register name into register index
/// ///
@@ -130,6 +131,7 @@ static inline int op_reg_index(int regname)
/// ///
/// @return Index in y_regs array or -1 if register name was not recognized. /// @return Index in y_regs array or -1 if register name was not recognized.
static inline int op_reg_index(const int regname) static inline int op_reg_index(const int regname)
FUNC_ATTR_CONST
{ {
if (ascii_isdigit(regname)) { if (ascii_isdigit(regname)) {
return regname - '0'; return regname - '0';
@@ -148,19 +150,13 @@ static inline int op_reg_index(const int regname)
} }
} }
static inline bool is_literal_register(int regname)
REAL_FATTR_CONST;
/// @see get_yank_register /// @see get_yank_register
/// @return true when register should be inserted literally /// @return true when register should be inserted literally
/// (selection or clipboard) /// (selection or clipboard)
static inline bool is_literal_register(const int regname) static inline bool is_literal_register(const int regname)
FUNC_ATTR_CONST
{ {
return regname == '*' || regname == '+'; return regname == '*' || regname == '+';
} }
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ops.h.generated.h"
#endif
EXTERN LuaRef repeat_luaref INIT( = LUA_NOREF); ///< LuaRef for "." EXTERN LuaRef repeat_luaref INIT( = LUA_NOREF); ///< LuaRef for "."

View File

@@ -3,8 +3,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "nvim/func_attr.h"
/// Structure used to read from/write to file /// Structure used to read from/write to file
typedef struct { typedef struct {
int fd; ///< File descriptor. Can be -1 if no backing file (file_open_buffer) int fd; ///< File descriptor. Can be -1 if no backing file (file_open_buffer)
@@ -17,8 +15,9 @@ typedef struct {
uint64_t bytes_read; ///< total bytes read so far uint64_t bytes_read; ///< total bytes read so far
} FileDescriptor; } FileDescriptor;
static inline bool file_eof(const FileDescriptor *fp) #ifdef INCLUDE_GENERATED_DECLARATIONS
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL; # include "os/fileio_defs.h.inline.generated.h"
#endif
/// Check whether end of file was encountered /// Check whether end of file was encountered
/// ///
@@ -27,19 +26,18 @@ static inline bool file_eof(const FileDescriptor *fp)
/// @return true if it was, false if it was not or read operation was never /// @return true if it was, false if it was not or read operation was never
/// performed. /// performed.
static inline bool file_eof(const FileDescriptor *const fp) static inline bool file_eof(const FileDescriptor *const fp)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{ {
return fp->eof && fp->read_pos == fp->write_pos; return fp->eof && fp->read_pos == fp->write_pos;
} }
static inline int file_fd(const FileDescriptor *fp)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL;
/// Return the file descriptor associated with the FileDescriptor structure /// Return the file descriptor associated with the FileDescriptor structure
/// ///
/// @param[in] fp File to check. /// @param[in] fp File to check.
/// ///
/// @return File descriptor. /// @return File descriptor.
static inline int file_fd(const FileDescriptor *const fp) static inline int file_fd(const FileDescriptor *const fp)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{ {
return fp->fd; return fp->fd;
} }

View File

@@ -3,7 +3,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "nvim/func_attr.h"
#include "nvim/marktree_defs.h" #include "nvim/marktree_defs.h"
#include "nvim/pos_defs.h" #include "nvim/pos_defs.h"
#include "nvim/types_defs.h" #include "nvim/types_defs.h"
@@ -39,12 +38,9 @@ typedef struct {
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "plines.h.generated.h" # include "plines.h.generated.h"
# include "plines.h.inline.generated.h"
#endif #endif
static inline CharSize win_charsize(CSType cstype, int vcol, char *ptr, int32_t chr,
CharsizeArg *csarg)
REAL_FATTR_NONNULL_ALL REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE;
/// Get the number of cells taken up on the screen by the given character at vcol. /// Get the number of cells taken up on the screen by the given character at vcol.
/// "csarg->cur_text_width_left" and "csarg->cur_text_width_right" are set /// "csarg->cur_text_width_left" and "csarg->cur_text_width_right" are set
/// to the extra size for inline virtual text. /// to the extra size for inline virtual text.
@@ -55,6 +51,7 @@ static inline CharSize win_charsize(CSType cstype, int vcol, char *ptr, int32_t
/// of 'showbreak'/'breakindent' before where cursor should be placed. /// of 'showbreak'/'breakindent' before where cursor should be placed.
static inline CharSize win_charsize(CSType cstype, int vcol, char *ptr, int32_t chr, static inline CharSize win_charsize(CSType cstype, int vcol, char *ptr, int32_t chr,
CharsizeArg *csarg) CharsizeArg *csarg)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE
{ {
if (cstype == kCharsizeFast) { if (cstype == kCharsizeFast) {
return charsize_fast(csarg, vcol, chr); return charsize_fast(csarg, vcol, chr);
@@ -63,9 +60,6 @@ static inline CharSize win_charsize(CSType cstype, int vcol, char *ptr, int32_t
} }
} }
static inline int linetabsize_str(char *s)
REAL_FATTR_NONNULL_ALL REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE;
/// Return the number of cells the string "s" will take on the screen, /// Return the number of cells the string "s" will take on the screen,
/// taking into account the size of a tab. /// taking into account the size of a tab.
/// ///
@@ -73,13 +67,11 @@ static inline int linetabsize_str(char *s)
/// ///
/// @return Number of cells the string will take on the screen. /// @return Number of cells the string will take on the screen.
static inline int linetabsize_str(char *s) static inline int linetabsize_str(char *s)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE
{ {
return linetabsize_col(0, s); return linetabsize_col(0, s);
} }
static inline int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len)
REAL_FATTR_NONNULL_ALL REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE;
/// Like linetabsize_str(), but for a given window instead of the current one. /// Like linetabsize_str(), but for a given window instead of the current one.
/// ///
/// @param wp /// @param wp
@@ -88,6 +80,7 @@ static inline int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T
/// ///
/// @return Number of cells the string will take on the screen. /// @return Number of cells the string will take on the screen.
static inline int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len) static inline int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE
{ {
CharsizeArg csarg; CharsizeArg csarg;
CSType const cstype = init_charsize_arg(&csarg, wp, lnum, line); CSType const cstype = init_charsize_arg(&csarg, wp, lnum, line);

View File

@@ -7,29 +7,9 @@
#include "klib/kvec.h" #include "klib/kvec.h"
#include "nvim/api/private/defs.h" #include "nvim/api/private/defs.h"
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#include "nvim/func_attr.h"
#include "nvim/os/os_defs.h" #include "nvim/os/os_defs.h"
#include "nvim/types_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep
static inline char *strappend(char *dst, const char *src)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL
REAL_FATTR_NONNULL_RET REAL_FATTR_WARN_UNUSED_RESULT;
/// Append string to string and return pointer to the next byte
///
/// Unlike strcat, this one does *not* add NUL byte and returns pointer to the
/// past of the added string.
///
/// @param[out] dst String to append to.
/// @param[in] src String to append.
///
/// @return pointer to the byte just past the appended byte.
static inline char *strappend(char *const dst, const char *const src)
{
const size_t src_len = strlen(src);
return (char *)memmove(dst, src, src_len) + src_len;
}
typedef kvec_t(char) StringBuilder; typedef kvec_t(char) StringBuilder;
// Return the length of a string literal // Return the length of a string literal
@@ -46,8 +26,26 @@ typedef struct {
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "strings.h.generated.h" # include "strings.h.generated.h"
# include "strings.h.inline.generated.h"
#endif #endif
/// Append string to string and return pointer to the next byte
///
/// Unlike strcat, this one does *not* add NUL byte and returns pointer to the
/// past of the added string.
///
/// @param[out] dst String to append to.
/// @param[in] src String to append.
///
/// @return pointer to the byte just past the appended byte.
static inline char *strappend(char *const dst, const char *const src)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL
FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT
{
const size_t src_len = strlen(src);
return (char *)memmove(dst, src, src_len) + src_len;
}
#ifdef HAVE_STRCASECMP #ifdef HAVE_STRCASECMP
# define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s)) # define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s))
#else #else

View File

@@ -5,13 +5,13 @@
#include <stddef.h> #include <stddef.h>
#include "klib/kvec.h" #include "klib/kvec.h"
#include "nvim/func_attr.h"
#include "nvim/mbyte_defs.h" #include "nvim/mbyte_defs.h"
#include "nvim/viml/parser/parser_defs.h" // IWYU pragma: keep #include "nvim/viml/parser/parser_defs.h" // IWYU pragma: keep
static inline void viml_parser_init(ParserState *ret_pstate, ParserLineGetter get_line, #ifdef INCLUDE_GENERATED_DECLARATIONS
void *cookie, ParserHighlight *colors) # include "viml/parser/parser.h.generated.h"
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ARG(1, 2); # include "viml/parser/parser.h.inline.generated.h"
#endif
/// Initialize a new parser state instance /// Initialize a new parser state instance
/// ///
@@ -22,6 +22,7 @@ static inline void viml_parser_init(ParserState *ret_pstate, ParserLineGetter ge
/// needed. /// needed.
static inline void viml_parser_init(ParserState *const ret_pstate, const ParserLineGetter get_line, static inline void viml_parser_init(ParserState *const ret_pstate, const ParserLineGetter get_line,
void *const cookie, ParserHighlight *const colors) void *const cookie, ParserHighlight *const colors)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ARG(1, 2)
{ {
*ret_pstate = (ParserState) { *ret_pstate = (ParserState) {
.reader = { .reader = {
@@ -37,9 +38,6 @@ static inline void viml_parser_init(ParserState *const ret_pstate, const ParserL
kvi_init(ret_pstate->stack); 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 /// Advance position by a given number of bytes
/// ///
/// At maximum advances to the next line. /// 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 pstate Parser state to advance.
/// @param[in] len Number of bytes to advance. /// @param[in] len Number of bytes to advance.
static inline void viml_parser_advance(ParserState *const pstate, const size_t len) 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); assert(pstate->pos.line == kv_size(pstate->reader.lines) - 1);
const ParserLine pline = kv_last(pstate->reader.lines); 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 /// Record highlighting of some region of text
/// ///
/// @param pstate Parser state to work with. /// @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. /// @param[in] group Highlight group.
static inline void viml_parser_highlight(ParserState *const pstate, const ParserPosition start, static inline void viml_parser_highlight(ParserState *const pstate, const ParserPosition start,
const size_t len, const char *const group) const size_t len, const char *const group)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL
{ {
if (pstate->colors == NULL || len == 0) { if (pstate->colors == NULL || len == 0) {
return; return;
@@ -83,7 +79,3 @@ static inline void viml_parser_highlight(ParserState *const pstate, const Parser
.group = group, .group = group,
})); }));
} }
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "viml/parser/parser.h.generated.h"
#endif

View File

@@ -264,6 +264,7 @@ local function formatc(str)
-- and ';' indicates we're at the end of a statement, so we put end -- and ';' indicates we're at the end of a statement, so we put end
-- it with a newline. -- it with a newline.
token[1] = ';\n' token[1] = ';\n'
end_at_brace = false
end end
elseif typ == 'whitespace' then elseif typ == 'whitespace' then
-- replace all whitespace by one space -- replace all whitespace by one space