diff options
Diffstat (limited to 'src/nvim/eval')
-rw-r--r-- | src/nvim/eval/encode.c | 4 | ||||
-rw-r--r-- | src/nvim/eval/typval.c | 46 | ||||
-rw-r--r-- | src/nvim/eval/typval.h | 11 | ||||
-rw-r--r-- | src/nvim/eval/typval_encode.c.h | 1 |
4 files changed, 32 insertions, 30 deletions
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 9bae436e3d..2563e38258 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -609,14 +609,14 @@ static inline int convert_to_json_string(garray_T *const gap, if (ch > 0x7F && shift == 1) { emsgf(_("E474: String \"%.*s\" contains byte that does not start " "any UTF-8 character"), - utf_len - (i - shift), utf_buf + i - shift); + (int)(utf_len - (i - shift)), utf_buf + i - shift); xfree(tofree); return FAIL; } else if ((SURROGATE_HI_START <= ch && ch <= SURROGATE_HI_END) || (SURROGATE_LO_START <= ch && ch <= SURROGATE_LO_END)) { emsgf(_("E474: UTF-8 string contains code point which belongs " "to a surrogate pair: %.*s"), - utf_len - (i - shift), utf_buf + i - shift); + (int)(utf_len - (i - shift)), utf_buf + i - shift); xfree(tofree); return FAIL; } else if (ENCODE_RAW(ch)) { diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index b151357196..6a93b20345 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -991,7 +991,7 @@ const char *tv_list_find_str(list_T *const l, const int n) { const listitem_T *const li = tv_list_find(l, n); if (li == NULL) { - emsgf(_(e_listidx), (int64_t)n); + EMSG2(_(e_listidx), (int64_t)n); return NULL; } return tv_get_string(TV_LIST_ITEM_TV(li)); @@ -1532,7 +1532,7 @@ bool tv_dict_get_callback(dict_T *const d, } if (!tv_is_func(di->di_tv) && di->di_tv.v_type != VAR_STRING) { - emsgf(_("E6000: Argument is not a function or function name")); + EMSG(_("E6000: Argument is not a function or function name")); return false; } @@ -2298,7 +2298,7 @@ void tv_item_lock(typval_T *const tv, const int deep, const bool lock) static int recurse = 0; if (recurse >= DICT_MAXNEST) { - emsgf(_("E743: variable nested too deep for (un)lock")); + EMSG(_("E743: variable nested too deep for (un)lock")); return; } if (deep == 0) { @@ -2546,28 +2546,28 @@ bool tv_check_str_or_nr(const typval_T *const tv) return true; } case VAR_FLOAT: { - emsgf(_("E805: Expected a Number or a String, Float found")); + EMSG(_("E805: Expected a Number or a String, Float found")); return false; } case VAR_PARTIAL: case VAR_FUNC: { - emsgf(_("E703: Expected a Number or a String, Funcref found")); + EMSG(_("E703: Expected a Number or a String, Funcref found")); return false; } case VAR_LIST: { - emsgf(_("E745: Expected a Number or a String, List found")); + EMSG(_("E745: Expected a Number or a String, List found")); return false; } case VAR_DICT: { - emsgf(_("E728: Expected a Number or a String, Dictionary found")); + EMSG(_("E728: Expected a Number or a String, Dictionary found")); return false; } case VAR_SPECIAL: { - emsgf(_("E5300: Expected a Number or a String")); + EMSG(_("E5300: Expected a Number or a String")); return false; } case VAR_UNKNOWN: { - emsgf(_(e_intern2), "tv_check_str_or_nr(UNKNOWN)"); + EMSG2(_(e_intern2), "tv_check_str_or_nr(UNKNOWN)"); return false; } } @@ -2611,7 +2611,7 @@ bool tv_check_num(const typval_T *const tv) case VAR_DICT: case VAR_FLOAT: case VAR_UNKNOWN: { - emsgf(_(num_errors[tv->v_type])); + EMSG(_(num_errors[tv->v_type])); return false; } } @@ -2632,7 +2632,7 @@ static const char *const str_errors[] = { #undef FUNC_ERROR -/// Check that given value is a string or can be converted to it +/// Check that given value is a VimL String or can be "cast" to it. /// /// Error messages are compatible with tv_get_string_chk() previously used for /// the same purpose. @@ -2655,7 +2655,7 @@ bool tv_check_str(const typval_T *const tv) case VAR_DICT: case VAR_FLOAT: case VAR_UNKNOWN: { - emsgf(_(str_errors[tv->v_type])); + EMSG(_(str_errors[tv->v_type])); return false; } } @@ -2702,7 +2702,7 @@ varnumber_T tv_get_number_chk(const typval_T *const tv, bool *const ret_error) case VAR_LIST: case VAR_DICT: case VAR_FLOAT: { - emsgf(_(num_errors[tv->v_type])); + EMSG(_(num_errors[tv->v_type])); break; } case VAR_NUMBER: { @@ -2778,23 +2778,23 @@ float_T tv_get_float(const typval_T *const tv) } case VAR_PARTIAL: case VAR_FUNC: { - emsgf(_("E891: Using a Funcref as a Float")); + EMSG(_("E891: Using a Funcref as a Float")); break; } case VAR_STRING: { - emsgf(_("E892: Using a String as a Float")); + EMSG(_("E892: Using a String as a Float")); break; } case VAR_LIST: { - emsgf(_("E893: Using a List as a Float")); + EMSG(_("E893: Using a List as a Float")); break; } case VAR_DICT: { - emsgf(_("E894: Using a Dictionary as a Float")); + EMSG(_("E894: Using a Dictionary as a Float")); break; } case VAR_SPECIAL: { - emsgf(_("E907: Using a special value as a Float")); + EMSG(_("E907: Using a special value as a Float")); break; } case VAR_UNKNOWN: { @@ -2805,7 +2805,7 @@ float_T tv_get_float(const typval_T *const tv) return 0; } -/// Get the string value of a VimL object +/// Get the string value of a "stringish" VimL object. /// /// @param[in] tv Object to get value of. /// @param buf Buffer used to hold numbers and special variables converted to @@ -2840,14 +2840,14 @@ const char *tv_get_string_buf_chk(const typval_T *const tv, char *const buf) case VAR_DICT: case VAR_FLOAT: case VAR_UNKNOWN: { - emsgf(_(str_errors[tv->v_type])); + EMSG(_(str_errors[tv->v_type])); return false; } } return NULL; } -/// Get the string value of a VimL object +/// Get the string value of a "stringish" VimL object. /// /// @warning For number and special values it uses a single, static buffer. It /// may be used only once, next call to get_tv_string may reuse it. Use @@ -2866,7 +2866,7 @@ const char *tv_get_string_chk(const typval_T *const tv) return tv_get_string_buf_chk(tv, mybuf); } -/// Get the string value of a VimL object +/// Get the string value of a "stringish" VimL object. /// /// @warning For number and special values it uses a single, static buffer. It /// may be used only once, next call to get_tv_string may reuse it. Use @@ -2888,7 +2888,7 @@ const char *tv_get_string(const typval_T *const tv) return tv_get_string_buf((typval_T *)tv, mybuf); } -/// Get the string value of a VimL object +/// Get the string value of a "stringish" VimL object. /// /// @note tv_get_string_chk() and tv_get_string_buf_chk() are similar, but /// return NULL on error. diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 664bf7332c..e99289c430 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -162,19 +162,20 @@ struct listwatch_S { }; /// Structure to hold info about a list +/// Order of members is optimized to reduce padding. struct listvar_S { listitem_T *lv_first; ///< First item, NULL if none. listitem_T *lv_last; ///< Last item, NULL if none. - int lv_refcount; ///< Reference count. - int lv_len; ///< Number of items. listwatch_T *lv_watch; ///< First watcher, NULL if none. - int lv_idx; ///< Index of a cached item, used for optimising repeated l[idx]. listitem_T *lv_idx_item; ///< When not NULL item at index "lv_idx". - int lv_copyID; ///< ID used by deepcopy(). list_T *lv_copylist; ///< Copied list used by deepcopy(). - VarLockStatus lv_lock; ///< Zero, VAR_LOCKED, VAR_FIXED. list_T *lv_used_next; ///< next list in used lists list. list_T *lv_used_prev; ///< Previous list in used lists list. + int lv_refcount; ///< Reference count. + int lv_len; ///< Number of items. + int lv_idx; ///< Index of a cached item, used for optimising repeated l[idx]. + int lv_copyID; ///< ID used by deepcopy(). + VarLockStatus lv_lock; ///< Zero, VAR_LOCKED, VAR_FIXED. }; // Static list with 10 items. Use tv_list_init_static10() to initialize. diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h index 4556ce8193..623bdfc93b 100644 --- a/src/nvim/eval/typval_encode.c.h +++ b/src/nvim/eval/typval_encode.c.h @@ -741,6 +741,7 @@ typval_encode_stop_converting_one_item: case kMPConvPartial: { partial_T *const pt = cur_mpsv->data.p.pt; tv = cur_mpsv->tv; + (void)tv; switch (cur_mpsv->data.p.stage) { case kMPConvPartialArgs: { TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, |