mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 06:16:08 +00:00
*: Hide list implementation in other files as well
This commit is contained in:
@@ -120,7 +120,7 @@ static inline int json_decoder_pop(ValuesStackItem obj,
|
||||
last_container = kv_last(*container_stack);
|
||||
}
|
||||
if (last_container.container.v_type == VAR_LIST) {
|
||||
if (last_container.container.vval.v_list->lv_len != 0
|
||||
if (tv_list_len(last_container.container.vval.v_list) != 0
|
||||
&& !obj.didcomma) {
|
||||
EMSG2(_("E474: Expected comma before list item: %s"), val_location);
|
||||
tv_clear(&obj.val);
|
||||
@@ -128,7 +128,7 @@ static inline int json_decoder_pop(ValuesStackItem obj,
|
||||
}
|
||||
assert(last_container.special_val == NULL);
|
||||
listitem_T *obj_li = tv_list_item_alloc();
|
||||
obj_li->li_tv = obj.val;
|
||||
*TV_LIST_ITEM_TV(obj_li) = obj.val;
|
||||
tv_list_append(last_container.container.vval.v_list, obj_li);
|
||||
} else if (last_container.stack_index == kv_size(*stack) - 2) {
|
||||
if (!obj.didcolon) {
|
||||
@@ -155,10 +155,10 @@ static inline int json_decoder_pop(ValuesStackItem obj,
|
||||
list_T *const kv_pair = tv_list_alloc();
|
||||
tv_list_append_list(last_container.special_val, kv_pair);
|
||||
listitem_T *const key_li = tv_list_item_alloc();
|
||||
key_li->li_tv = key.val;
|
||||
*TV_LIST_ITEM_TV(key_li) = key.val;
|
||||
tv_list_append(kv_pair, key_li);
|
||||
listitem_T *const val_li = tv_list_item_alloc();
|
||||
val_li->li_tv = obj.val;
|
||||
*TV_LIST_ITEM_TV(val_li) = obj.val;
|
||||
tv_list_append(kv_pair, val_li);
|
||||
}
|
||||
} else {
|
||||
@@ -738,8 +738,9 @@ json_decode_string_cycle_start:
|
||||
} else if (last_container.special_val == NULL
|
||||
? (last_container.container.v_type == VAR_DICT
|
||||
? (DICT_LEN(last_container.container.vval.v_dict) == 0)
|
||||
: (last_container.container.vval.v_list->lv_len == 0))
|
||||
: (last_container.special_val->lv_len == 0)) {
|
||||
: (tv_list_len(last_container.container.vval.v_list)
|
||||
== 0))
|
||||
: (tv_list_len(last_container.special_val) == 0)) {
|
||||
emsgf(_("E474: Leading comma: %.*s"), LENP(p, e));
|
||||
goto json_decode_string_fail;
|
||||
}
|
||||
@@ -1047,9 +1048,10 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv)
|
||||
};
|
||||
for (size_t i = 0; i < mobj.via.array.size; i++) {
|
||||
listitem_T *const li = tv_list_item_alloc();
|
||||
li->li_tv.v_type = VAR_UNKNOWN;
|
||||
TV_LIST_ITEM_TV(li)->v_type = VAR_UNKNOWN;
|
||||
tv_list_append(list, li);
|
||||
if (msgpack_to_vim(mobj.via.array.ptr[i], &li->li_tv) == FAIL) {
|
||||
if (msgpack_to_vim(mobj.via.array.ptr[i], TV_LIST_ITEM_TV(li))
|
||||
== FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@@ -1094,15 +1096,17 @@ msgpack_to_vim_generic_map: {}
|
||||
list_T *const kv_pair = tv_list_alloc();
|
||||
tv_list_append_list(list, kv_pair);
|
||||
listitem_T *const key_li = tv_list_item_alloc();
|
||||
key_li->li_tv.v_type = VAR_UNKNOWN;
|
||||
TV_LIST_ITEM_TV(key_li)->v_type = VAR_UNKNOWN;
|
||||
tv_list_append(kv_pair, key_li);
|
||||
listitem_T *const val_li = tv_list_item_alloc();
|
||||
val_li->li_tv.v_type = VAR_UNKNOWN;
|
||||
TV_LIST_ITEM_TV(val_li)->v_type = VAR_UNKNOWN;
|
||||
tv_list_append(kv_pair, val_li);
|
||||
if (msgpack_to_vim(mobj.via.map.ptr[i].key, &key_li->li_tv) == FAIL) {
|
||||
if (msgpack_to_vim(mobj.via.map.ptr[i].key, TV_LIST_ITEM_TV(key_li))
|
||||
== FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
if (msgpack_to_vim(mobj.via.map.ptr[i].val, &val_li->li_tv) == FAIL) {
|
||||
if (msgpack_to_vim(mobj.via.map.ptr[i].val, TV_LIST_ITEM_TV(val_li))
|
||||
== FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
@@ -53,17 +53,18 @@ int encode_list_write(void *const data, const char *const buf, const size_t len)
|
||||
list_T *const list = (list_T *) data;
|
||||
const char *const end = buf + len;
|
||||
const char *line_end = buf;
|
||||
listitem_T *li = list->lv_last;
|
||||
listitem_T *li = tv_list_last(list);
|
||||
|
||||
// Continue the last list element
|
||||
if (li != NULL) {
|
||||
line_end = xmemscan(buf, NL, len);
|
||||
if (line_end != buf) {
|
||||
const size_t line_length = (size_t)(line_end - buf);
|
||||
char *str = (char *)li->li_tv.vval.v_string;
|
||||
char *str = (char *)TV_LIST_ITEM_TV(li)->vval.v_string;
|
||||
const size_t li_len = (str == NULL ? 0 : strlen(str));
|
||||
li->li_tv.vval.v_string = xrealloc(str, li_len + line_length + 1);
|
||||
str = (char *)li->li_tv.vval.v_string + li_len;
|
||||
TV_LIST_ITEM_TV(li)->vval.v_string = xrealloc(
|
||||
str, li_len + line_length + 1);
|
||||
str = (char *)TV_LIST_ITEM_TV(li)->vval.v_string + li_len;
|
||||
memcpy(str, buf, line_length);
|
||||
str[line_length] = 0;
|
||||
memchrsub(str, NUL, NL, line_length);
|
||||
@@ -135,21 +136,18 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
|
||||
}
|
||||
case kMPConvPairs:
|
||||
case kMPConvList: {
|
||||
int idx = 0;
|
||||
const listitem_T *li;
|
||||
for (li = v.data.l.list->lv_first;
|
||||
li != NULL && li->li_next != v.data.l.li;
|
||||
li = li->li_next) {
|
||||
idx++;
|
||||
}
|
||||
const listitem_T *const li = TV_LIST_ITEM_PREV(v.data.l.list,
|
||||
v.data.l.li);
|
||||
int idx = (int)tv_list_idx_of_item(v.data.l.list, li);
|
||||
if (v.type == kMPConvList
|
||||
|| li == NULL
|
||||
|| (li->li_tv.v_type != VAR_LIST
|
||||
&& li->li_tv.vval.v_list->lv_len <= 0)) {
|
||||
vim_snprintf((char *) IObuff, IOSIZE, idx_msg, idx);
|
||||
|| (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST
|
||||
&& tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) <= 0)) {
|
||||
vim_snprintf((char *)IObuff, IOSIZE, idx_msg, idx);
|
||||
ga_concat(&msg_ga, IObuff);
|
||||
} else {
|
||||
typval_T key_tv = li->li_tv.vval.v_list->lv_first->li_tv;
|
||||
typval_T key_tv = *TV_LIST_ITEM_TV(
|
||||
tv_list_first(TV_LIST_ITEM_TV(li)->vval.v_list));
|
||||
char *const key = encode_tv2echo(&key_tv, NULL);
|
||||
vim_snprintf((char *) IObuff, IOSIZE, key_pair_msg, key, idx);
|
||||
xfree(key);
|
||||
@@ -202,21 +200,17 @@ bool encode_vim_list_to_buf(const list_T *const list, size_t *const ret_len,
|
||||
FUNC_ATTR_NONNULL_ARG(2, 3) FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
size_t len = 0;
|
||||
if (list != NULL) {
|
||||
for (const listitem_T *li = list->lv_first;
|
||||
li != NULL;
|
||||
li = li->li_next) {
|
||||
if (li->li_tv.v_type != VAR_STRING) {
|
||||
return false;
|
||||
}
|
||||
len++;
|
||||
if (li->li_tv.vval.v_string != 0) {
|
||||
len += STRLEN(li->li_tv.vval.v_string);
|
||||
}
|
||||
TV_LIST_ITER_CONST(list, li, {
|
||||
if (TV_LIST_ITEM_TV(li)->v_type != VAR_STRING) {
|
||||
return false;
|
||||
}
|
||||
if (len) {
|
||||
len--;
|
||||
len++;
|
||||
if (TV_LIST_ITEM_TV(li)->vval.v_string != 0) {
|
||||
len += STRLEN(TV_LIST_ITEM_TV(li)->vval.v_string);
|
||||
}
|
||||
});
|
||||
if (len) {
|
||||
len--;
|
||||
}
|
||||
*ret_len = len;
|
||||
if (len == 0) {
|
||||
@@ -253,31 +247,34 @@ int encode_read_from_list(ListReaderState *const state, char *const buf,
|
||||
char *const buf_end = buf + nbuf;
|
||||
char *p = buf;
|
||||
while (p < buf_end) {
|
||||
assert(state->li_length == 0 || state->li->li_tv.vval.v_string != NULL);
|
||||
assert(state->li_length == 0
|
||||
|| TV_LIST_ITEM_TV(state->li)->vval.v_string != NULL);
|
||||
for (size_t i = state->offset; i < state->li_length && p < buf_end; i++) {
|
||||
assert(state->li->li_tv.vval.v_string != NULL);
|
||||
const char ch = (char)state->li->li_tv.vval.v_string[state->offset++];
|
||||
assert(TV_LIST_ITEM_TV(state->li)->vval.v_string != NULL);
|
||||
const char ch = (char)(
|
||||
TV_LIST_ITEM_TV(state->li)->vval.v_string[state->offset++]);
|
||||
*p++ = (char)((char)ch == (char)NL ? (char)NUL : (char)ch);
|
||||
}
|
||||
if (p < buf_end) {
|
||||
state->li = state->li->li_next;
|
||||
state->li = TV_LIST_ITEM_NEXT(state->list, state->li);
|
||||
if (state->li == NULL) {
|
||||
*read_bytes = (size_t) (p - buf);
|
||||
return OK;
|
||||
}
|
||||
*p++ = NL;
|
||||
if (state->li->li_tv.v_type != VAR_STRING) {
|
||||
if (TV_LIST_ITEM_TV(state->li)->v_type != VAR_STRING) {
|
||||
*read_bytes = (size_t) (p - buf);
|
||||
return FAIL;
|
||||
}
|
||||
state->offset = 0;
|
||||
state->li_length = (state->li->li_tv.vval.v_string == NULL
|
||||
state->li_length = (TV_LIST_ITEM_TV(state->li)->vval.v_string == NULL
|
||||
? 0
|
||||
: STRLEN(state->li->li_tv.vval.v_string));
|
||||
: STRLEN(TV_LIST_ITEM_TV(state->li)->vval.v_string));
|
||||
}
|
||||
}
|
||||
*read_bytes = nbuf;
|
||||
return (state->offset < state->li_length || state->li->li_next != NULL
|
||||
return ((state->offset < state->li_length
|
||||
|| TV_LIST_ITEM_NEXT(state->list, state->li) != NULL)
|
||||
? NOTDONE
|
||||
: OK);
|
||||
}
|
||||
@@ -727,12 +724,11 @@ bool encode_check_json_key(const typval_T *const tv)
|
||||
if (val_di->di_tv.vval.v_list == NULL) {
|
||||
return true;
|
||||
}
|
||||
for (const listitem_T *li = val_di->di_tv.vval.v_list->lv_first;
|
||||
li != NULL; li = li->li_next) {
|
||||
if (li->li_tv.v_type != VAR_STRING) {
|
||||
TV_LIST_ITER_CONST(val_di->di_tv.vval.v_list, li, {
|
||||
if (TV_LIST_ITEM_TV(li)->v_type != VAR_STRING) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -33,9 +33,10 @@ int encode_vim_to_echo(garray_T *const packer,
|
||||
|
||||
/// Structure defining state for read_from_list()
|
||||
typedef struct {
|
||||
const list_T *const list; ///< List being currently read.
|
||||
const listitem_T *li; ///< Item currently read.
|
||||
size_t offset; ///< Byte offset inside the read item.
|
||||
size_t li_length; ///< Length of the string inside the read item.
|
||||
size_t offset; ///< Byte offset inside the read item.
|
||||
size_t li_length; ///< Length of the string inside the read item.
|
||||
} ListReaderState;
|
||||
|
||||
/// Initialize ListReaderState structure
|
||||
@@ -43,11 +44,13 @@ static inline ListReaderState encode_init_lrstate(const list_T *const list)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
return (ListReaderState) {
|
||||
.li = list->lv_first,
|
||||
.list = list,
|
||||
.li = tv_list_first(list),
|
||||
.offset = 0,
|
||||
.li_length = (list->lv_first->li_tv.vval.v_string == NULL
|
||||
.li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL
|
||||
? 0
|
||||
: STRLEN(list->lv_first->li_tv.vval.v_string)),
|
||||
: STRLEN(TV_LIST_ITEM_TV(
|
||||
tv_list_first(list))->vval.v_string)),
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -383,6 +383,22 @@ static inline listitem_T *tv_list_first(const list_T *const l)
|
||||
return l->lv_first;
|
||||
}
|
||||
|
||||
static inline listitem_T *tv_list_last(const list_T *const l)
|
||||
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
/// Get last list item
|
||||
///
|
||||
/// @param[in] l List to get item from.
|
||||
///
|
||||
/// @return List item or NULL in case of an empty list.
|
||||
static inline listitem_T *tv_list_last(const list_T *const l)
|
||||
{
|
||||
if (l == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return l->lv_last;
|
||||
}
|
||||
|
||||
static inline long tv_dict_len(const dict_T *const d)
|
||||
REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
|
@@ -355,14 +355,14 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
||||
break;
|
||||
}
|
||||
case VAR_LIST: {
|
||||
if (tv->vval.v_list == NULL || tv->vval.v_list->lv_len == 0) {
|
||||
if (tv->vval.v_list == NULL || tv_list_len(tv->vval.v_list) == 0) {
|
||||
TYPVAL_ENCODE_CONV_EMPTY_LIST(tv);
|
||||
break;
|
||||
}
|
||||
const int saved_copyID = tv->vval.v_list->lv_copyID;
|
||||
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_list, lv_copyID, copyID,
|
||||
kMPConvList);
|
||||
TYPVAL_ENCODE_CONV_LIST_START(tv, tv->vval.v_list->lv_len);
|
||||
TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(tv->vval.v_list));
|
||||
assert(saved_copyID != copyID && saved_copyID != copyID - 1);
|
||||
_mp_push(*mpstack, ((MPConvStackVal) {
|
||||
.type = kMPConvList,
|
||||
@@ -371,7 +371,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
||||
.data = {
|
||||
.l = {
|
||||
.list = tv->vval.v_list,
|
||||
.li = tv->vval.v_list->lv_first,
|
||||
.li = tv_list_first(tv->vval.v_list),
|
||||
},
|
||||
},
|
||||
}));
|
||||
@@ -440,23 +440,43 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
||||
// 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
|
||||
|| (val_list = val_di->di_tv.vval.v_list) == NULL
|
||||
|| val_list->lv_len != 4
|
||||
|| val_list->lv_first->li_tv.v_type != VAR_NUMBER
|
||||
|| (sign = val_list->lv_first->li_tv.vval.v_number) == 0
|
||||
|| val_list->lv_first->li_next->li_tv.v_type != VAR_NUMBER
|
||||
|| (highest_bits =
|
||||
val_list->lv_first->li_next->li_tv.vval.v_number) < 0
|
||||
|| val_list->lv_last->li_prev->li_tv.v_type != VAR_NUMBER
|
||||
|| (high_bits =
|
||||
val_list->lv_last->li_prev->li_tv.vval.v_number) < 0
|
||||
|| val_list->lv_last->li_tv.v_type != VAR_NUMBER
|
||||
|| (low_bits = val_list->lv_last->li_tv.vval.v_number) < 0) {
|
||||
|| tv_list_len(val_list = val_di->di_tv.vval.v_list) != 4) {
|
||||
goto _convert_one_value_regular_dict;
|
||||
}
|
||||
uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62)
|
||||
| (uint64_t)(((uint64_t)high_bits) << 31)
|
||||
| (uint64_t)low_bits);
|
||||
|
||||
const listitem_T *const sign_li = tv_list_first(val_list);
|
||||
if (TV_LIST_ITEM_TV(sign_li)->v_type != VAR_NUMBER
|
||||
|| (sign = TV_LIST_ITEM_TV(sign_li)->vval.v_number) == 0) {
|
||||
goto _convert_one_value_regular_dict;
|
||||
}
|
||||
|
||||
const listitem_T *const highest_bits_li = (
|
||||
TV_LIST_ITEM_NEXT(val_list, sign_li));
|
||||
if (TV_LIST_ITEM_TV(highest_bits_li)->v_type != VAR_NUMBER
|
||||
|| ((highest_bits
|
||||
= TV_LIST_ITEM_TV(highest_bits_li)->vval.v_number)
|
||||
< 0)) {
|
||||
goto _convert_one_value_regular_dict;
|
||||
}
|
||||
|
||||
const listitem_T *const high_bits_li = (
|
||||
TV_LIST_ITEM_NEXT(val_list, highest_bits_li));
|
||||
if (TV_LIST_ITEM_TV(high_bits_li)->v_type != VAR_NUMBER
|
||||
|| ((high_bits = TV_LIST_ITEM_TV(high_bits_li)->vval.v_number)
|
||||
< 0)) {
|
||||
goto _convert_one_value_regular_dict;
|
||||
}
|
||||
|
||||
const listitem_T *const low_bits_li = tv_list_last(val_list);
|
||||
if (TV_LIST_ITEM_TV(low_bits_li)->v_type != VAR_NUMBER
|
||||
|| ((low_bits = TV_LIST_ITEM_TV(low_bits_li)->vval.v_number)
|
||||
< 0)) {
|
||||
goto _convert_one_value_regular_dict;
|
||||
}
|
||||
|
||||
const uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62)
|
||||
| (uint64_t)(((uint64_t)high_bits) << 31)
|
||||
| (uint64_t)low_bits);
|
||||
if (sign > 0) {
|
||||
TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER(tv, number);
|
||||
} else {
|
||||
@@ -499,8 +519,8 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
||||
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_di->di_tv.vval.v_list,
|
||||
lv_copyID, copyID,
|
||||
kMPConvList);
|
||||
TYPVAL_ENCODE_CONV_LIST_START(tv,
|
||||
val_di->di_tv.vval.v_list->lv_len);
|
||||
TYPVAL_ENCODE_CONV_LIST_START(
|
||||
tv, tv_list_len(val_di->di_tv.vval.v_list));
|
||||
assert(saved_copyID != copyID && saved_copyID != copyID - 1);
|
||||
_mp_push(*mpstack, ((MPConvStackVal) {
|
||||
.tv = tv,
|
||||
@@ -509,7 +529,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
||||
.data = {
|
||||
.l = {
|
||||
.list = val_di->di_tv.vval.v_list,
|
||||
.li = val_di->di_tv.vval.v_list->lv_first,
|
||||
.li = tv_list_first(val_di->di_tv.vval.v_list),
|
||||
},
|
||||
},
|
||||
}));
|
||||
@@ -520,22 +540,21 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
||||
goto _convert_one_value_regular_dict;
|
||||
}
|
||||
list_T *const val_list = val_di->di_tv.vval.v_list;
|
||||
if (val_list == NULL || val_list->lv_len == 0) {
|
||||
if (val_list == NULL || tv_list_len(val_list) == 0) {
|
||||
TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, TYPVAL_ENCODE_NODICT_VAR);
|
||||
break;
|
||||
}
|
||||
for (const listitem_T *li = val_list->lv_first; li != NULL;
|
||||
li = li->li_next) {
|
||||
if (li->li_tv.v_type != VAR_LIST
|
||||
|| li->li_tv.vval.v_list->lv_len != 2) {
|
||||
TV_LIST_ITER_CONST(val_list, li, {
|
||||
if (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST
|
||||
|| tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) != 2) {
|
||||
goto _convert_one_value_regular_dict;
|
||||
}
|
||||
}
|
||||
});
|
||||
const int saved_copyID = val_di->di_tv.vval.v_list->lv_copyID;
|
||||
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_list, lv_copyID, copyID,
|
||||
kMPConvPairs);
|
||||
TYPVAL_ENCODE_CONV_DICT_START(tv, TYPVAL_ENCODE_NODICT_VAR,
|
||||
val_list->lv_len);
|
||||
tv_list_len(val_list));
|
||||
assert(saved_copyID != copyID && saved_copyID != copyID - 1);
|
||||
_mp_push(*mpstack, ((MPConvStackVal) {
|
||||
.tv = tv,
|
||||
@@ -544,7 +563,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
||||
.data = {
|
||||
.l = {
|
||||
.list = val_list,
|
||||
.li = val_list->lv_first,
|
||||
.li = tv_list_first(val_list),
|
||||
},
|
||||
},
|
||||
}));
|
||||
@@ -554,18 +573,22 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
|
||||
const list_T *val_list;
|
||||
varnumber_T type;
|
||||
if (val_di->di_tv.v_type != VAR_LIST
|
||||
|| (val_list = val_di->di_tv.vval.v_list) == NULL
|
||||
|| val_list->lv_len != 2
|
||||
|| (val_list->lv_first->li_tv.v_type != VAR_NUMBER)
|
||||
|| (type = val_list->lv_first->li_tv.vval.v_number) > INT8_MAX
|
||||
|| 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
|
||||
|| (val_list->lv_last->li_tv.v_type != VAR_LIST)) {
|
||||
|| (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(val_list->lv_last->li_tv.vval.v_list,
|
||||
&len, &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);
|
||||
@@ -674,11 +697,13 @@ typval_encode_stop_converting_one_item:
|
||||
cur_mpsv->data.l.list->lv_copyID = cur_mpsv->saved_copyID;
|
||||
TYPVAL_ENCODE_CONV_LIST_END(cur_mpsv->tv);
|
||||
continue;
|
||||
} else if (cur_mpsv->data.l.li != cur_mpsv->data.l.list->lv_first) {
|
||||
} else if (cur_mpsv->data.l.li
|
||||
!= tv_list_first(cur_mpsv->data.l.list)) {
|
||||
TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(cur_mpsv->tv);
|
||||
}
|
||||
tv = &cur_mpsv->data.l.li->li_tv;
|
||||
cur_mpsv->data.l.li = cur_mpsv->data.l.li->li_next;
|
||||
tv = TV_LIST_ITEM_TV(cur_mpsv->data.l.li);
|
||||
cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
|
||||
cur_mpsv->data.l.li);
|
||||
break;
|
||||
}
|
||||
case kMPConvPairs: {
|
||||
@@ -687,24 +712,26 @@ typval_encode_stop_converting_one_item:
|
||||
cur_mpsv->data.l.list->lv_copyID = cur_mpsv->saved_copyID;
|
||||
TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
|
||||
continue;
|
||||
} else if (cur_mpsv->data.l.li != cur_mpsv->data.l.list->lv_first) {
|
||||
} else if (cur_mpsv->data.l.li
|
||||
!= tv_list_first(cur_mpsv->data.l.list)) {
|
||||
TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(
|
||||
cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
|
||||
}
|
||||
const list_T *const kv_pair = cur_mpsv->data.l.li->li_tv.vval.v_list;
|
||||
const list_T *const kv_pair = (
|
||||
TV_LIST_ITEM_TV(cur_mpsv->data.l.li)->vval.v_list);
|
||||
TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK(
|
||||
encode_vim_to__error_ret, kv_pair->lv_first->li_tv);
|
||||
if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME,
|
||||
&mpstack, cur_mpsv,
|
||||
&kv_pair->lv_first->li_tv,
|
||||
copyID,
|
||||
objname) == FAIL) {
|
||||
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 = &kv_pair->lv_last->li_tv;
|
||||
cur_mpsv->data.l.li = cur_mpsv->data.l.li->li_next;
|
||||
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: {
|
||||
|
Reference in New Issue
Block a user