mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
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"
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
#ifndef NVIM_API_PRIVATE_DEFS_H
|
#ifndef NVIM_API_PRIVATE_DEFS_H
|
||||||
#define NVIM_API_PRIVATE_DEFS_H
|
#define NVIM_API_PRIVATE_DEFS_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "nvim/func_attr.h"
|
#include "nvim/func_attr.h"
|
||||||
#include "nvim/types.h"
|
#include "nvim/types.h"
|
||||||
|
|
||||||
#define ARRAY_DICT_INIT {.size = 0, .capacity = 0, .items = NULL}
|
#define ARRAY_DICT_INIT { .size = 0, .capacity = 0, .items = NULL }
|
||||||
#define STRING_INIT {.data = NULL, .size = 0}
|
#define STRING_INIT { .data = NULL, .size = 0 }
|
||||||
#define OBJECT_INIT { .type = kObjectTypeNil }
|
#define OBJECT_INIT { .type = kObjectTypeNil }
|
||||||
#define ERROR_INIT { .type = kErrorTypeNone, .msg = NULL }
|
#define ERROR_INIT { .type = kErrorTypeNone, .msg = NULL }
|
||||||
#define REMOTE_TYPE(type) typedef handle_T type
|
#define REMOTE_TYPE(type) typedef handle_T type
|
||||||
|
@@ -4,12 +4,12 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "nvim/api/private/defs.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/decoration.h"
|
||||||
#include "nvim/ex_eval.h"
|
#include "nvim/ex_eval.h"
|
||||||
|
#include "nvim/getchar.h"
|
||||||
#include "nvim/lib/kvec.h"
|
#include "nvim/lib/kvec.h"
|
||||||
|
#include "nvim/memory.h"
|
||||||
|
#include "nvim/vim.h"
|
||||||
|
|
||||||
#define OBJECT_OBJ(o) o
|
#define OBJECT_OBJ(o) o
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
name.size = fixsize; \
|
name.size = fixsize; \
|
||||||
name.items = name##__items; \
|
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
|
/// Create a new String instance, putting data in allocated memory
|
||||||
///
|
///
|
||||||
@@ -137,7 +137,7 @@ typedef struct {
|
|||||||
msg_list = &private_msg_list; \
|
msg_list = &private_msg_list; \
|
||||||
private_msg_list = NULL; \
|
private_msg_list = NULL; \
|
||||||
code \
|
code \
|
||||||
msg_list = saved_msg_list; /* Restore the exception context. */ \
|
msg_list = saved_msg_list; /* Restore the exception context. */ \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
#ifndef NVIM_EVAL_DECODE_H
|
#ifndef NVIM_EVAL_DECODE_H
|
||||||
#define NVIM_EVAL_DECODE_H
|
#define NVIM_EVAL_DECODE_H
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include <msgpack.h>
|
#include <msgpack.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "nvim/eval/typval.h"
|
#include "nvim/eval/typval.h"
|
||||||
#include "nvim/globals.h"
|
#include "nvim/globals.h"
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
#ifndef NVIM_EVAL_ENCODE_H
|
#ifndef NVIM_EVAL_ENCODE_H
|
||||||
#define NVIM_EVAL_ENCODE_H
|
#define NVIM_EVAL_ENCODE_H
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include <msgpack.h>
|
#include <msgpack.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval.h"
|
||||||
#include "nvim/garray.h"
|
#include "nvim/garray.h"
|
||||||
@@ -49,8 +48,7 @@ static inline ListReaderState encode_init_lrstate(const list_T *const list)
|
|||||||
.offset = 0,
|
.offset = 0,
|
||||||
.li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL
|
.li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL
|
||||||
? 0
|
? 0
|
||||||
: STRLEN(TV_LIST_ITEM_TV(
|
: STRLEN(TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string)),
|
||||||
tv_list_first(list))->vval.v_string)),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,23 +1,23 @@
|
|||||||
#ifndef NVIM_EVAL_TYPVAL_H
|
#ifndef NVIM_EVAL_TYPVAL_H
|
||||||
#define NVIM_EVAL_TYPVAL_H
|
#define NVIM_EVAL_TYPVAL_H
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.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/func_attr.h"
|
||||||
#include "nvim/lib/queue.h"
|
#include "nvim/garray.h"
|
||||||
#include "nvim/profile.h" // for proftime_T
|
|
||||||
#include "nvim/pos.h" // for linenr_T
|
|
||||||
#include "nvim/gettext.h"
|
#include "nvim/gettext.h"
|
||||||
#include "nvim/message.h"
|
#include "nvim/hashtab.h"
|
||||||
|
#include "nvim/lib/queue.h"
|
||||||
#include "nvim/macros.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
|
#ifdef LOG_LIST_ACTIONS
|
||||||
# include "nvim/memory.h"
|
# include "nvim/memory.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -156,8 +156,8 @@ typedef enum {
|
|||||||
typedef struct listitem_S listitem_T;
|
typedef struct listitem_S listitem_T;
|
||||||
|
|
||||||
struct listitem_S {
|
struct listitem_S {
|
||||||
listitem_T *li_next; ///< Next item in list.
|
listitem_T *li_next; ///< Next item in list.
|
||||||
listitem_T *li_prev; ///< Previous item in list.
|
listitem_T *li_prev; ///< Previous item in list.
|
||||||
typval_T li_tv; ///< Item value.
|
typval_T li_tv; ///< Item value.
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -195,25 +195,25 @@ typedef struct {
|
|||||||
} staticList10_T;
|
} staticList10_T;
|
||||||
|
|
||||||
#define TV_LIST_STATIC10_INIT { \
|
#define TV_LIST_STATIC10_INIT { \
|
||||||
.sl_list = { \
|
.sl_list = { \
|
||||||
.lv_first = NULL, \
|
.lv_first = NULL, \
|
||||||
.lv_last = NULL, \
|
.lv_last = NULL, \
|
||||||
.lv_refcount = 0, \
|
.lv_refcount = 0, \
|
||||||
.lv_len = 0, \
|
.lv_len = 0, \
|
||||||
.lv_watch = NULL, \
|
.lv_watch = NULL, \
|
||||||
.lv_idx_item = NULL, \
|
.lv_idx_item = NULL, \
|
||||||
.lv_lock = VAR_FIXED, \
|
.lv_lock = VAR_FIXED, \
|
||||||
.lv_used_next = NULL, \
|
.lv_used_next = NULL, \
|
||||||
.lv_used_prev = NULL, \
|
.lv_used_prev = NULL, \
|
||||||
}, \
|
}, \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TV_DICTITEM_STRUCT(...) \
|
#define TV_DICTITEM_STRUCT(...) \
|
||||||
struct { \
|
struct { \
|
||||||
typval_T di_tv; /* Structure that holds scope dictionary itself. */ \
|
typval_T di_tv; /* Structure that holds scope dictionary itself. */ \
|
||||||
uint8_t di_flags; /* Flags. */ \
|
uint8_t di_flags; /* Flags. */ \
|
||||||
char_u di_key[__VA_ARGS__]; /* Key value. */ \
|
char_u di_key[__VA_ARGS__]; /* Key value. */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Structure to hold a scope dictionary
|
/// Structure to hold a scope dictionary
|
||||||
///
|
///
|
||||||
@@ -321,40 +321,40 @@ struct funccall_S {
|
|||||||
|
|
||||||
/// Structure to hold info for a user function.
|
/// Structure to hold info for a user function.
|
||||||
struct ufunc {
|
struct ufunc {
|
||||||
int uf_varargs; ///< variable nr of arguments
|
int uf_varargs; ///< variable nr of arguments
|
||||||
int uf_flags;
|
int uf_flags;
|
||||||
int uf_calls; ///< nr of active calls
|
int uf_calls; ///< nr of active calls
|
||||||
bool uf_cleared; ///< func_clear() was already called
|
bool uf_cleared; ///< func_clear() was already called
|
||||||
garray_T uf_args; ///< arguments
|
garray_T uf_args; ///< arguments
|
||||||
garray_T uf_def_args; ///< default argument expressions
|
garray_T uf_def_args; ///< default argument expressions
|
||||||
garray_T uf_lines; ///< function lines
|
garray_T uf_lines; ///< function lines
|
||||||
int uf_profiling; ///< true when func is being profiled
|
int uf_profiling; ///< true when func is being profiled
|
||||||
int uf_prof_initialized;
|
int uf_prof_initialized;
|
||||||
// Managing cfuncs
|
// 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
|
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.
|
// Profiling the function as a whole.
|
||||||
int uf_tm_count; ///< nr of calls
|
int uf_tm_count; ///< nr of calls
|
||||||
proftime_T uf_tm_total; ///< time spent in function + children
|
proftime_T uf_tm_total; ///< time spent in function + children
|
||||||
proftime_T uf_tm_self; ///< time spent in function itself
|
proftime_T uf_tm_self; ///< time spent in function itself
|
||||||
proftime_T uf_tm_children; ///< time spent in children this call
|
proftime_T uf_tm_children; ///< time spent in children this call
|
||||||
// Profiling the function per line.
|
// Profiling the function per line.
|
||||||
int *uf_tml_count; ///< nr of times line was executed
|
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_total; ///< time spent in a line + children
|
||||||
proftime_T *uf_tml_self; ///< time spent in a line itself
|
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_start; ///< start time for current line
|
||||||
proftime_T uf_tml_children; ///< time spent in children for this line
|
proftime_T uf_tml_children; ///< time spent in children for this line
|
||||||
proftime_T uf_tml_wait; ///< start wait time for current 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_idx; ///< index of line being timed; -1 if none
|
||||||
int uf_tml_execed; ///< line being timed was executed
|
int uf_tml_execed; ///< line being timed was executed
|
||||||
sctx_T uf_script_ctx; ///< SCTX where function was defined,
|
sctx_T uf_script_ctx; ///< SCTX where function was defined,
|
||||||
///< used for s: variables
|
///< used for s: variables
|
||||||
int uf_refcount; ///< reference count, see func_name_refcount()
|
int uf_refcount; ///< reference count, see func_name_refcount()
|
||||||
funccall_T *uf_scoped; ///< l: local variables for closure
|
funccall_T *uf_scoped; ///< l: local variables for closure
|
||||||
char_u uf_name[]; ///< Name of function (actual size equals name);
|
char_u uf_name[]; ///< Name of function (actual size equals name);
|
||||||
///< can start with <SNR>123_
|
///< can start with <SNR>123_
|
||||||
///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
|
///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct partial_S {
|
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] li1 List item 1.
|
||||||
/// @param[in] li2 List item 2, often used for integers and not list items.
|
/// @param[in] li2 List item 2, often used for integers and not list items.
|
||||||
/// @param[in] action Logged action.
|
/// @param[in] action Logged action.
|
||||||
static inline void list_log(const list_T *const l,
|
static inline void list_log(const list_T *const l, const listitem_T *const li1,
|
||||||
const listitem_T *const li1,
|
const listitem_T *const li2, const char *const action)
|
||||||
const listitem_T *const li2,
|
|
||||||
const char *const action)
|
|
||||||
{
|
{
|
||||||
ListLog *tgt;
|
ListLog *tgt;
|
||||||
if (list_log_first == NULL) {
|
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
|
/// Convert a hashitem pointer to a dictitem pointer
|
||||||
#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 *const l)
|
static inline void tv_list_ref(list_T *const l)
|
||||||
REAL_FATTR_ALWAYS_INLINE;
|
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[out] l List to modify.
|
||||||
/// @param[in] lock New lock status.
|
/// @param[in] lock New lock status.
|
||||||
static inline void tv_list_set_lock(list_T *const l,
|
static inline void tv_list_set_lock(list_T *const l, const VarLockStatus lock)
|
||||||
const VarLockStatus lock)
|
|
||||||
{
|
{
|
||||||
if (l == NULL) {
|
if (l == NULL) {
|
||||||
assert(lock == VAR_FIXED);
|
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[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,
|
static inline void tv_list_set_copyid(list_T *const l, const int copyid)
|
||||||
const int copyid)
|
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
l->lv_copyID = copyid;
|
l->lv_copyID = copyid;
|
||||||
@@ -793,10 +789,10 @@ static inline void tv_init(typval_T *const tv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define TV_INITIAL_VALUE \
|
#define TV_INITIAL_VALUE \
|
||||||
((typval_T) { \
|
((typval_T) { \
|
||||||
.v_type = VAR_UNKNOWN, \
|
.v_type = VAR_UNKNOWN, \
|
||||||
.v_lock = VAR_UNLOCKED, \
|
.v_lock = VAR_UNLOCKED, \
|
||||||
})
|
})
|
||||||
|
|
||||||
/// Empty string
|
/// 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 li Name of the variable with current listitem_T entry.
|
||||||
/// @param code Cycle body.
|
/// @param code Cycle body.
|
||||||
#define _TV_LIST_ITER_MOD(modifier, l, li, code) \
|
#define _TV_LIST_ITER_MOD(modifier, l, li, code) \
|
||||||
do { \
|
do { \
|
||||||
modifier list_T *const l_ = (l); \
|
modifier list_T *const l_ = (l); \
|
||||||
list_log(l_, NULL, NULL, "iter" #modifier); \
|
list_log(l_, NULL, NULL, "iter" #modifier); \
|
||||||
if (l_ != NULL) { \
|
if (l_ != NULL) { \
|
||||||
for (modifier listitem_T *li = l_->lv_first; \
|
for (modifier listitem_T *li = l_->lv_first; \
|
||||||
li != NULL; li = li->li_next) { \
|
li != NULL; li = li->li_next) { \
|
||||||
code \
|
code \
|
||||||
} \
|
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/// Iterate over a list
|
/// 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 li Name of the variable with current listitem_T entry.
|
||||||
/// @param code Cycle body.
|
/// @param code Cycle body.
|
||||||
#define TV_LIST_ITER(l, li, code) \
|
#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
|
/// 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 li Name of the variable with current listitem_T entry.
|
||||||
/// @param code Cycle body.
|
/// @param code Cycle body.
|
||||||
#define TV_LIST_ITER_CONST(l, li, code) \
|
#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
|
// Below macros are macros to avoid duplicating code for functionally identical
|
||||||
// const and non-const function variants.
|
// 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 di Name of the variable with current dictitem_T entry.
|
||||||
/// @param code Cycle body.
|
/// @param code Cycle body.
|
||||||
#define TV_DICT_ITER(d, di, code) \
|
#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,
|
static inline bool tv_get_float_chk(const typval_T *const tv,
|
||||||
float_T *const ret_f)
|
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.
|
/// @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.
|
/// @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,
|
static inline bool tv_get_float_chk(const typval_T *const tv, float_T *const ret_f)
|
||||||
float_T *const ret_f)
|
|
||||||
{
|
{
|
||||||
if (tv->v_type == VAR_FLOAT) {
|
if (tv->v_type == VAR_FLOAT) {
|
||||||
*ret_f = tv->vval.v_float;
|
*ret_f = tv->vval.v_float;
|
||||||
|
@@ -240,15 +240,15 @@
|
|||||||
///
|
///
|
||||||
/// This name will only be used by one of the above macros which are defined by
|
/// 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.
|
/// the caller. Functions defined here do not use first argument directly.
|
||||||
#include <stddef.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <assert.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/eval/encode.h"
|
||||||
#include "nvim/func_attr.h"
|
#include "nvim/eval/typval.h"
|
||||||
#include "nvim/eval/typval_encode.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
|
/// Dummy variable used because some macros need lvalue
|
||||||
///
|
///
|
||||||
@@ -257,12 +257,12 @@
|
|||||||
const dict_T *const TYPVAL_ENCODE_NODICT_VAR = NULL;
|
const dict_T *const TYPVAL_ENCODE_NODICT_VAR = NULL;
|
||||||
|
|
||||||
static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
|
static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
|
||||||
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
|
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
|
||||||
void *const val, int *const val_copyID,
|
void *const val, int *const val_copyID,
|
||||||
const MPConvStack *const mpstack, const int copyID,
|
const MPConvStack *const mpstack, const int copyID,
|
||||||
const MPConvStackValType conv_type,
|
const MPConvStackValType conv_type,
|
||||||
const char *const objname)
|
const char *const objname)
|
||||||
REAL_FATTR_NONNULL_ARG(2, 3, 4, 7) REAL_FATTR_WARN_UNUSED_RESULT
|
REAL_FATTR_NONNULL_ARG(2, 3, 4, 7) REAL_FATTR_WARN_UNUSED_RESULT
|
||||||
REAL_FATTR_ALWAYS_INLINE;
|
REAL_FATTR_ALWAYS_INLINE;
|
||||||
|
|
||||||
/// Function for checking whether container references itself
|
/// 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.
|
/// @return NOTDONE in case of success, what to return in case of failure.
|
||||||
static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
|
static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
|
||||||
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
|
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME, void *const val, int *const val_copyID,
|
||||||
void *const val, int *const val_copyID,
|
const MPConvStack *const mpstack, const int copyID, const MPConvStackValType conv_type,
|
||||||
const MPConvStack *const mpstack, const int copyID,
|
const char *const objname)
|
||||||
const MPConvStackValType conv_type,
|
|
||||||
const char *const objname)
|
|
||||||
{
|
{
|
||||||
if (*val_copyID == copyID) {
|
if (*val_copyID == copyID) {
|
||||||
TYPVAL_ENCODE_CONV_RECURSE(val, conv_type);
|
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(
|
static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
||||||
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
|
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
|
||||||
MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
|
MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
|
||||||
typval_T *const tv, const int copyID,
|
typval_T *const tv, const int copyID,
|
||||||
const char *const objname)
|
const char *const objname)
|
||||||
REAL_FATTR_NONNULL_ARG(2, 4, 6) REAL_FATTR_WARN_UNUSED_RESULT;
|
REAL_FATTR_NONNULL_ARG(2, 4, 6) REAL_FATTR_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
/// Convert single value
|
/// 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.
|
/// @return OK in case of success, FAIL in case of failure.
|
||||||
static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
||||||
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
|
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME, MPConvStack *const mpstack,
|
||||||
MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
|
MPConvStackVal *const cur_mpsv, typval_T *const tv, const int copyID, const char *const objname)
|
||||||
typval_T *const tv, const int copyID,
|
|
||||||
const char *const objname)
|
|
||||||
{
|
{
|
||||||
switch (tv->v_type) {
|
switch (tv->v_type) {
|
||||||
case VAR_STRING: {
|
case VAR_STRING:
|
||||||
TYPVAL_ENCODE_CONV_STRING(tv, tv->vval.v_string, tv_strlen(tv));
|
TYPVAL_ENCODE_CONV_STRING(tv, tv->vval.v_string, tv_strlen(tv));
|
||||||
break;
|
break;
|
||||||
}
|
case VAR_NUMBER:
|
||||||
case VAR_NUMBER: {
|
TYPVAL_ENCODE_CONV_NUMBER(tv, tv->vval.v_number);
|
||||||
TYPVAL_ENCODE_CONV_NUMBER(tv, tv->vval.v_number);
|
break;
|
||||||
break;
|
case VAR_FLOAT:
|
||||||
}
|
TYPVAL_ENCODE_CONV_FLOAT(tv, tv->vval.v_float);
|
||||||
case VAR_FLOAT: {
|
break;
|
||||||
TYPVAL_ENCODE_CONV_FLOAT(tv, tv->vval.v_float);
|
case VAR_BLOB:
|
||||||
break;
|
TYPVAL_ENCODE_CONV_BLOB(tv, tv->vval.v_blob,
|
||||||
}
|
tv_blob_len(tv->vval.v_blob));
|
||||||
case VAR_BLOB: {
|
break;
|
||||||
TYPVAL_ENCODE_CONV_BLOB(tv, tv->vval.v_blob,
|
case VAR_FUNC:
|
||||||
tv_blob_len(tv->vval.v_blob));
|
TYPVAL_ENCODE_CONV_FUNC_START(tv, tv->vval.v_string);
|
||||||
break;
|
TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, 0);
|
||||||
}
|
TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
|
||||||
case VAR_FUNC: {
|
TYPVAL_ENCODE_CONV_FUNC_END(tv);
|
||||||
TYPVAL_ENCODE_CONV_FUNC_START(tv, tv->vval.v_string);
|
break;
|
||||||
TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, 0);
|
case VAR_PARTIAL: {
|
||||||
TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
|
partial_T *const pt = tv->vval.v_partial;
|
||||||
TYPVAL_ENCODE_CONV_FUNC_END(tv);
|
(void)pt;
|
||||||
break;
|
TYPVAL_ENCODE_CONV_FUNC_START( // -V547
|
||||||
}
|
tv, (pt == NULL ? NULL : partial_name(pt)));
|
||||||
case VAR_PARTIAL: {
|
_mp_push(*mpstack, ((MPConvStackVal) { // -V779
|
||||||
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,
|
.type = kMPConvPartial,
|
||||||
.tv = tv,
|
.tv = tv,
|
||||||
.saved_copyID = copyID - 1,
|
.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;
|
break;
|
||||||
}
|
}
|
||||||
case VAR_LIST: {
|
const int saved_copyID = tv_list_copyid(tv->vval.v_list);
|
||||||
if (tv->vval.v_list == NULL || tv_list_len(tv->vval.v_list) == 0) {
|
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_list, lv_copyID, copyID,
|
||||||
TYPVAL_ENCODE_CONV_EMPTY_LIST(tv);
|
kMPConvList);
|
||||||
break;
|
TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(tv->vval.v_list));
|
||||||
}
|
assert(saved_copyID != copyID);
|
||||||
const int saved_copyID = tv_list_copyid(tv->vval.v_list);
|
_mp_push(*mpstack, ((MPConvStackVal) {
|
||||||
_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,
|
.type = kMPConvList,
|
||||||
.tv = tv,
|
.tv = tv,
|
||||||
.saved_copyID = saved_copyID,
|
.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;
|
break;
|
||||||
}
|
}
|
||||||
case VAR_BOOL: {
|
break;
|
||||||
switch (tv->vval.v_bool) {
|
case VAR_SPECIAL:
|
||||||
case kBoolVarTrue:
|
switch (tv->vval.v_special) {
|
||||||
case kBoolVarFalse: {
|
case kSpecialVarNull:
|
||||||
TYPVAL_ENCODE_CONV_BOOL(tv, tv->vval.v_bool == kBoolVarTrue);
|
TYPVAL_ENCODE_CONV_NIL(tv); // -V1037
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
if (i == ARRAY_SIZE(eval_msgpack_type_lists)) {
|
||||||
}
|
goto _convert_one_value_regular_dict;
|
||||||
case VAR_SPECIAL: {
|
|
||||||
switch (tv->vval.v_special) {
|
|
||||||
case kSpecialVarNull: {
|
|
||||||
TYPVAL_ENCODE_CONV_NIL(tv); // -V1037
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
switch ((MessagePackType)i) {
|
||||||
}
|
case kMPNil:
|
||||||
case VAR_DICT: {
|
TYPVAL_ENCODE_CONV_NIL(tv);
|
||||||
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;
|
break;
|
||||||
}
|
case kMPBoolean:
|
||||||
const dictitem_T *type_di;
|
if (val_di->di_tv.v_type != VAR_NUMBER) {
|
||||||
const dictitem_T *val_di;
|
goto _convert_one_value_regular_dict;
|
||||||
if (TYPVAL_ENCODE_ALLOW_SPECIALS
|
}
|
||||||
&& tv->vval.v_dict->dv_hashtab.ht_used == 2
|
TYPVAL_ENCODE_CONV_BOOL(tv, val_di->di_tv.vval.v_number);
|
||||||
&& (type_di = tv_dict_find((dict_T *)tv->vval.v_dict,
|
break;
|
||||||
S_LEN("_TYPE"))) != NULL
|
case kMPInteger: {
|
||||||
&& type_di->di_tv.v_type == VAR_LIST
|
const list_T *val_list;
|
||||||
&& (val_di = tv_dict_find((dict_T *)tv->vval.v_dict,
|
varnumber_T sign;
|
||||||
S_LEN("_VAL"))) != NULL) {
|
varnumber_T highest_bits;
|
||||||
size_t i;
|
varnumber_T high_bits;
|
||||||
for (i = 0; i < ARRAY_SIZE(eval_msgpack_type_lists); i++) {
|
varnumber_T low_bits;
|
||||||
if (type_di->di_tv.vval.v_list == eval_msgpack_type_lists[i]) {
|
// List of 4 integers; first is signed (should be 1 or -1, but
|
||||||
break;
|
// 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
|
||||||
if (i == ARRAY_SIZE(eval_msgpack_type_lists)) {
|
// 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;
|
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);
|
const listitem_T *const sign_li = tv_list_first(val_list);
|
||||||
if (TV_LIST_ITEM_TV(sign_li)->v_type != VAR_NUMBER
|
if (TV_LIST_ITEM_TV(sign_li)->v_type != VAR_NUMBER
|
||||||
|| (sign = TV_LIST_ITEM_TV(sign_li)->vval.v_number) == 0) {
|
|| (sign = TV_LIST_ITEM_TV(sign_li)->vval.v_number) == 0) {
|
||||||
goto _convert_one_value_regular_dict;
|
goto _convert_one_value_regular_dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
const listitem_T *const highest_bits_li = (
|
const listitem_T *const highest_bits_li = (
|
||||||
TV_LIST_ITEM_NEXT(val_list, sign_li));
|
TV_LIST_ITEM_NEXT(val_list, sign_li));
|
||||||
if (TV_LIST_ITEM_TV(highest_bits_li)->v_type != VAR_NUMBER
|
if (TV_LIST_ITEM_TV(highest_bits_li)->v_type != VAR_NUMBER
|
||||||
|| ((highest_bits
|
|| ((highest_bits
|
||||||
= TV_LIST_ITEM_TV(highest_bits_li)->vval.v_number)
|
= TV_LIST_ITEM_TV(highest_bits_li)->vval.v_number)
|
||||||
< 0)) {
|
< 0)) {
|
||||||
goto _convert_one_value_regular_dict;
|
goto _convert_one_value_regular_dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
const listitem_T *const high_bits_li = (
|
const listitem_T *const high_bits_li = (
|
||||||
TV_LIST_ITEM_NEXT(val_list, highest_bits_li));
|
TV_LIST_ITEM_NEXT(val_list, highest_bits_li));
|
||||||
if (TV_LIST_ITEM_TV(high_bits_li)->v_type != VAR_NUMBER
|
if (TV_LIST_ITEM_TV(high_bits_li)->v_type != VAR_NUMBER
|
||||||
|| ((high_bits = TV_LIST_ITEM_TV(high_bits_li)->vval.v_number)
|
|| ((high_bits = TV_LIST_ITEM_TV(high_bits_li)->vval.v_number)
|
||||||
< 0)) {
|
< 0)) {
|
||||||
goto _convert_one_value_regular_dict;
|
goto _convert_one_value_regular_dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
const listitem_T *const low_bits_li = tv_list_last(val_list);
|
const listitem_T *const low_bits_li = tv_list_last(val_list);
|
||||||
if (TV_LIST_ITEM_TV(low_bits_li)->v_type != VAR_NUMBER
|
if (TV_LIST_ITEM_TV(low_bits_li)->v_type != VAR_NUMBER
|
||||||
|| ((low_bits = TV_LIST_ITEM_TV(low_bits_li)->vval.v_number)
|
|| ((low_bits = TV_LIST_ITEM_TV(low_bits_li)->vval.v_number)
|
||||||
< 0)) {
|
< 0)) {
|
||||||
goto _convert_one_value_regular_dict;
|
goto _convert_one_value_regular_dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62)
|
const uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62)
|
||||||
| (uint64_t)(((uint64_t)high_bits) << 31)
|
| (uint64_t)(((uint64_t)high_bits) << 31)
|
||||||
| (uint64_t)low_bits);
|
| (uint64_t)low_bits);
|
||||||
if (sign > 0) {
|
if (sign > 0) {
|
||||||
TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER(tv, number);
|
TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER(tv, number);
|
||||||
} else {
|
} else {
|
||||||
TYPVAL_ENCODE_CONV_NUMBER(tv, -number);
|
TYPVAL_ENCODE_CONV_NUMBER(tv, -number);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kMPFloat: {
|
case kMPFloat:
|
||||||
if (val_di->di_tv.v_type != VAR_FLOAT) {
|
if (val_di->di_tv.v_type != VAR_FLOAT) {
|
||||||
goto _convert_one_value_regular_dict;
|
goto _convert_one_value_regular_dict;
|
||||||
}
|
}
|
||||||
TYPVAL_ENCODE_CONV_FLOAT(tv, val_di->di_tv.vval.v_float);
|
TYPVAL_ENCODE_CONV_FLOAT(tv, val_di->di_tv.vval.v_float);
|
||||||
break;
|
break;
|
||||||
}
|
case kMPString:
|
||||||
case kMPString:
|
case kMPBinary: {
|
||||||
case kMPBinary: {
|
const bool is_string = ((MessagePackType)i == kMPString);
|
||||||
const bool is_string = ((MessagePackType)i == kMPString);
|
if (val_di->di_tv.v_type != VAR_LIST) {
|
||||||
if (val_di->di_tv.v_type != VAR_LIST) {
|
goto _convert_one_value_regular_dict;
|
||||||
goto _convert_one_value_regular_dict;
|
}
|
||||||
}
|
size_t len;
|
||||||
size_t len;
|
char *buf;
|
||||||
char *buf;
|
if (!encode_vim_list_to_buf(val_di->di_tv.vval.v_list, &len,
|
||||||
if (!encode_vim_list_to_buf(val_di->di_tv.vval.v_list, &len,
|
&buf)) {
|
||||||
&buf)) {
|
goto _convert_one_value_regular_dict;
|
||||||
goto _convert_one_value_regular_dict;
|
}
|
||||||
}
|
if (is_string) {
|
||||||
if (is_string) {
|
TYPVAL_ENCODE_CONV_STR_STRING(tv, buf, len);
|
||||||
TYPVAL_ENCODE_CONV_STR_STRING(tv, buf, len);
|
} else { // -V523
|
||||||
} else { // -V523
|
TYPVAL_ENCODE_CONV_STRING(tv, buf, len);
|
||||||
TYPVAL_ENCODE_CONV_STRING(tv, buf, len);
|
}
|
||||||
}
|
xfree(buf);
|
||||||
xfree(buf);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
case kMPArray: {
|
||||||
case kMPArray: {
|
if (val_di->di_tv.v_type != VAR_LIST) {
|
||||||
if (val_di->di_tv.v_type != VAR_LIST) {
|
goto _convert_one_value_regular_dict;
|
||||||
goto _convert_one_value_regular_dict;
|
}
|
||||||
}
|
const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
|
||||||
const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
|
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_di->di_tv.vval.v_list,
|
||||||
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_di->di_tv.vval.v_list,
|
lv_copyID, copyID,
|
||||||
lv_copyID, copyID,
|
kMPConvList);
|
||||||
kMPConvList);
|
TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(val_di->di_tv.vval.v_list));
|
||||||
TYPVAL_ENCODE_CONV_LIST_START(
|
assert(saved_copyID != copyID && saved_copyID != copyID - 1);
|
||||||
tv, tv_list_len(val_di->di_tv.vval.v_list));
|
_mp_push(*mpstack, ((MPConvStackVal) {
|
||||||
assert(saved_copyID != copyID && saved_copyID != copyID - 1);
|
|
||||||
_mp_push(*mpstack, ((MPConvStackVal) {
|
|
||||||
.tv = tv,
|
.tv = tv,
|
||||||
.type = kMPConvList,
|
.type = kMPConvList,
|
||||||
.saved_copyID = saved_copyID,
|
.saved_copyID = saved_copyID,
|
||||||
@@ -551,31 +534,31 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kMPMap: {
|
case kMPMap: {
|
||||||
if (val_di->di_tv.v_type != VAR_LIST) {
|
if (val_di->di_tv.v_type != VAR_LIST) {
|
||||||
goto _convert_one_value_regular_dict;
|
goto _convert_one_value_regular_dict;
|
||||||
}
|
}
|
||||||
list_T *const val_list = val_di->di_tv.vval.v_list;
|
list_T *const val_list = val_di->di_tv.vval.v_list;
|
||||||
if (val_list == NULL || tv_list_len(val_list) == 0) {
|
if (val_list == NULL || tv_list_len(val_list) == 0) {
|
||||||
TYPVAL_ENCODE_CONV_EMPTY_DICT( // -V501
|
TYPVAL_ENCODE_CONV_EMPTY_DICT( // -V501
|
||||||
tv, TYPVAL_ENCODE_NODICT_VAR);
|
tv, TYPVAL_ENCODE_NODICT_VAR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TV_LIST_ITER_CONST(val_list, li, {
|
TV_LIST_ITER_CONST(val_list, li, {
|
||||||
if (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST
|
if (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST
|
||||||
|| tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) != 2) {
|
|| tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) != 2) {
|
||||||
goto _convert_one_value_regular_dict;
|
goto _convert_one_value_regular_dict;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
|
const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
|
||||||
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_list, lv_copyID, copyID,
|
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_list, lv_copyID, copyID,
|
||||||
kMPConvPairs);
|
kMPConvPairs);
|
||||||
TYPVAL_ENCODE_CONV_DICT_START(tv, TYPVAL_ENCODE_NODICT_VAR,
|
TYPVAL_ENCODE_CONV_DICT_START(tv, TYPVAL_ENCODE_NODICT_VAR,
|
||||||
tv_list_len(val_list));
|
tv_list_len(val_list));
|
||||||
assert(saved_copyID != copyID && saved_copyID != copyID - 1);
|
assert(saved_copyID != copyID && saved_copyID != copyID - 1);
|
||||||
_mp_push(*mpstack, ((MPConvStackVal) {
|
_mp_push(*mpstack, ((MPConvStackVal) {
|
||||||
.tv = tv,
|
.tv = tv,
|
||||||
.type = kMPConvPairs,
|
.type = kMPConvPairs,
|
||||||
.saved_copyID = saved_copyID,
|
.saved_copyID = saved_copyID,
|
||||||
@@ -586,46 +569,45 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kMPExt: {
|
|
||||||
const list_T *val_list;
|
|
||||||
varnumber_T type;
|
|
||||||
if (val_di->di_tv.v_type != VAR_LIST
|
|
||||||
|| tv_list_len((val_list = val_di->di_tv.vval.v_list)) != 2
|
|
||||||
|| (TV_LIST_ITEM_TV(tv_list_first(val_list))->v_type
|
|
||||||
!= VAR_NUMBER)
|
|
||||||
|| ((type
|
|
||||||
= TV_LIST_ITEM_TV(tv_list_first(val_list))->vval.v_number)
|
|
||||||
> INT8_MAX)
|
|
||||||
|| type < INT8_MIN
|
|
||||||
|| (TV_LIST_ITEM_TV(tv_list_last(val_list))->v_type
|
|
||||||
!= VAR_LIST)) {
|
|
||||||
goto _convert_one_value_regular_dict;
|
|
||||||
}
|
|
||||||
size_t len;
|
|
||||||
char *buf;
|
|
||||||
if (!(
|
|
||||||
encode_vim_list_to_buf(
|
|
||||||
TV_LIST_ITEM_TV(tv_list_last(val_list))->vval.v_list, &len,
|
|
||||||
&buf))) {
|
|
||||||
goto _convert_one_value_regular_dict;
|
|
||||||
}
|
|
||||||
TYPVAL_ENCODE_CONV_EXT_STRING(tv, buf, len, type);
|
|
||||||
xfree(buf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case kMPExt: {
|
||||||
|
const list_T *val_list;
|
||||||
|
varnumber_T type;
|
||||||
|
if (val_di->di_tv.v_type != VAR_LIST
|
||||||
|
|| tv_list_len((val_list = val_di->di_tv.vval.v_list)) != 2
|
||||||
|
|| (TV_LIST_ITEM_TV(tv_list_first(val_list))->v_type
|
||||||
|
!= VAR_NUMBER)
|
||||||
|
|| ((type
|
||||||
|
= TV_LIST_ITEM_TV(tv_list_first(val_list))->vval.v_number)
|
||||||
|
> INT8_MAX)
|
||||||
|
|| type < INT8_MIN
|
||||||
|
|| (TV_LIST_ITEM_TV(tv_list_last(val_list))->v_type
|
||||||
|
!= VAR_LIST)) {
|
||||||
|
goto _convert_one_value_regular_dict;
|
||||||
|
}
|
||||||
|
size_t len;
|
||||||
|
char *buf;
|
||||||
|
if (!(
|
||||||
|
encode_vim_list_to_buf(TV_LIST_ITEM_TV(tv_list_last(val_list))->vval.v_list, &len,
|
||||||
|
&buf))) {
|
||||||
|
goto _convert_one_value_regular_dict;
|
||||||
|
}
|
||||||
|
TYPVAL_ENCODE_CONV_EXT_STRING(tv, buf, len, type);
|
||||||
|
xfree(buf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
_convert_one_value_regular_dict: {}
|
_convert_one_value_regular_dict: {}
|
||||||
const int saved_copyID = tv->vval.v_dict->dv_copyID;
|
const int saved_copyID = tv->vval.v_dict->dv_copyID;
|
||||||
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_dict, dv_copyID, copyID,
|
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_dict, dv_copyID, copyID,
|
||||||
kMPConvDict);
|
kMPConvDict);
|
||||||
TYPVAL_ENCODE_CONV_DICT_START(tv, tv->vval.v_dict,
|
TYPVAL_ENCODE_CONV_DICT_START(tv, tv->vval.v_dict,
|
||||||
tv->vval.v_dict->dv_hashtab.ht_used);
|
tv->vval.v_dict->dv_hashtab.ht_used);
|
||||||
assert(saved_copyID != copyID);
|
assert(saved_copyID != copyID);
|
||||||
_mp_push(*mpstack, ((MPConvStackVal) {
|
_mp_push(*mpstack, ((MPConvStackVal) {
|
||||||
.tv = tv,
|
.tv = tv,
|
||||||
.type = kMPConvDict,
|
.type = kMPConvDict,
|
||||||
.saved_copyID = saved_copyID,
|
.saved_copyID = saved_copyID,
|
||||||
@@ -638,14 +620,13 @@ _convert_one_value_regular_dict: {}
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(tv, tv->vval.v_dict,
|
TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(tv, tv->vval.v_dict,
|
||||||
_mp_last(*mpstack));
|
_mp_last(*mpstack));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VAR_UNKNOWN: {
|
case VAR_UNKNOWN:
|
||||||
internal_error(STR(_TYPVAL_ENCODE_CONVERT_ONE_VALUE) "()");
|
internal_error(STR(_TYPVAL_ENCODE_CONVERT_ONE_VALUE) "()");
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
typval_encode_stop_converting_one_item:
|
typval_encode_stop_converting_one_item:
|
||||||
return OK;
|
return OK;
|
||||||
@@ -654,9 +635,9 @@ typval_encode_stop_converting_one_item:
|
|||||||
}
|
}
|
||||||
|
|
||||||
TYPVAL_ENCODE_SCOPE int _TYPVAL_ENCODE_ENCODE(
|
TYPVAL_ENCODE_SCOPE int _TYPVAL_ENCODE_ENCODE(
|
||||||
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
|
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
|
||||||
typval_T *const tv, const char *const objname)
|
typval_T *const tv, const char *const objname)
|
||||||
REAL_FATTR_NONNULL_ARG(2, 3) REAL_FATTR_WARN_UNUSED_RESULT;
|
REAL_FATTR_NONNULL_ARG(2, 3) REAL_FATTR_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
/// Convert the whole typval
|
/// Convert the whole typval
|
||||||
///
|
///
|
||||||
@@ -668,8 +649,8 @@ TYPVAL_ENCODE_SCOPE int _TYPVAL_ENCODE_ENCODE(
|
|||||||
///
|
///
|
||||||
/// @return OK in case of success, FAIL in case of failure.
|
/// @return OK in case of success, FAIL in case of failure.
|
||||||
TYPVAL_ENCODE_SCOPE int _TYPVAL_ENCODE_ENCODE(
|
TYPVAL_ENCODE_SCOPE int _TYPVAL_ENCODE_ENCODE(
|
||||||
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
|
TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME, typval_T *const top_tv,
|
||||||
typval_T *const top_tv, const char *const objname)
|
const char *const objname)
|
||||||
{
|
{
|
||||||
const int copyID = get_copyID();
|
const int copyID = get_copyID();
|
||||||
MPConvStack mpstack;
|
MPConvStack mpstack;
|
||||||
@@ -687,125 +668,121 @@ typval_encode_stop_converting_one_item:
|
|||||||
MPConvStackVal *cur_mpsv = &_mp_last(mpstack);
|
MPConvStackVal *cur_mpsv = &_mp_last(mpstack);
|
||||||
typval_T *tv = NULL;
|
typval_T *tv = NULL;
|
||||||
switch (cur_mpsv->type) {
|
switch (cur_mpsv->type) {
|
||||||
case kMPConvDict: {
|
case kMPConvDict: {
|
||||||
if (!cur_mpsv->data.d.todo) {
|
if (!cur_mpsv->data.d.todo) {
|
||||||
(void)_mp_pop(mpstack);
|
(void)_mp_pop(mpstack);
|
||||||
cur_mpsv->data.d.dict->dv_copyID = cur_mpsv->saved_copyID;
|
cur_mpsv->data.d.dict->dv_copyID = cur_mpsv->saved_copyID;
|
||||||
TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, *cur_mpsv->data.d.dictp);
|
TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, *cur_mpsv->data.d.dictp);
|
||||||
continue;
|
continue;
|
||||||
} else if (cur_mpsv->data.d.todo
|
} else if (cur_mpsv->data.d.todo
|
||||||
!= cur_mpsv->data.d.dict->dv_hashtab.ht_used) {
|
!= cur_mpsv->data.d.dict->dv_hashtab.ht_used) {
|
||||||
TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(cur_mpsv->tv,
|
TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(cur_mpsv->tv,
|
||||||
*cur_mpsv->data.d.dictp);
|
*cur_mpsv->data.d.dictp);
|
||||||
}
|
}
|
||||||
while (HASHITEM_EMPTY(cur_mpsv->data.d.hi)) {
|
while (HASHITEM_EMPTY(cur_mpsv->data.d.hi)) {
|
||||||
cur_mpsv->data.d.hi++;
|
|
||||||
}
|
|
||||||
dictitem_T *const di = TV_DICT_HI2DI(cur_mpsv->data.d.hi);
|
|
||||||
cur_mpsv->data.d.todo--;
|
|
||||||
cur_mpsv->data.d.hi++;
|
cur_mpsv->data.d.hi++;
|
||||||
TYPVAL_ENCODE_CONV_STR_STRING(NULL, &di->di_key[0],
|
|
||||||
strlen((char *)&di->di_key[0]));
|
|
||||||
TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(cur_mpsv->tv,
|
|
||||||
*cur_mpsv->data.d.dictp);
|
|
||||||
tv = &di->di_tv;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case kMPConvList: {
|
dictitem_T *const di = TV_DICT_HI2DI(cur_mpsv->data.d.hi);
|
||||||
if (cur_mpsv->data.l.li == NULL) {
|
cur_mpsv->data.d.todo--;
|
||||||
(void)_mp_pop(mpstack);
|
cur_mpsv->data.d.hi++;
|
||||||
tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
|
TYPVAL_ENCODE_CONV_STR_STRING(NULL, &di->di_key[0],
|
||||||
TYPVAL_ENCODE_CONV_LIST_END(cur_mpsv->tv);
|
strlen((char *)&di->di_key[0]));
|
||||||
continue;
|
TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(cur_mpsv->tv,
|
||||||
} else if (cur_mpsv->data.l.li
|
*cur_mpsv->data.d.dictp);
|
||||||
!= tv_list_first(cur_mpsv->data.l.list)) {
|
tv = &di->di_tv;
|
||||||
TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(cur_mpsv->tv);
|
break;
|
||||||
}
|
}
|
||||||
tv = TV_LIST_ITEM_TV(cur_mpsv->data.l.li);
|
case kMPConvList:
|
||||||
cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
|
if (cur_mpsv->data.l.li == NULL) {
|
||||||
cur_mpsv->data.l.li);
|
(void)_mp_pop(mpstack);
|
||||||
break;
|
tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
|
||||||
|
TYPVAL_ENCODE_CONV_LIST_END(cur_mpsv->tv);
|
||||||
|
continue;
|
||||||
|
} else if (cur_mpsv->data.l.li
|
||||||
|
!= tv_list_first(cur_mpsv->data.l.list)) {
|
||||||
|
TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(cur_mpsv->tv);
|
||||||
}
|
}
|
||||||
case kMPConvPairs: {
|
tv = TV_LIST_ITEM_TV(cur_mpsv->data.l.li);
|
||||||
if (cur_mpsv->data.l.li == NULL) {
|
cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
|
||||||
(void)_mp_pop(mpstack);
|
cur_mpsv->data.l.li);
|
||||||
tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
|
break;
|
||||||
TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
|
case kMPConvPairs: {
|
||||||
continue;
|
if (cur_mpsv->data.l.li == NULL) {
|
||||||
} else if (cur_mpsv->data.l.li
|
(void)_mp_pop(mpstack);
|
||||||
!= tv_list_first(cur_mpsv->data.l.list)) {
|
tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
|
||||||
TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(
|
TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
|
||||||
cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
|
continue;
|
||||||
}
|
} else if (cur_mpsv->data.l.li
|
||||||
const list_T *const kv_pair = (
|
!= tv_list_first(cur_mpsv->data.l.list)) {
|
||||||
TV_LIST_ITEM_TV(cur_mpsv->data.l.li)->vval.v_list);
|
TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
|
||||||
TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK(
|
|
||||||
encode_vim_to__error_ret, *TV_LIST_ITEM_TV(tv_list_first(kv_pair)));
|
|
||||||
if (
|
|
||||||
_TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
|
||||||
TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack, cur_mpsv,
|
|
||||||
TV_LIST_ITEM_TV(tv_list_first(kv_pair)), copyID, objname)
|
|
||||||
== FAIL) {
|
|
||||||
goto encode_vim_to__error_ret;
|
|
||||||
}
|
|
||||||
TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(cur_mpsv->tv,
|
|
||||||
TYPVAL_ENCODE_NODICT_VAR);
|
|
||||||
tv = TV_LIST_ITEM_TV(tv_list_last(kv_pair));
|
|
||||||
cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
|
|
||||||
cur_mpsv->data.l.li);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case kMPConvPartial: {
|
const list_T *const kv_pair = (
|
||||||
partial_T *const pt = cur_mpsv->data.p.pt;
|
TV_LIST_ITEM_TV(cur_mpsv->data.l.li)->vval.v_list);
|
||||||
tv = cur_mpsv->tv;
|
TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK(encode_vim_to__error_ret,
|
||||||
(void)tv;
|
*TV_LIST_ITEM_TV(tv_list_first(kv_pair)));
|
||||||
switch (cur_mpsv->data.p.stage) {
|
if (
|
||||||
case kMPConvPartialArgs: {
|
_TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack, cur_mpsv,
|
||||||
TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv,
|
TV_LIST_ITEM_TV(tv_list_first(kv_pair)), copyID, objname)
|
||||||
pt == NULL ? 0 : pt->pt_argc);
|
== FAIL) {
|
||||||
cur_mpsv->data.p.stage = kMPConvPartialSelf;
|
goto encode_vim_to__error_ret;
|
||||||
if (pt != NULL && pt->pt_argc > 0) {
|
}
|
||||||
TYPVAL_ENCODE_CONV_LIST_START(NULL, pt->pt_argc);
|
TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(cur_mpsv->tv,
|
||||||
_mp_push(mpstack, ((MPConvStackVal) {
|
TYPVAL_ENCODE_NODICT_VAR);
|
||||||
.type = kMPConvPartialList,
|
tv = TV_LIST_ITEM_TV(tv_list_last(kv_pair));
|
||||||
.tv = NULL,
|
cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
|
||||||
.saved_copyID = copyID - 1,
|
cur_mpsv->data.l.li);
|
||||||
.data = {
|
break;
|
||||||
.a = {
|
}
|
||||||
.arg = pt->pt_argv,
|
case kMPConvPartial: {
|
||||||
.argv = pt->pt_argv,
|
partial_T *const pt = cur_mpsv->data.p.pt;
|
||||||
.todo = (size_t)pt->pt_argc,
|
tv = cur_mpsv->tv;
|
||||||
},
|
(void)tv;
|
||||||
|
switch (cur_mpsv->data.p.stage) {
|
||||||
|
case kMPConvPartialArgs:
|
||||||
|
TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv,
|
||||||
|
pt == NULL ? 0 : pt->pt_argc);
|
||||||
|
cur_mpsv->data.p.stage = kMPConvPartialSelf;
|
||||||
|
if (pt != NULL && pt->pt_argc > 0) {
|
||||||
|
TYPVAL_ENCODE_CONV_LIST_START(NULL, pt->pt_argc);
|
||||||
|
_mp_push(mpstack, ((MPConvStackVal) {
|
||||||
|
.type = kMPConvPartialList,
|
||||||
|
.tv = NULL,
|
||||||
|
.saved_copyID = copyID - 1,
|
||||||
|
.data = {
|
||||||
|
.a = {
|
||||||
|
.arg = pt->pt_argv,
|
||||||
|
.argv = pt->pt_argv,
|
||||||
|
.todo = (size_t)pt->pt_argc,
|
||||||
},
|
},
|
||||||
}));
|
},
|
||||||
}
|
}));
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
case kMPConvPartialSelf: {
|
||||||
|
cur_mpsv->data.p.stage = kMPConvPartialEnd;
|
||||||
|
dict_T *const dict = pt == NULL ? NULL : pt->pt_dict;
|
||||||
|
if (dict != NULL) {
|
||||||
|
TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, dict->dv_hashtab.ht_used);
|
||||||
|
if (dict->dv_hashtab.ht_used == 0) {
|
||||||
|
TYPVAL_ENCODE_CONV_EMPTY_DICT(NULL, pt->pt_dict);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
case kMPConvPartialSelf: {
|
const int saved_copyID = dict->dv_copyID;
|
||||||
cur_mpsv->data.p.stage = kMPConvPartialEnd;
|
const int te_csr_ret = _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(TYPVAL_ENCODE_FIRST_ARG_NAME,
|
||||||
dict_T *const dict = pt == NULL ? NULL : pt->pt_dict;
|
dict, &dict->dv_copyID,
|
||||||
if (dict != NULL) {
|
&mpstack, copyID, kMPConvDict,
|
||||||
TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, dict->dv_hashtab.ht_used);
|
objname);
|
||||||
if (dict->dv_hashtab.ht_used == 0) {
|
if (te_csr_ret != NOTDONE) {
|
||||||
TYPVAL_ENCODE_CONV_EMPTY_DICT(NULL, pt->pt_dict);
|
if (te_csr_ret == FAIL) {
|
||||||
continue;
|
goto encode_vim_to__error_ret;
|
||||||
}
|
} else {
|
||||||
const int saved_copyID = dict->dv_copyID;
|
continue;
|
||||||
const int te_csr_ret = _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
|
}
|
||||||
TYPVAL_ENCODE_FIRST_ARG_NAME,
|
}
|
||||||
dict, &dict->dv_copyID, &mpstack, copyID, kMPConvDict,
|
TYPVAL_ENCODE_CONV_DICT_START(NULL, pt->pt_dict,
|
||||||
objname);
|
dict->dv_hashtab.ht_used);
|
||||||
if (te_csr_ret != NOTDONE) {
|
assert(saved_copyID != copyID && saved_copyID != copyID - 1);
|
||||||
if (te_csr_ret == FAIL) {
|
_mp_push(mpstack, ((MPConvStackVal) {
|
||||||
goto encode_vim_to__error_ret;
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TYPVAL_ENCODE_CONV_DICT_START(NULL, pt->pt_dict,
|
|
||||||
dict->dv_hashtab.ht_used);
|
|
||||||
assert(saved_copyID != copyID && saved_copyID != copyID - 1);
|
|
||||||
_mp_push(mpstack, ((MPConvStackVal) {
|
|
||||||
.type = kMPConvDict,
|
.type = kMPConvDict,
|
||||||
.tv = NULL,
|
.tv = NULL,
|
||||||
.saved_copyID = saved_copyID,
|
.saved_copyID = saved_copyID,
|
||||||
@@ -818,33 +795,31 @@ typval_encode_stop_converting_one_item:
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(NULL, pt->pt_dict,
|
TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(NULL, pt->pt_dict,
|
||||||
_mp_last(mpstack));
|
_mp_last(mpstack));
|
||||||
} else {
|
} else {
|
||||||
TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
|
TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kMPConvPartialEnd: {
|
|
||||||
TYPVAL_ENCODE_CONV_FUNC_END(tv);
|
|
||||||
(void)_mp_pop(mpstack);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
case kMPConvPartialList: {
|
|
||||||
if (!cur_mpsv->data.a.todo) {
|
|
||||||
(void)_mp_pop(mpstack);
|
|
||||||
TYPVAL_ENCODE_CONV_LIST_END(NULL);
|
|
||||||
continue;
|
|
||||||
} else if (cur_mpsv->data.a.argv != cur_mpsv->data.a.arg) {
|
|
||||||
TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(NULL);
|
|
||||||
}
|
|
||||||
tv = cur_mpsv->data.a.arg++;
|
|
||||||
cur_mpsv->data.a.todo--;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case kMPConvPartialEnd:
|
||||||
|
TYPVAL_ENCODE_CONV_FUNC_END(tv);
|
||||||
|
(void)_mp_pop(mpstack);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case kMPConvPartialList:
|
||||||
|
if (!cur_mpsv->data.a.todo) {
|
||||||
|
(void)_mp_pop(mpstack);
|
||||||
|
TYPVAL_ENCODE_CONV_LIST_END(NULL);
|
||||||
|
continue;
|
||||||
|
} else if (cur_mpsv->data.a.argv != cur_mpsv->data.a.arg) {
|
||||||
|
TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(NULL);
|
||||||
|
}
|
||||||
|
tv = cur_mpsv->data.a.arg++;
|
||||||
|
cur_mpsv->data.a.todo--;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
assert(tv != NULL);
|
assert(tv != NULL);
|
||||||
if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack,
|
if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack,
|
||||||
|
@@ -5,14 +5,14 @@
|
|||||||
#ifndef NVIM_EVAL_TYPVAL_ENCODE_H
|
#ifndef NVIM_EVAL_TYPVAL_ENCODE_H
|
||||||
#define NVIM_EVAL_TYPVAL_ENCODE_H
|
#define NVIM_EVAL_TYPVAL_ENCODE_H
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "nvim/lib/kvec.h"
|
|
||||||
#include "nvim/eval/typval.h"
|
#include "nvim/eval/typval.h"
|
||||||
#include "nvim/func_attr.h"
|
#include "nvim/func_attr.h"
|
||||||
|
#include "nvim/lib/kvec.h"
|
||||||
|
|
||||||
/// Type of the stack entry
|
/// Type of the stack entry
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -87,7 +87,7 @@ static inline size_t tv_strlen(const typval_T *const tv)
|
|||||||
assert(tv->v_type == VAR_STRING);
|
assert(tv->v_type == VAR_STRING);
|
||||||
return (tv->vval.v_string == NULL
|
return (tv->vval.v_string == NULL
|
||||||
? 0
|
? 0
|
||||||
: strlen((char *) tv->vval.v_string));
|
: strlen((char *)tv->vval.v_string));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Code for checking whether container references itself
|
/// Code for checking whether container references itself
|
||||||
@@ -100,19 +100,19 @@ static inline size_t tv_strlen(const typval_T *const tv)
|
|||||||
/// @param conv_type Type of the conversion, @see MPConvStackValType.
|
/// @param conv_type Type of the conversion, @see MPConvStackValType.
|
||||||
#define _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val, copyID_attr, copyID, \
|
#define _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val, copyID_attr, copyID, \
|
||||||
conv_type) \
|
conv_type) \
|
||||||
do { \
|
do { \
|
||||||
const int te_csr_ret = _TYPVAL_ENCODE_CHECK_SELF_REFERENCE( \
|
const int te_csr_ret = _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(TYPVAL_ENCODE_FIRST_ARG_NAME, \
|
||||||
TYPVAL_ENCODE_FIRST_ARG_NAME, \
|
(val), &(val)->copyID_attr, mpstack, \
|
||||||
(val), &(val)->copyID_attr, mpstack, copyID, conv_type, objname); \
|
copyID, conv_type, objname); \
|
||||||
if (te_csr_ret != NOTDONE) { \
|
if (te_csr_ret != NOTDONE) { \
|
||||||
return te_csr_ret; \
|
return te_csr_ret; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define _TYPVAL_ENCODE_FUNC_NAME_INNER_2(pref, name, suf) \
|
#define _TYPVAL_ENCODE_FUNC_NAME_INNER_2(pref, name, suf) \
|
||||||
pref##name##suf
|
pref##name##suf
|
||||||
#define _TYPVAL_ENCODE_FUNC_NAME_INNER(pref, name, suf) \
|
#define _TYPVAL_ENCODE_FUNC_NAME_INNER(pref, name, suf) \
|
||||||
_TYPVAL_ENCODE_FUNC_NAME_INNER_2(pref, name, suf)
|
_TYPVAL_ENCODE_FUNC_NAME_INNER_2(pref, name, suf)
|
||||||
|
|
||||||
/// Construct function name, possibly using macros
|
/// Construct function name, possibly using macros
|
||||||
///
|
///
|
||||||
@@ -125,22 +125,22 @@ static inline size_t tv_strlen(const typval_T *const tv)
|
|||||||
///
|
///
|
||||||
/// @return Concat: pref + #TYPVAL_ENCODE_NAME + suf.
|
/// @return Concat: pref + #TYPVAL_ENCODE_NAME + suf.
|
||||||
#define _TYPVAL_ENCODE_FUNC_NAME(pref, suf) \
|
#define _TYPVAL_ENCODE_FUNC_NAME(pref, suf) \
|
||||||
_TYPVAL_ENCODE_FUNC_NAME_INNER(pref, TYPVAL_ENCODE_NAME, suf)
|
_TYPVAL_ENCODE_FUNC_NAME_INNER(pref, TYPVAL_ENCODE_NAME, suf)
|
||||||
|
|
||||||
/// Self reference checker function name
|
/// Self reference checker function name
|
||||||
#define _TYPVAL_ENCODE_CHECK_SELF_REFERENCE \
|
#define _TYPVAL_ENCODE_CHECK_SELF_REFERENCE \
|
||||||
_TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _check_self_reference)
|
_TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _check_self_reference)
|
||||||
|
|
||||||
/// Entry point function name
|
/// Entry point function name
|
||||||
#define _TYPVAL_ENCODE_ENCODE \
|
#define _TYPVAL_ENCODE_ENCODE \
|
||||||
_TYPVAL_ENCODE_FUNC_NAME(encode_vim_to_, )
|
_TYPVAL_ENCODE_FUNC_NAME(encode_vim_to_, )
|
||||||
|
|
||||||
/// Name of the …convert_one_value function
|
/// Name of the …convert_one_value function
|
||||||
#define _TYPVAL_ENCODE_CONVERT_ONE_VALUE \
|
#define _TYPVAL_ENCODE_CONVERT_ONE_VALUE \
|
||||||
_TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _convert_one_value)
|
_TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _convert_one_value)
|
||||||
|
|
||||||
/// Name of the dummy const dict_T *const variable
|
/// Name of the dummy const dict_T *const variable
|
||||||
#define TYPVAL_ENCODE_NODICT_VAR \
|
#define TYPVAL_ENCODE_NODICT_VAR \
|
||||||
_TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _nodict_var)
|
_TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _nodict_var)
|
||||||
|
|
||||||
#endif // NVIM_EVAL_TYPVAL_ENCODE_H
|
#endif // NVIM_EVAL_TYPVAL_ENCODE_H
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
dict_T *fd_dict; ///< Dictionary used.
|
dict_T *fd_dict; ///< Dictionary used.
|
||||||
char_u *fd_newkey; ///< New key in "dict" in allocated memory.
|
char_u *fd_newkey; ///< New key in "dict" in allocated memory.
|
||||||
dictitem_T *fd_di; ///< Dictionary item used.
|
dictitem_T *fd_di; ///< Dictionary item used.
|
||||||
} funcdict_T;
|
} funcdict_T;
|
||||||
|
|
||||||
typedef struct funccal_entry funccal_entry_T;
|
typedef struct funccal_entry funccal_entry_T;
|
||||||
|
@@ -11,7 +11,7 @@ typedef struct message {
|
|||||||
argv_callback handler;
|
argv_callback handler;
|
||||||
void *argv[EVENT_HANDLER_MAX_ARGC];
|
void *argv[EVENT_HANDLER_MAX_ARGC];
|
||||||
} Event;
|
} Event;
|
||||||
typedef void(*event_scheduler)(Event event, void *data);
|
typedef void (*event_scheduler)(Event event, void *data);
|
||||||
|
|
||||||
#define VA_EVENT_INIT(event, h, a) \
|
#define VA_EVENT_INIT(event, h, a) \
|
||||||
do { \
|
do { \
|
||||||
|
@@ -2,12 +2,11 @@
|
|||||||
#define NVIM_EVENT_LOOP_H
|
#define NVIM_EVENT_LOOP_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
|
#include "nvim/event/multiqueue.h"
|
||||||
#include "nvim/lib/klist.h"
|
#include "nvim/lib/klist.h"
|
||||||
#include "nvim/os/time.h"
|
#include "nvim/os/time.h"
|
||||||
#include "nvim/event/multiqueue.h"
|
|
||||||
|
|
||||||
typedef void * WatcherPtr;
|
typedef void * WatcherPtr;
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ typedef struct loop {
|
|||||||
break; \
|
break; \
|
||||||
} else if (remaining > 0) { \
|
} else if (remaining > 0) { \
|
||||||
uint64_t now = os_hrtime(); \
|
uint64_t now = os_hrtime(); \
|
||||||
remaining -= (int) ((now - before) / 1000000); \
|
remaining -= (int)((now - before) / 1000000); \
|
||||||
before = now; \
|
before = now; \
|
||||||
if (remaining <= 0) { \
|
if (remaining <= 0) { \
|
||||||
break; \
|
break; \
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
#ifndef NVIM_EVENT_PROCESS_H
|
#ifndef NVIM_EVENT_PROCESS_H
|
||||||
#define NVIM_EVENT_PROCESS_H
|
#define NVIM_EVENT_PROCESS_H
|
||||||
|
|
||||||
|
#include "nvim/eval/typval.h"
|
||||||
#include "nvim/event/loop.h"
|
#include "nvim/event/loop.h"
|
||||||
#include "nvim/event/rstream.h"
|
#include "nvim/event/rstream.h"
|
||||||
#include "nvim/event/wstream.h"
|
#include "nvim/event/wstream.h"
|
||||||
#include "nvim/eval/typval.h"
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kProcessTypeUv,
|
kProcessTypeUv,
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
#include "nvim/event/loop.h"
|
#include "nvim/event/loop.h"
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
#include "nvim/event/loop.h"
|
#include "nvim/event/loop.h"
|
||||||
@@ -18,7 +17,7 @@ typedef struct stream Stream;
|
|||||||
/// @param data User-defined data
|
/// @param data User-defined data
|
||||||
/// @param eof If the stream reached EOF.
|
/// @param eof If the stream reached EOF.
|
||||||
typedef void (*stream_read_cb)(Stream *stream, RBuffer *buf, size_t count,
|
typedef void (*stream_read_cb)(Stream *stream, RBuffer *buf, size_t count,
|
||||||
void *data, bool eof);
|
void *data, bool eof);
|
||||||
|
|
||||||
/// Type of function called when the Stream has information about a write
|
/// Type of function called when the Stream has information about a write
|
||||||
/// request.
|
/// request.
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
#ifndef NVIM_EVENT_WSTREAM_H
|
#ifndef NVIM_EVENT_WSTREAM_H
|
||||||
#define NVIM_EVENT_WSTREAM_H
|
#define NVIM_EVENT_WSTREAM_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
#include "nvim/event/loop.h"
|
#include "nvim/event/loop.h"
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/func_attr.h"
|
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval.h"
|
||||||
|
#include "nvim/func_attr.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
LuaRef func_ref;
|
LuaRef func_ref;
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
#ifndef NVIM_LUA_EXECUTOR_H
|
#ifndef NVIM_LUA_EXECUTOR_H
|
||||||
#define NVIM_LUA_EXECUTOR_H
|
#define NVIM_LUA_EXECUTOR_H
|
||||||
|
|
||||||
#include <lua.h>
|
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
|
#include <lua.h>
|
||||||
|
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/func_attr.h"
|
|
||||||
#include "nvim/eval/typval.h"
|
#include "nvim/eval/typval.h"
|
||||||
#include "nvim/ex_cmds_defs.h"
|
#include "nvim/ex_cmds_defs.h"
|
||||||
|
#include "nvim/func_attr.h"
|
||||||
#include "nvim/lua/converter.h"
|
#include "nvim/lua/converter.h"
|
||||||
|
|
||||||
// Generated by msgpack-gen.lua
|
// Generated by msgpack-gen.lua
|
||||||
@@ -19,12 +19,12 @@ EXTERN LuaRef nlua_empty_dict_ref INIT(= LUA_NOREF);
|
|||||||
EXTERN int nlua_refcount INIT(= 0);
|
EXTERN int nlua_refcount INIT(= 0);
|
||||||
|
|
||||||
#define set_api_error(s, err) \
|
#define set_api_error(s, err) \
|
||||||
do { \
|
do { \
|
||||||
Error *err_ = (err); \
|
Error *err_ = (err); \
|
||||||
err_->type = kErrorTypeException; \
|
err_->type = kErrorTypeException; \
|
||||||
err_->set = true; \
|
err_->set = true; \
|
||||||
memcpy(&err_->msg[0], s, sizeof(s)); \
|
memcpy(&err_->msg[0], s, sizeof(s)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define NLUA_CLEAR_REF(x) \
|
#define NLUA_CLEAR_REF(x) \
|
||||||
do { \
|
do { \
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
#ifndef NVIM_LUA_TREESITTER_H
|
#ifndef NVIM_LUA_TREESITTER_H
|
||||||
#define NVIM_LUA_TREESITTER_H
|
#define NVIM_LUA_TREESITTER_H
|
||||||
|
|
||||||
|
#include <lauxlib.h>
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#include "tree_sitter/api.h"
|
#include "tree_sitter/api.h"
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
#ifndef NVIM_LUA_XDIFF_H
|
#ifndef NVIM_LUA_XDIFF_H
|
||||||
#define NVIM_LUA_XDIFF_H
|
#define NVIM_LUA_XDIFF_H
|
||||||
|
|
||||||
|
#include <lauxlib.h>
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "lua/xdiff.h.generated.h"
|
# include "lua/xdiff.h.generated.h"
|
||||||
|
@@ -5,10 +5,10 @@
|
|||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/event/socket.h"
|
|
||||||
#include "nvim/event/process.h"
|
|
||||||
#include "nvim/vim.h"
|
|
||||||
#include "nvim/channel.h"
|
#include "nvim/channel.h"
|
||||||
|
#include "nvim/event/process.h"
|
||||||
|
#include "nvim/event/socket.h"
|
||||||
|
#include "nvim/vim.h"
|
||||||
|
|
||||||
#define METHOD_MAXLEN 512
|
#define METHOD_MAXLEN 512
|
||||||
|
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
#ifndef NVIM_MSGPACK_RPC_CHANNEL_DEFS_H
|
#ifndef NVIM_MSGPACK_RPC_CHANNEL_DEFS_H
|
||||||
#define NVIM_MSGPACK_RPC_CHANNEL_DEFS_H
|
#define NVIM_MSGPACK_RPC_CHANNEL_DEFS_H
|
||||||
|
|
||||||
|
#include <msgpack.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
#include <msgpack.h>
|
|
||||||
|
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/event/socket.h"
|
|
||||||
#include "nvim/event/process.h"
|
#include "nvim/event/process.h"
|
||||||
|
#include "nvim/event/socket.h"
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
|
|
||||||
typedef struct Channel Channel;
|
typedef struct Channel Channel;
|
||||||
|
@@ -1,13 +1,12 @@
|
|||||||
#ifndef NVIM_MSGPACK_RPC_HELPERS_H
|
#ifndef NVIM_MSGPACK_RPC_HELPERS_H
|
||||||
#define NVIM_MSGPACK_RPC_HELPERS_H
|
#define NVIM_MSGPACK_RPC_HELPERS_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include <msgpack.h>
|
#include <msgpack.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "nvim/event/wstream.h"
|
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
|
#include "nvim/event/wstream.h"
|
||||||
|
|
||||||
/// Value by which objects represented as EXT type are shifted
|
/// Value by which objects represented as EXT type are shifted
|
||||||
///
|
///
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
#ifndef NVIM_OS_INPUT_H
|
#ifndef NVIM_OS_INPUT_H
|
||||||
#define NVIM_OS_INPUT_H
|
#define NVIM_OS_INPUT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/event/multiqueue.h"
|
#include "nvim/event/multiqueue.h"
|
||||||
|
@@ -9,11 +9,11 @@
|
|||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
# include "os/env.h.generated.h"
|
||||||
# include "os/fs.h.generated.h"
|
# include "os/fs.h.generated.h"
|
||||||
# include "os/mem.h.generated.h"
|
# include "os/mem.h.generated.h"
|
||||||
# include "os/env.h.generated.h"
|
|
||||||
# include "os/users.h.generated.h"
|
|
||||||
# include "os/stdpaths.h.generated.h"
|
# include "os/stdpaths.h.generated.h"
|
||||||
|
# include "os/users.h.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // NVIM_OS_OS_H
|
#endif // NVIM_OS_OS_H
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
#define BASENAMELEN (NAME_MAX - 5)
|
#define BASENAMELEN (NAME_MAX - 5)
|
||||||
|
|
||||||
// Use the system path length if it makes sense.
|
// Use the system path length if it makes sense.
|
||||||
# define DEFAULT_MAXPATHL 4096
|
#define DEFAULT_MAXPATHL 4096
|
||||||
#if defined(PATH_MAX) && (PATH_MAX > DEFAULT_MAXPATHL)
|
#if defined(PATH_MAX) && (PATH_MAX > DEFAULT_MAXPATHL)
|
||||||
# define MAXPATHL PATH_MAX
|
# define MAXPATHL PATH_MAX
|
||||||
#else
|
#else
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#define NVIM_OS_PROCESS_H
|
#define NVIM_OS_PROCESS_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
#ifndef NVIM_OS_TIME_H
|
#ifndef NVIM_OS_TIME_H
|
||||||
#define NVIM_OS_TIME_H
|
#define NVIM_OS_TIME_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
typedef uint64_t Timestamp;
|
typedef uint64_t Timestamp;
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
#ifndef NVIM_OS_UNIX_DEFS_H
|
#ifndef NVIM_OS_UNIX_DEFS_H
|
||||||
#define NVIM_OS_UNIX_DEFS_H
|
#define NVIM_OS_UNIX_DEFS_H
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
// POSIX.1-2008 says that NAME_MAX should be in here
|
// POSIX.1-2008 says that NAME_MAX should be in here
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
@@ -7,11 +7,14 @@
|
|||||||
|
|
||||||
// winsock2.h must be first to avoid incompatibilities
|
// winsock2.h must be first to avoid incompatibilities
|
||||||
// with winsock.h (included by windows.h)
|
// with winsock.h (included by windows.h)
|
||||||
|
|
||||||
|
// uncrustify:off
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
// uncrustify:on
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
// Windows does not have S_IFLNK but libuv defines it
|
// Windows does not have S_IFLNK but libuv defines it
|
||||||
// and sets the flag for us when calling uv_fs_stat.
|
// and sets the flag for us when calling uv_fs_stat.
|
||||||
|
@@ -332,8 +332,8 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
|
|||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void push_path(RuntimeSearchPath *search_path, Map(String, handle_T) *rtp_used,
|
static void push_path(RuntimeSearchPath *search_path, Map(String, handle_T) *rtp_used, char *entry,
|
||||||
char *entry, bool after)
|
bool after)
|
||||||
{
|
{
|
||||||
handle_T h = map_get(String, handle_T)(rtp_used, cstr_as_string(entry));
|
handle_T h = map_get(String, handle_T)(rtp_used, cstr_as_string(entry));
|
||||||
if (h == 0) {
|
if (h == 0) {
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
#define NVIM_TUI_INPUT_H
|
#define NVIM_TUI_INPUT_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <termkey.h>
|
#include <termkey.h>
|
||||||
|
|
||||||
#include "nvim/event/stream.h"
|
#include "nvim/event/stream.h"
|
||||||
#include "nvim/event/time.h"
|
#include "nvim/event/time.h"
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -1,13 +1,13 @@
|
|||||||
#ifndef NVIM_VIML_PARSER_EXPRESSIONS_H
|
#ifndef NVIM_VIML_PARSER_EXPRESSIONS_H
|
||||||
#define NVIM_VIML_PARSER_EXPRESSIONS_H
|
#define NVIM_VIML_PARSER_EXPRESSIONS_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
|
#include "nvim/eval/typval.h"
|
||||||
#include "nvim/types.h"
|
#include "nvim/types.h"
|
||||||
#include "nvim/viml/parser/parser.h"
|
#include "nvim/viml/parser/parser.h"
|
||||||
#include "nvim/eval/typval.h"
|
|
||||||
|
|
||||||
// Defines whether to ignore case:
|
// Defines whether to ignore case:
|
||||||
// == kCCStrategyUseOption
|
// == kCCStrategyUseOption
|
||||||
@@ -80,7 +80,7 @@ typedef enum {
|
|||||||
} ExprAssignmentType;
|
} ExprAssignmentType;
|
||||||
|
|
||||||
#define EXPR_OPT_SCOPE_LIST \
|
#define EXPR_OPT_SCOPE_LIST \
|
||||||
((char[]){ kExprOptScopeGlobal, kExprOptScopeLocal })
|
((char[]){ kExprOptScopeGlobal, kExprOptScopeLocal })
|
||||||
|
|
||||||
/// All possible variable scopes
|
/// All possible variable scopes
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -96,11 +96,11 @@ typedef enum {
|
|||||||
} ExprVarScope;
|
} ExprVarScope;
|
||||||
|
|
||||||
#define EXPR_VAR_SCOPE_LIST \
|
#define EXPR_VAR_SCOPE_LIST \
|
||||||
((char[]) { \
|
((char[]) { \
|
||||||
kExprVarScopeScript, kExprVarScopeGlobal, kExprVarScopeVim, \
|
kExprVarScopeScript, kExprVarScopeGlobal, kExprVarScopeVim, \
|
||||||
kExprVarScopeBuffer, kExprVarScopeWindow, kExprVarScopeTabpage, \
|
kExprVarScopeBuffer, kExprVarScopeWindow, kExprVarScopeTabpage, \
|
||||||
kExprVarScopeLocal, kExprVarScopeBuffer, kExprVarScopeArguments, \
|
kExprVarScopeLocal, kExprVarScopeBuffer, kExprVarScopeArguments, \
|
||||||
})
|
})
|
||||||
|
|
||||||
/// Lexer token
|
/// Lexer token
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
#ifndef NVIM_VIML_PARSER_PARSER_H
|
#ifndef NVIM_VIML_PARSER_PARSER_H
|
||||||
#define NVIM_VIML_PARSER_PARSER_H
|
#define NVIM_VIML_PARSER_PARSER_H
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "nvim/lib/kvec.h"
|
|
||||||
#include "nvim/func_attr.h"
|
#include "nvim/func_attr.h"
|
||||||
|
#include "nvim/lib/kvec.h"
|
||||||
#include "nvim/mbyte.h"
|
#include "nvim/mbyte.h"
|
||||||
#include "nvim/memory.h"
|
#include "nvim/memory.h"
|
||||||
|
|
||||||
@@ -82,9 +82,9 @@ typedef struct {
|
|||||||
} ParserState;
|
} ParserState;
|
||||||
|
|
||||||
static inline void viml_parser_init(
|
static inline void viml_parser_init(
|
||||||
ParserState *const ret_pstate,
|
ParserState *const ret_pstate,
|
||||||
const ParserLineGetter get_line, void *const cookie,
|
const ParserLineGetter get_line, void *const cookie,
|
||||||
ParserHighlight *const colors)
|
ParserHighlight *const colors)
|
||||||
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ARG(1, 2);
|
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ARG(1, 2);
|
||||||
|
|
||||||
/// Initialize a new parser state instance
|
/// Initialize a new parser state instance
|
||||||
@@ -94,10 +94,8 @@ static inline void viml_parser_init(
|
|||||||
/// @param[in] cookie Argument for the get_line function.
|
/// @param[in] cookie Argument for the get_line function.
|
||||||
/// @param[in] colors Where to save highlighting. May be NULL if it is not
|
/// @param[in] colors Where to save highlighting. May be NULL if it is not
|
||||||
/// needed.
|
/// needed.
|
||||||
static inline void viml_parser_init(
|
static inline void viml_parser_init(ParserState *const ret_pstate, const ParserLineGetter get_line,
|
||||||
ParserState *const ret_pstate,
|
void *const cookie, ParserHighlight *const colors)
|
||||||
const ParserLineGetter get_line, void *const cookie,
|
|
||||||
ParserHighlight *const colors)
|
|
||||||
{
|
{
|
||||||
*ret_pstate = (ParserState) {
|
*ret_pstate = (ParserState) {
|
||||||
.reader = {
|
.reader = {
|
||||||
@@ -194,8 +192,7 @@ static inline void viml_parser_advance(ParserState *const pstate,
|
|||||||
///
|
///
|
||||||
/// @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,
|
static inline void viml_parser_advance(ParserState *const pstate, const size_t len)
|
||||||
const size_t len)
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
@@ -219,10 +216,8 @@ static inline void viml_parser_highlight(ParserState *const pstate,
|
|||||||
/// @param[in] start Start position of the highlight.
|
/// @param[in] start Start position of the highlight.
|
||||||
/// @param[in] len Highlighting chunk length.
|
/// @param[in] len Highlighting chunk length.
|
||||||
/// @param[in] group Highlight group.
|
/// @param[in] group Highlight group.
|
||||||
static inline void viml_parser_highlight(ParserState *const pstate,
|
static inline void viml_parser_highlight(ParserState *const pstate, const ParserPosition start,
|
||||||
const ParserPosition start,
|
const size_t len, const char *const group)
|
||||||
const size_t len,
|
|
||||||
const char *const group)
|
|
||||||
{
|
{
|
||||||
if (pstate->colors == NULL || len == 0) {
|
if (pstate->colors == NULL || len == 0) {
|
||||||
return;
|
return;
|
||||||
@@ -231,9 +226,9 @@ static inline void viml_parser_highlight(ParserState *const pstate,
|
|||||||
|| kv_Z(*pstate->colors, 0).start.line < start.line
|
|| kv_Z(*pstate->colors, 0).start.line < start.line
|
||||||
|| kv_Z(*pstate->colors, 0).end_col <= start.col);
|
|| kv_Z(*pstate->colors, 0).end_col <= start.col);
|
||||||
kvi_push(*pstate->colors, ((ParserHighlightChunk) {
|
kvi_push(*pstate->colors, ((ParserHighlightChunk) {
|
||||||
.start = start,
|
.start = start,
|
||||||
.end_col = start.col + len,
|
.end_col = start.col + len,
|
||||||
.group = group,
|
.group = group,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Uncrustify-0.73.0-195-1f883c691
|
# Uncrustify-0.73.0-199-0dfafb273
|
||||||
|
|
||||||
#
|
#
|
||||||
# General options
|
# General options
|
||||||
@@ -44,12 +44,12 @@ disable_processing_nl_cont = false # true/false
|
|||||||
# file.
|
# file.
|
||||||
#
|
#
|
||||||
# Default: *INDENT-OFF*
|
# Default: *INDENT-OFF*
|
||||||
disable_processing_cmt = "uncrustify:indent-off" # string
|
disable_processing_cmt = "uncrustify:off" # string
|
||||||
|
|
||||||
# Specify the marker used in comments to (re)enable processing in a file.
|
# Specify the marker used in comments to (re)enable processing in a file.
|
||||||
#
|
#
|
||||||
# Default: *INDENT-ON*
|
# Default: *INDENT-ON*
|
||||||
enable_processing_cmt = "uncrustify:indent-on" # string
|
enable_processing_cmt = "uncrustify:on" # string
|
||||||
|
|
||||||
# Enable parsing of digraphs.
|
# Enable parsing of digraphs.
|
||||||
enable_digraphs = false # true/false
|
enable_digraphs = false # true/false
|
||||||
@@ -472,9 +472,13 @@ sp_after_class_colon = ignore # ignore/add/remove/force/not_defined
|
|||||||
sp_before_class_colon = ignore # ignore/add/remove/force/not_defined
|
sp_before_class_colon = ignore # ignore/add/remove/force/not_defined
|
||||||
|
|
||||||
# Add or remove space after class constructor ':'.
|
# Add or remove space after class constructor ':'.
|
||||||
|
#
|
||||||
|
# Default: add
|
||||||
sp_after_constr_colon = ignore # ignore/add/remove/force/not_defined
|
sp_after_constr_colon = ignore # ignore/add/remove/force/not_defined
|
||||||
|
|
||||||
# Add or remove space before class constructor ':'.
|
# Add or remove space before class constructor ':'.
|
||||||
|
#
|
||||||
|
# Default: add
|
||||||
sp_before_constr_colon = ignore # ignore/add/remove/force/not_defined
|
sp_before_constr_colon = ignore # ignore/add/remove/force/not_defined
|
||||||
|
|
||||||
# Add or remove space before case ':'.
|
# Add or remove space before case ':'.
|
||||||
@@ -1103,11 +1107,16 @@ indent_class_on_colon = false # true/false
|
|||||||
# Whether to indent the stuff after a leading class initializer colon.
|
# Whether to indent the stuff after a leading class initializer colon.
|
||||||
indent_constr_colon = false # true/false
|
indent_constr_colon = false # true/false
|
||||||
|
|
||||||
# Virtual indent from the ':' for member initializers.
|
# Virtual indent from the ':' for leading member initializers.
|
||||||
#
|
#
|
||||||
# Default: 2
|
# Default: 2
|
||||||
indent_ctor_init_leading = 2 # unsigned number
|
indent_ctor_init_leading = 2 # unsigned number
|
||||||
|
|
||||||
|
# Virtual indent from the ':' for following member initializers.
|
||||||
|
#
|
||||||
|
# Default: 2
|
||||||
|
indent_ctor_init_following = 2 # unsigned number
|
||||||
|
|
||||||
# Additional indent for constructor initializer list.
|
# Additional indent for constructor initializer list.
|
||||||
# Negative values decrease indent down to the first column.
|
# Negative values decrease indent down to the first column.
|
||||||
indent_ctor_init = 0 # number
|
indent_ctor_init = 0 # number
|
||||||
@@ -3298,5 +3307,5 @@ set QUESTION REAL_FATTR_CONST
|
|||||||
set QUESTION REAL_FATTR_NONNULL_ALL
|
set QUESTION REAL_FATTR_NONNULL_ALL
|
||||||
set QUESTION REAL_FATTR_PURE
|
set QUESTION REAL_FATTR_PURE
|
||||||
set QUESTION REAL_FATTR_WARN_UNUSED_RESULT
|
set QUESTION REAL_FATTR_WARN_UNUSED_RESULT
|
||||||
# option(s) with 'not default' value: 62
|
# option(s) with 'not default' value: 64
|
||||||
#
|
#
|
||||||
|
Reference in New Issue
Block a user