diff options
Diffstat (limited to 'src/nvim/eval/decode.c')
| -rw-r--r-- | src/nvim/eval/decode.c | 46 | 
1 files changed, 25 insertions, 21 deletions
| diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index 0933b1bf9c..d5c65ebe81 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -60,8 +60,8 @@ static inline void create_special_dict(typval_T *const rettv,    dictitem_T *const type_di = tv_dict_item_alloc_len(S_LEN("_TYPE"));    type_di->di_tv.v_type = VAR_LIST;    type_di->di_tv.v_lock = VAR_UNLOCKED; -  type_di->di_tv.vval.v_list = (list_T *) eval_msgpack_type_lists[type]; -  type_di->di_tv.vval.v_list->lv_refcount++; +  type_di->di_tv.vval.v_list = (list_T *)eval_msgpack_type_lists[type]; +  tv_list_ref(type_di->di_tv.vval.v_list);    tv_dict_add(dict, type_di);    dictitem_T *const val_di = tv_dict_item_alloc_len(S_LEN("_VAL"));    val_di->di_tv = val; @@ -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 { @@ -234,7 +234,7 @@ list_T *decode_create_map_special_dict(typval_T *const ret_tv)    FUNC_ATTR_NONNULL_ALL  {    list_T *const list = tv_list_alloc(); -  list->lv_refcount++; +  tv_list_ref(list);    create_special_dict(ret_tv, kMPMap, ((typval_T) {      .v_type = VAR_LIST,      .v_lock = VAR_UNLOCKED, @@ -270,7 +270,7 @@ typval_T decode_string(const char *const s, const size_t len,                                : (bool)hasnul);    if (really_hasnul) {      list_T *const list = tv_list_alloc(); -    list->lv_refcount++; +    tv_list_ref(list);      typval_T tv;      create_special_dict(&tv, binary ? kMPBinary : kMPString, ((typval_T) {        .v_type = VAR_LIST, @@ -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;          } @@ -849,7 +850,7 @@ json_decode_string_cycle_start:        }        case '[': {          list_T *list = tv_list_alloc(); -        list->lv_refcount++; +        tv_list_ref(list);          typval_T tv = {            .v_type = VAR_LIST,            .v_lock = VAR_UNLOCKED, @@ -970,7 +971,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv)          };        } else {          list_T *const list = tv_list_alloc(); -        list->lv_refcount++; +        tv_list_ref(list);          create_special_dict(rettv, kMPInteger, ((typval_T) {            .v_type = VAR_LIST,            .v_lock = VAR_UNLOCKED, @@ -993,7 +994,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv)          };        } else {          list_T *const list = tv_list_alloc(); -        list->lv_refcount++; +        tv_list_ref(list);          create_special_dict(rettv, kMPInteger, ((typval_T) {            .v_type = VAR_LIST,            .v_lock = VAR_UNLOCKED, @@ -1039,7 +1040,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv)      }      case MSGPACK_OBJECT_ARRAY: {        list_T *const list = tv_list_alloc(); -      list->lv_refcount++; +      tv_list_ref(list);        *rettv = (typval_T) {          .v_type = VAR_LIST,          .v_lock = VAR_UNLOCKED, @@ -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;          }        } @@ -1110,7 +1114,7 @@ msgpack_to_vim_generic_map: {}      }      case MSGPACK_OBJECT_EXT: {        list_T *const list = tv_list_alloc(); -      list->lv_refcount++; +      tv_list_ref(list);        tv_list_append_number(list, mobj.via.ext.type);        list_T *const ext_val_list = tv_list_alloc();        tv_list_append_list(list, ext_val_list); | 
