aboutsummaryrefslogtreecommitdiff
path: root/src/nvim
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2021-10-09 14:20:16 +0200
committerGitHub <noreply@github.com>2021-10-09 05:20:16 -0700
commit0fc8597f011e0927e529abd11bf0ddd8d0d1eaab (patch)
tree2339570a059d7ebb41f26db32b032440d1505ee7 /src/nvim
parenta36c6e5df959867ff4041405f4098b7833281517 (diff)
downloadrneovim-0fc8597f011e0927e529abd11bf0ddd8d0d1eaab.tar.gz
rneovim-0fc8597f011e0927e529abd11bf0ddd8d0d1eaab.tar.bz2
rneovim-0fc8597f011e0927e529abd11bf0ddd8d0d1eaab.zip
refactor: format header files with uncrustify #15877
* refactor: format header files with uncrustify * fixup(justin): skip formatting of terminfo_defs.h * fixup: force winsock2 to be included first * fixup: simplify disable/enable directive to "uncrustify:off/on"
Diffstat (limited to 'src/nvim')
-rw-r--r--src/nvim/api/private/defs.h6
-rw-r--r--src/nvim/api/private/helpers.h10
-rw-r--r--src/nvim/eval/decode.h3
-rw-r--r--src/nvim/eval/encode.h6
-rw-r--r--src/nvim/eval/typval.h177
-rw-r--r--src/nvim/eval/typval_encode.c.h789
-rw-r--r--src/nvim/eval/typval_encode.h38
-rw-r--r--src/nvim/eval/userfunc.h2
-rw-r--r--src/nvim/event/defs.h2
-rw-r--r--src/nvim/event/loop.h5
-rw-r--r--src/nvim/event/process.h2
-rw-r--r--src/nvim/event/rstream.h1
-rw-r--r--src/nvim/event/stream.h3
-rw-r--r--src/nvim/event/wstream.h3
-rw-r--r--src/nvim/lua/converter.h2
-rw-r--r--src/nvim/lua/executor.h16
-rw-r--r--src/nvim/lua/treesitter.h2
-rw-r--r--src/nvim/lua/xdiff.h2
-rw-r--r--src/nvim/msgpack_rpc/channel.h4
-rw-r--r--src/nvim/msgpack_rpc/channel_defs.h4
-rw-r--r--src/nvim/msgpack_rpc/helpers.h7
-rw-r--r--src/nvim/os/input.h2
-rw-r--r--src/nvim/os/os.h4
-rw-r--r--src/nvim/os/os_defs.h2
-rw-r--r--src/nvim/os/process.h1
-rw-r--r--src/nvim/os/time.h2
-rw-r--r--src/nvim/os/unix_defs.h2
-rw-r--r--src/nvim/os/win_defs.h7
-rw-r--r--src/nvim/runtime.c4
-rw-r--r--src/nvim/tui/input.h2
-rw-r--r--src/nvim/tui/terminfo_defs.h5
-rw-r--r--src/nvim/viml/parser/expressions.h16
-rw-r--r--src/nvim/viml/parser/parser.h31
33 files changed, 564 insertions, 598 deletions
diff --git a/src/nvim/api/private/defs.h b/src/nvim/api/private/defs.h
index 8346e01558..663d1e16b5 100644
--- a/src/nvim/api/private/defs.h
+++ b/src/nvim/api/private/defs.h
@@ -1,15 +1,15 @@
#ifndef NVIM_API_PRIVATE_DEFS_H
#define NVIM_API_PRIVATE_DEFS_H
-#include <stdint.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
#include "nvim/func_attr.h"
#include "nvim/types.h"
-#define ARRAY_DICT_INIT {.size = 0, .capacity = 0, .items = NULL}
-#define STRING_INIT {.data = NULL, .size = 0}
+#define ARRAY_DICT_INIT { .size = 0, .capacity = 0, .items = NULL }
+#define STRING_INIT { .data = NULL, .size = 0 }
#define OBJECT_INIT { .type = kObjectTypeNil }
#define ERROR_INIT { .type = kErrorTypeNone, .msg = NULL }
#define REMOTE_TYPE(type) typedef handle_T type
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 2cdd80bffe..dc9452e832 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -4,12 +4,12 @@
#include <stdbool.h>
#include "nvim/api/private/defs.h"
-#include "nvim/vim.h"
-#include "nvim/getchar.h"
-#include "nvim/memory.h"
#include "nvim/decoration.h"
#include "nvim/ex_eval.h"
+#include "nvim/getchar.h"
#include "nvim/lib/kvec.h"
+#include "nvim/memory.h"
+#include "nvim/vim.h"
#define OBJECT_OBJ(o) o
@@ -76,7 +76,7 @@
name.size = fixsize; \
name.items = name##__items; \
-#define STATIC_CSTR_AS_STRING(s) ((String) {.data = s, .size = sizeof(s) - 1})
+#define STATIC_CSTR_AS_STRING(s) ((String) { .data = s, .size = sizeof(s) - 1 })
/// Create a new String instance, putting data in allocated memory
///
@@ -137,7 +137,7 @@ typedef struct {
msg_list = &private_msg_list; \
private_msg_list = NULL; \
code \
- msg_list = saved_msg_list; /* Restore the exception context. */ \
+ msg_list = saved_msg_list; /* Restore the exception context. */ \
} while (0)
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/eval/decode.h b/src/nvim/eval/decode.h
index 77fc4c78c2..f1be5a1f69 100644
--- a/src/nvim/eval/decode.h
+++ b/src/nvim/eval/decode.h
@@ -1,9 +1,8 @@
#ifndef NVIM_EVAL_DECODE_H
#define NVIM_EVAL_DECODE_H
-#include <stddef.h>
-
#include <msgpack.h>
+#include <stddef.h>
#include "nvim/eval/typval.h"
#include "nvim/globals.h"
diff --git a/src/nvim/eval/encode.h b/src/nvim/eval/encode.h
index 596bb49ae0..8755ff48ac 100644
--- a/src/nvim/eval/encode.h
+++ b/src/nvim/eval/encode.h
@@ -1,9 +1,8 @@
#ifndef NVIM_EVAL_ENCODE_H
#define NVIM_EVAL_ENCODE_H
-#include <stddef.h>
-
#include <msgpack.h>
+#include <stddef.h>
#include "nvim/eval.h"
#include "nvim/garray.h"
@@ -49,8 +48,7 @@ static inline ListReaderState encode_init_lrstate(const list_T *const list)
.offset = 0,
.li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL
? 0
- : STRLEN(TV_LIST_ITEM_TV(
- tv_list_first(list))->vval.v_string)),
+ : STRLEN(TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string)),
};
}
diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h
index 5aecaccee9..a28feffd0b 100644
--- a/src/nvim/eval/typval.h
+++ b/src/nvim/eval/typval.h
@@ -1,23 +1,23 @@
#ifndef NVIM_EVAL_TYPVAL_H
#define NVIM_EVAL_TYPVAL_H
+#include <assert.h>
#include <inttypes.h>
+#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-#include <stdbool.h>
-#include <assert.h>
-#include "nvim/types.h"
-#include "nvim/hashtab.h"
-#include "nvim/garray.h"
-#include "nvim/mbyte.h"
#include "nvim/func_attr.h"
-#include "nvim/lib/queue.h"
-#include "nvim/profile.h" // for proftime_T
-#include "nvim/pos.h" // for linenr_T
+#include "nvim/garray.h"
#include "nvim/gettext.h"
-#include "nvim/message.h"
+#include "nvim/hashtab.h"
+#include "nvim/lib/queue.h"
#include "nvim/macros.h"
+#include "nvim/mbyte.h"
+#include "nvim/message.h"
+#include "nvim/pos.h" // for linenr_T
+#include "nvim/profile.h" // for proftime_T
+#include "nvim/types.h"
#ifdef LOG_LIST_ACTIONS
# include "nvim/memory.h"
#endif
@@ -156,8 +156,8 @@ typedef enum {
typedef struct listitem_S listitem_T;
struct listitem_S {
- listitem_T *li_next; ///< Next item in list.
- listitem_T *li_prev; ///< Previous item in list.
+ listitem_T *li_next; ///< Next item in list.
+ listitem_T *li_prev; ///< Previous item in list.
typval_T li_tv; ///< Item value.
};
@@ -195,25 +195,25 @@ typedef struct {
} staticList10_T;
#define TV_LIST_STATIC10_INIT { \
- .sl_list = { \
- .lv_first = NULL, \
- .lv_last = NULL, \
- .lv_refcount = 0, \
- .lv_len = 0, \
- .lv_watch = NULL, \
- .lv_idx_item = NULL, \
- .lv_lock = VAR_FIXED, \
- .lv_used_next = NULL, \
- .lv_used_prev = NULL, \
- }, \
- }
+ .sl_list = { \
+ .lv_first = NULL, \
+ .lv_last = NULL, \
+ .lv_refcount = 0, \
+ .lv_len = 0, \
+ .lv_watch = NULL, \
+ .lv_idx_item = NULL, \
+ .lv_lock = VAR_FIXED, \
+ .lv_used_next = NULL, \
+ .lv_used_prev = NULL, \
+ }, \
+}
#define TV_DICTITEM_STRUCT(...) \
- struct { \
- typval_T di_tv; /* Structure that holds scope dictionary itself. */ \
- uint8_t di_flags; /* Flags. */ \
- char_u di_key[__VA_ARGS__]; /* Key value. */ \
- }
+ struct { \
+ typval_T di_tv; /* Structure that holds scope dictionary itself. */ \
+ uint8_t di_flags; /* Flags. */ \
+ char_u di_key[__VA_ARGS__]; /* Key value. */ \
+ }
/// Structure to hold a scope dictionary
///
@@ -321,40 +321,40 @@ struct funccall_S {
/// Structure to hold info for a user function.
struct ufunc {
- int uf_varargs; ///< variable nr of arguments
- int uf_flags;
- int uf_calls; ///< nr of active calls
- bool uf_cleared; ///< func_clear() was already called
- garray_T uf_args; ///< arguments
- garray_T uf_def_args; ///< default argument expressions
- garray_T uf_lines; ///< function lines
- int uf_profiling; ///< true when func is being profiled
- int uf_prof_initialized;
+ int uf_varargs; ///< variable nr of arguments
+ int uf_flags;
+ int uf_calls; ///< nr of active calls
+ bool uf_cleared; ///< func_clear() was already called
+ garray_T uf_args; ///< arguments
+ garray_T uf_def_args; ///< default argument expressions
+ garray_T uf_lines; ///< function lines
+ int uf_profiling; ///< true when func is being profiled
+ int uf_prof_initialized;
// Managing cfuncs
- cfunc_T uf_cb; ///< C function extension callback
+ cfunc_T uf_cb; ///< C function extension callback
cfunc_free_T uf_cb_free; ///< C function extension free callback
- void *uf_cb_state; ///< State of C function extension.
+ void *uf_cb_state; ///< State of C function extension.
// Profiling the function as a whole.
- int uf_tm_count; ///< nr of calls
- proftime_T uf_tm_total; ///< time spent in function + children
- proftime_T uf_tm_self; ///< time spent in function itself
- proftime_T uf_tm_children; ///< time spent in children this call
+ int uf_tm_count; ///< nr of calls
+ proftime_T uf_tm_total; ///< time spent in function + children
+ proftime_T uf_tm_self; ///< time spent in function itself
+ proftime_T uf_tm_children; ///< time spent in children this call
// Profiling the function per line.
- int *uf_tml_count; ///< nr of times line was executed
- proftime_T *uf_tml_total; ///< time spent in a line + children
- proftime_T *uf_tml_self; ///< time spent in a line itself
- proftime_T uf_tml_start; ///< start time for current line
- proftime_T uf_tml_children; ///< time spent in children for this line
- proftime_T uf_tml_wait; ///< start wait time for current line
- int uf_tml_idx; ///< index of line being timed; -1 if none
- int uf_tml_execed; ///< line being timed was executed
- sctx_T uf_script_ctx; ///< SCTX where function was defined,
- ///< used for s: variables
- int uf_refcount; ///< reference count, see func_name_refcount()
- funccall_T *uf_scoped; ///< l: local variables for closure
- char_u uf_name[]; ///< Name of function (actual size equals name);
- ///< can start with <SNR>123_
- ///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
+ int *uf_tml_count; ///< nr of times line was executed
+ proftime_T *uf_tml_total; ///< time spent in a line + children
+ proftime_T *uf_tml_self; ///< time spent in a line itself
+ proftime_T uf_tml_start; ///< start time for current line
+ proftime_T uf_tml_children; ///< time spent in children for this line
+ proftime_T uf_tml_wait; ///< start wait time for current line
+ int uf_tml_idx; ///< index of line being timed; -1 if none
+ int uf_tml_execed; ///< line being timed was executed
+ sctx_T uf_script_ctx; ///< SCTX where function was defined,
+ ///< used for s: variables
+ int uf_refcount; ///< reference count, see func_name_refcount()
+ funccall_T *uf_scoped; ///< l: local variables for closure
+ char_u uf_name[]; ///< Name of function (actual size equals name);
+ ///< can start with <SNR>123_
+ ///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
};
struct partial_S {
@@ -452,10 +452,8 @@ static inline void list_log(const list_T *const l,
/// @param[in] li1 List item 1.
/// @param[in] li2 List item 2, often used for integers and not list items.
/// @param[in] action Logged action.
-static inline void list_log(const list_T *const l,
- const listitem_T *const li1,
- const listitem_T *const li2,
- const char *const action)
+static inline void list_log(const list_T *const l, const listitem_T *const li1,
+ const listitem_T *const li2, const char *const action)
{
ListLog *tgt;
if (list_log_first == NULL) {
@@ -484,7 +482,7 @@ static inline void list_log(const list_T *const l,
/// Convert a hashitem pointer to a dictitem pointer
#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 *const l)
REAL_FATTR_ALWAYS_INLINE;
@@ -538,8 +536,7 @@ static inline VarLockStatus tv_list_locked(const list_T *const l)
///
/// @param[out] l List to modify.
/// @param[in] lock New lock status.
-static inline void tv_list_set_lock(list_T *const l,
- const VarLockStatus lock)
+static inline void tv_list_set_lock(list_T *const l, const VarLockStatus lock)
{
if (l == NULL) {
assert(lock == VAR_FIXED);
@@ -554,8 +551,7 @@ static inline void tv_list_set_lock(list_T *const l,
///
/// @param[out] l List to modify.
/// @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;
@@ -793,10 +789,10 @@ static inline void tv_init(typval_T *const tv)
}
#define TV_INITIAL_VALUE \
- ((typval_T) { \
- .v_type = VAR_UNKNOWN, \
- .v_lock = VAR_UNLOCKED, \
- })
+ ((typval_T) { \
+ .v_type = VAR_UNKNOWN, \
+ .v_lock = VAR_UNLOCKED, \
+ })
/// Empty string
///
@@ -815,16 +811,16 @@ extern bool tv_in_free_unref_items;
/// @param li Name of the variable with current listitem_T entry.
/// @param code Cycle body.
#define _TV_LIST_ITER_MOD(modifier, l, li, code) \
- do { \
- modifier list_T *const l_ = (l); \
- list_log(l_, NULL, NULL, "iter" #modifier); \
- if (l_ != NULL) { \
- for (modifier listitem_T *li = l_->lv_first; \
- li != NULL; li = li->li_next) { \
- code \
- } \
+ do { \
+ modifier list_T *const l_ = (l); \
+ list_log(l_, NULL, NULL, "iter" #modifier); \
+ if (l_ != NULL) { \
+ for (modifier listitem_T *li = l_->lv_first; \
+ li != NULL; li = li->li_next) { \
+ code \
} \
- } while (0)
+ } \
+ } while (0)
/// Iterate over a list
///
@@ -835,7 +831,7 @@ extern bool tv_in_free_unref_items;
/// @param li Name of the variable with current listitem_T entry.
/// @param code Cycle body.
#define TV_LIST_ITER(l, li, code) \
- _TV_LIST_ITER_MOD(, l, li, code)
+ _TV_LIST_ITER_MOD(, l, li, code)
/// Iterate over a list
///
@@ -846,7 +842,7 @@ extern bool tv_in_free_unref_items;
/// @param li Name of the variable with current listitem_T entry.
/// @param code Cycle body.
#define TV_LIST_ITER_CONST(l, li, code) \
- _TV_LIST_ITER_MOD(const, l, li, code)
+ _TV_LIST_ITER_MOD(const, l, li, code)
// Below macros are macros to avoid duplicating code for functionally identical
// const and non-const function variants.
@@ -883,14 +879,14 @@ extern bool tv_in_free_unref_items;
/// @param di Name of the variable with current dictitem_T entry.
/// @param code Cycle body.
#define TV_DICT_ITER(d, di, code) \
- HASHTAB_ITER(&(d)->dv_hashtab, di##hi_, { \
+ HASHTAB_ITER(&(d)->dv_hashtab, di##hi_, { \
+ { \
+ dictitem_T *const di = TV_DICT_HI2DI(di##hi_); \
{ \
- dictitem_T *const di = TV_DICT_HI2DI(di##hi_); \
- { \
- code \
- } \
+ code \
} \
- })
+ } \
+ })
static inline bool tv_get_float_chk(const typval_T *const tv,
float_T *const ret_f)
@@ -907,8 +903,7 @@ bool emsgf(const char *const fmt, ...);
/// @param[out] ret_f Location where resulting float is stored.
///
/// @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)
{
if (tv->v_type == VAR_FLOAT) {
*ret_f = tv->vval.v_float;
diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h
index cd1be1eecc..ece51cb046 100644
--- a/src/nvim/eval/typval_encode.c.h
+++ b/src/nvim/eval/typval_encode.c.h
@@ -240,15 +240,15 @@
///
/// This name will only be used by one of the above macros which are defined by
/// the caller. Functions defined here do not use first argument directly.
-#include <stddef.h>
-#include <inttypes.h>
#include <assert.h>
+#include <inttypes.h>
+#include <stddef.h>
-#include "nvim/lib/kvec.h"
-#include "nvim/eval/typval.h"
#include "nvim/eval/encode.h"
-#include "nvim/func_attr.h"
+#include "nvim/eval/typval.h"
#include "nvim/eval/typval_encode.h"
+#include "nvim/func_attr.h"
+#include "nvim/lib/kvec.h"
/// Dummy variable used because some macros need lvalue
///
@@ -257,12 +257,12 @@
const dict_T *const TYPVAL_ENCODE_NODICT_VAR = NULL;
static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
- TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
- void *const val, int *const val_copyID,
- const MPConvStack *const mpstack, const int copyID,
- const MPConvStackValType conv_type,
- const char *const objname)
- REAL_FATTR_NONNULL_ARG(2, 3, 4, 7) REAL_FATTR_WARN_UNUSED_RESULT
+ TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
+ void *const val, int *const val_copyID,
+ const MPConvStack *const mpstack, const int copyID,
+ const MPConvStackValType conv_type,
+ const char *const objname)
+REAL_FATTR_NONNULL_ARG(2, 3, 4, 7) REAL_FATTR_WARN_UNUSED_RESULT
REAL_FATTR_ALWAYS_INLINE;
/// Function for checking whether container references itself
@@ -280,11 +280,9 @@ static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
///
/// @return NOTDONE in case of success, what to return in case of failure.
static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
- TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
- void *const val, int *const val_copyID,
- const MPConvStack *const mpstack, const int copyID,
- const MPConvStackValType conv_type,
- const char *const objname)
+ TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME, void *const val, int *const val_copyID,
+ const MPConvStack *const mpstack, const int copyID, const MPConvStackValType conv_type,
+ const char *const objname)
{
if (*val_copyID == copyID) {
TYPVAL_ENCODE_CONV_RECURSE(val, conv_type);
@@ -295,11 +293,11 @@ static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
}
static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
- TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
- MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
- typval_T *const tv, const int copyID,
- const char *const objname)
- REAL_FATTR_NONNULL_ARG(2, 4, 6) REAL_FATTR_WARN_UNUSED_RESULT;
+ TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
+ MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
+ typval_T *const tv, const int copyID,
+ const char *const objname)
+REAL_FATTR_NONNULL_ARG(2, 4, 6) REAL_FATTR_WARN_UNUSED_RESULT;
/// Convert single value
///
@@ -319,42 +317,35 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
///
/// @return OK in case of success, FAIL in case of failure.
static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
- TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
- MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
- typval_T *const tv, const int copyID,
- const char *const objname)
+ TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME, MPConvStack *const mpstack,
+ MPConvStackVal *const cur_mpsv, typval_T *const tv, const int copyID, const char *const objname)
{
switch (tv->v_type) {
- case VAR_STRING: {
- TYPVAL_ENCODE_CONV_STRING(tv, tv->vval.v_string, tv_strlen(tv));
- break;
- }
- case VAR_NUMBER: {
- TYPVAL_ENCODE_CONV_NUMBER(tv, tv->vval.v_number);
- break;
- }
- case VAR_FLOAT: {
- TYPVAL_ENCODE_CONV_FLOAT(tv, tv->vval.v_float);
- break;
- }
- case VAR_BLOB: {
- TYPVAL_ENCODE_CONV_BLOB(tv, tv->vval.v_blob,
- tv_blob_len(tv->vval.v_blob));
- break;
- }
- case VAR_FUNC: {
- TYPVAL_ENCODE_CONV_FUNC_START(tv, tv->vval.v_string);
- TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, 0);
- TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
- TYPVAL_ENCODE_CONV_FUNC_END(tv);
- break;
- }
- case VAR_PARTIAL: {
- partial_T *const pt = tv->vval.v_partial;
- (void)pt;
- TYPVAL_ENCODE_CONV_FUNC_START( // -V547
- tv, (pt == NULL ? NULL : partial_name(pt)));
- _mp_push(*mpstack, ((MPConvStackVal) { // -V779
+ case VAR_STRING:
+ TYPVAL_ENCODE_CONV_STRING(tv, tv->vval.v_string, tv_strlen(tv));
+ break;
+ case VAR_NUMBER:
+ TYPVAL_ENCODE_CONV_NUMBER(tv, tv->vval.v_number);
+ break;
+ case VAR_FLOAT:
+ TYPVAL_ENCODE_CONV_FLOAT(tv, tv->vval.v_float);
+ break;
+ case VAR_BLOB:
+ TYPVAL_ENCODE_CONV_BLOB(tv, tv->vval.v_blob,
+ tv_blob_len(tv->vval.v_blob));
+ break;
+ case VAR_FUNC:
+ TYPVAL_ENCODE_CONV_FUNC_START(tv, tv->vval.v_string);
+ TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, 0);
+ TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
+ TYPVAL_ENCODE_CONV_FUNC_END(tv);
+ break;
+ case VAR_PARTIAL: {
+ partial_T *const pt = tv->vval.v_partial;
+ (void)pt;
+ TYPVAL_ENCODE_CONV_FUNC_START( // -V547
+ tv, (pt == NULL ? NULL : partial_name(pt)));
+ _mp_push(*mpstack, ((MPConvStackVal) { // -V779
.type = kMPConvPartial,
.tv = tv,
.saved_copyID = copyID - 1,
@@ -365,19 +356,19 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
},
},
}));
+ break;
+ }
+ case VAR_LIST: {
+ if (tv->vval.v_list == NULL || tv_list_len(tv->vval.v_list) == 0) {
+ TYPVAL_ENCODE_CONV_EMPTY_LIST(tv);
break;
}
- case VAR_LIST: {
- if (tv->vval.v_list == NULL || tv_list_len(tv->vval.v_list) == 0) {
- TYPVAL_ENCODE_CONV_EMPTY_LIST(tv);
- break;
- }
- const int saved_copyID = tv_list_copyid(tv->vval.v_list);
- _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_list, lv_copyID, copyID,
- kMPConvList);
- TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(tv->vval.v_list));
- assert(saved_copyID != copyID);
- _mp_push(*mpstack, ((MPConvStackVal) {
+ const int saved_copyID = tv_list_copyid(tv->vval.v_list);
+ _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_list, lv_copyID, copyID,
+ kMPConvList);
+ TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(tv->vval.v_list));
+ assert(saved_copyID != copyID);
+ _mp_push(*mpstack, ((MPConvStackVal) {
.type = kMPConvList,
.tv = tv,
.saved_copyID = saved_copyID,
@@ -388,159 +379,151 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
},
},
}));
- TYPVAL_ENCODE_CONV_REAL_LIST_AFTER_START(tv, _mp_last(*mpstack));
+ TYPVAL_ENCODE_CONV_REAL_LIST_AFTER_START(tv, _mp_last(*mpstack));
+ break;
+ }
+ case VAR_BOOL:
+ switch (tv->vval.v_bool) {
+ case kBoolVarTrue:
+ case kBoolVarFalse:
+ TYPVAL_ENCODE_CONV_BOOL(tv, tv->vval.v_bool == kBoolVarTrue);
break;
}
- case VAR_BOOL: {
- switch (tv->vval.v_bool) {
- case kBoolVarTrue:
- case kBoolVarFalse: {
- TYPVAL_ENCODE_CONV_BOOL(tv, tv->vval.v_bool == kBoolVarTrue);
- break;
- }
- }
+ break;
+ case VAR_SPECIAL:
+ switch (tv->vval.v_special) {
+ case kSpecialVarNull:
+ TYPVAL_ENCODE_CONV_NIL(tv); // -V1037
break;
}
- case VAR_SPECIAL: {
- switch (tv->vval.v_special) {
- case kSpecialVarNull: {
- TYPVAL_ENCODE_CONV_NIL(tv); // -V1037
+ break;
+ case VAR_DICT: {
+ if (tv->vval.v_dict == NULL
+ || tv->vval.v_dict->dv_hashtab.ht_used == 0) {
+ TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, tv->vval.v_dict);
+ break;
+ }
+ const dictitem_T *type_di;
+ const dictitem_T *val_di;
+ if (TYPVAL_ENCODE_ALLOW_SPECIALS
+ && tv->vval.v_dict->dv_hashtab.ht_used == 2
+ && (type_di = tv_dict_find((dict_T *)tv->vval.v_dict,
+ S_LEN("_TYPE"))) != NULL
+ && type_di->di_tv.v_type == VAR_LIST
+ && (val_di = tv_dict_find((dict_T *)tv->vval.v_dict,
+ S_LEN("_VAL"))) != NULL) {
+ size_t i;
+ for (i = 0; i < ARRAY_SIZE(eval_msgpack_type_lists); i++) {
+ if (type_di->di_tv.vval.v_list == eval_msgpack_type_lists[i]) {
break;
}
}
- break;
- }
- case VAR_DICT: {
- if (tv->vval.v_dict == NULL
- || tv->vval.v_dict->dv_hashtab.ht_used == 0) {
- TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, tv->vval.v_dict);
- break;
+ if (i == ARRAY_SIZE(eval_msgpack_type_lists)) {
+ goto _convert_one_value_regular_dict;
}
- const dictitem_T *type_di;
- const dictitem_T *val_di;
- if (TYPVAL_ENCODE_ALLOW_SPECIALS
- && tv->vval.v_dict->dv_hashtab.ht_used == 2
- && (type_di = tv_dict_find((dict_T *)tv->vval.v_dict,
- S_LEN("_TYPE"))) != NULL
- && type_di->di_tv.v_type == VAR_LIST
- && (val_di = tv_dict_find((dict_T *)tv->vval.v_dict,
- S_LEN("_VAL"))) != NULL) {
- size_t i;
- for (i = 0; i < ARRAY_SIZE(eval_msgpack_type_lists); i++) {
- if (type_di->di_tv.vval.v_list == eval_msgpack_type_lists[i]) {
- break;
- }
+ switch ((MessagePackType)i) {
+ case kMPNil:
+ TYPVAL_ENCODE_CONV_NIL(tv);
+ break;
+ case kMPBoolean:
+ if (val_di->di_tv.v_type != VAR_NUMBER) {
+ goto _convert_one_value_regular_dict;
}
- if (i == ARRAY_SIZE(eval_msgpack_type_lists)) {
+ TYPVAL_ENCODE_CONV_BOOL(tv, val_di->di_tv.vval.v_number);
+ break;
+ case kMPInteger: {
+ const list_T *val_list;
+ varnumber_T sign;
+ varnumber_T highest_bits;
+ varnumber_T high_bits;
+ varnumber_T low_bits;
+ // List of 4 integers; first is signed (should be 1 or -1, but
+ // this is not checked), second is unsigned and have at most
+ // one (sign is -1) or two (sign is 1) non-zero bits (number of
+ // bits is not checked), other unsigned and have at most 31
+ // non-zero bits (number of bits is not checked).
+ if (val_di->di_tv.v_type != VAR_LIST
+ || tv_list_len(val_list = val_di->di_tv.vval.v_list) != 4) {
goto _convert_one_value_regular_dict;
}
- switch ((MessagePackType)i) {
- case kMPNil: {
- TYPVAL_ENCODE_CONV_NIL(tv);
- break;
- }
- case kMPBoolean: {
- if (val_di->di_tv.v_type != VAR_NUMBER) {
- goto _convert_one_value_regular_dict;
- }
- TYPVAL_ENCODE_CONV_BOOL(tv, val_di->di_tv.vval.v_number);
- break;
- }
- case kMPInteger: {
- const list_T *val_list;
- varnumber_T sign;
- varnumber_T highest_bits;
- varnumber_T high_bits;
- varnumber_T low_bits;
- // List of 4 integers; first is signed (should be 1 or -1, but
- // this is not checked), second is unsigned and have at most
- // one (sign is -1) or two (sign is 1) non-zero bits (number of
- // bits is not checked), other unsigned and have at most 31
- // non-zero bits (number of bits is not checked).
- if (val_di->di_tv.v_type != VAR_LIST
- || tv_list_len(val_list = val_di->di_tv.vval.v_list) != 4) {
- goto _convert_one_value_regular_dict;
- }
- const listitem_T *const sign_li = tv_list_first(val_list);
- if (TV_LIST_ITEM_TV(sign_li)->v_type != VAR_NUMBER
- || (sign = TV_LIST_ITEM_TV(sign_li)->vval.v_number) == 0) {