237 #include <inttypes.h> 254 void *
const val,
int *
const val_copyID,
255 const MPConvStack *
const mpstack,
const int copyID,
257 const char *
const objname)
277 void *const val,
int *const val_copyID,
278 const MPConvStack *const mpstack, const
int copyID,
280 const
char *const objname)
282 if (*val_copyID == copyID) {
286 *val_copyID = copyID;
294 const char *
const objname)
317 typval_T *const tv, const
int copyID,
318 const
char *const objname)
348 .saved_copyID = copyID - 1,
363 const int saved_copyID = tv_list_copyid(tv->
vval.
v_list);
367 assert(saved_copyID != copyID && saved_copyID != copyID - 1);
371 .saved_copyID = saved_copyID,
398 || tv->
vval.
v_dict->dv_hashtab.ht_used == 0) {
408 && type_di->di_tv.v_type ==
VAR_LIST 418 goto _convert_one_value_regular_dict;
427 goto _convert_one_value_regular_dict;
443 if (val_di->di_tv.v_type !=
VAR_LIST 444 || tv_list_len(val_list = val_di->di_tv.vval.v_list) != 4) {
445 goto _convert_one_value_regular_dict;
448 const listitem_T *
const sign_li = tv_list_first(val_list);
451 goto _convert_one_value_regular_dict;
460 goto _convert_one_value_regular_dict;
468 goto _convert_one_value_regular_dict;
471 const listitem_T *
const low_bits_li = tv_list_last(val_list);
475 goto _convert_one_value_regular_dict;
478 const uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62)
479 | (uint64_t)(((uint64_t)high_bits) << 31)
480 | (uint64_t)low_bits);
490 goto _convert_one_value_regular_dict;
498 if (val_di->di_tv.v_type !=
VAR_LIST) {
499 goto _convert_one_value_regular_dict;
505 goto _convert_one_value_regular_dict;
516 if (val_di->di_tv.v_type !=
VAR_LIST) {
517 goto _convert_one_value_regular_dict;
519 const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
524 tv, tv_list_len(val_di->di_tv.vval.v_list));
525 assert(saved_copyID != copyID && saved_copyID != copyID - 1);
529 .saved_copyID = saved_copyID,
532 .list = val_di->di_tv.vval.v_list,
533 .li = tv_list_first(val_di->di_tv.vval.v_list),
540 if (val_di->di_tv.v_type !=
VAR_LIST) {
541 goto _convert_one_value_regular_dict;
543 list_T *
const val_list = val_di->di_tv.vval.v_list;
544 if (val_list ==
NULL || tv_list_len(val_list) == 0) {
546 tv, TYPVAL_ENCODE_NODICT_VAR);
552 goto _convert_one_value_regular_dict;
555 const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
559 tv_list_len(val_list));
560 assert(saved_copyID != copyID && saved_copyID != copyID - 1);
564 .saved_copyID = saved_copyID,
568 .li = tv_list_first(val_list),
577 if (val_di->di_tv.v_type !=
VAR_LIST 578 || tv_list_len((val_list = val_di->di_tv.vval.v_list)) != 2
587 goto _convert_one_value_regular_dict;
595 goto _convert_one_value_regular_dict;
604 _convert_one_value_regular_dict: {}
605 const int saved_copyID = tv->
vval.
v_dict->dv_copyID;
610 assert(saved_copyID != copyID && saved_copyID != copyID - 1);
614 .saved_copyID = saved_copyID,
633 typval_encode_stop_converting_one_item:
636 goto typval_encode_stop_converting_one_item;
641 typval_T *
const tv,
const char *
const objname)
655 typval_T *
const top_tv,
const char *
const objname)
662 top_tv, copyID, objname)
664 goto encode_vim_to__error_ret;
668 typval_encode_stop_converting_one_item:
672 switch (cur_mpsv->
type) {
674 if (!cur_mpsv->
data.
d.todo) {
679 }
else if (cur_mpsv->
data.
d.todo
680 != cur_mpsv->
data.
d.dict->dv_hashtab.ht_used) {
682 *cur_mpsv->
data.
d.dictp);
685 cur_mpsv->
data.
d.hi++;
688 cur_mpsv->
data.
d.todo--;
689 cur_mpsv->
data.
d.hi++;
691 strlen((
char *)&di->di_key[0]));
693 *cur_mpsv->
data.
d.dictp);
703 }
else if (cur_mpsv->
data.
l.li
704 != tv_list_first(cur_mpsv->
data.
l.list)) {
709 cur_mpsv->
data.
l.li);
718 }
else if (cur_mpsv->
data.
l.li
719 != tv_list_first(cur_mpsv->
data.
l.list)) {
721 cur_mpsv->
tv, TYPVAL_ENCODE_NODICT_VAR);
723 const list_T *
const kv_pair = (
729 TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack, cur_mpsv,
732 goto encode_vim_to__error_ret;
735 TYPVAL_ENCODE_NODICT_VAR);
738 cur_mpsv->
data.
l.li);
745 switch (cur_mpsv->
data.
p.stage) {
755 .saved_copyID = copyID - 1,
772 if (dict->dv_hashtab.ht_used == 0) {
776 const int saved_copyID = dict->dv_copyID;
778 TYPVAL_ENCODE_FIRST_ARG_NAME,
779 dict, &dict->dv_copyID, &mpstack, copyID,
kMPConvDict,
782 if (te_csr_ret ==
FAIL) {
783 goto encode_vim_to__error_ret;
789 dict->dv_hashtab.ht_used);
790 assert(saved_copyID != copyID && saved_copyID != copyID - 1);
794 .saved_copyID = saved_copyID,
799 .hi = dict->dv_hashtab.ht_array,
800 .todo = dict->dv_hashtab.ht_used,
820 if (!cur_mpsv->
data.
a.todo) {
824 }
else if (cur_mpsv->
data.
a.argv != cur_mpsv->
data.
a.arg) {
827 tv = cur_mpsv->
data.
a.arg++;
828 cur_mpsv->
data.
a.todo--;
834 cur_mpsv, tv, copyID, objname)
836 goto encode_vim_to__error_ret;
841 encode_vim_to__error_ret:
845 goto typval_encode_stop_converting_one_item;
typval_T tv
Definition: typval.c:1544
dict_T * v_dict
Dictionary for VAR_DICT, can be NULL.
Definition: typval.h:132
#define TYPVAL_ENCODE_CONV_LIST_START(tv, len)
Definition: helpers.c:471
Unknown (unspecified) value.
Definition: typval.h:110
#define TYPVAL_ENCODE_CONV_STR_STRING
Definition: helpers.c:438
#define HASHITEM_EMPTY(hi)
Definition: hashtab.h:19
struct MPConvStackVal::@9::@10 d
State of dictionary conversion.
#define _mp_size
Definition: typval_encode.h:67
Already converted everything.
Definition: typval_encode.h:30
#define TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(tv, dict, mpsv)
Definition: helpers.c:517
Partial, .v_partial is used.
Definition: typval.h:119
Convert mapping represented as a list_T* of pairs.
Definition: typval_encode.h:21
#define TYPVAL_ENCODE_CONV_BOOL(tv, num)
Definition: helpers.c:416
tv_copy & TV_DICT_HI2DI(hi) ->di_tv, rettv
#define TYPVAL_ENCODE_CONV_REAL_LIST_AFTER_START(tv, mpsv)
Definition: helpers.c:474
Definition: coverity-model.c:39
union MPConvStackVal::@9 data
Data to convert.
#define _mp_pop
Definition: typval_encode.h:71
Structure that holds an internal variable value.
Definition: typval.h:123
#define TYPVAL_ENCODE_CONV_EXT_STRING(tv, str, len, type)
Definition: helpers.c:440
#define TV_LIST_ITEM_TV(li)
Definition: typval.h:739
TV_LIST_ITER_CONST(list, li,{if(TV_LIST_ITEM_TV(li) ->v_type!=VAR_STRING){return false;}len++;if(TV_LIST_ITEM_TV(li) ->vval.v_string!=NULL){len+=STRLEN(TV_LIST_ITEM_TV(li) ->vval.v_string);}})
#define TYPVAL_ENCODE_ALLOW_SPECIALS
Definition: helpers.c:411
MPConvStackValType type
Type of the stack entry.
Definition: typval_encode.h:35
v:true
Definition: typval.h:97
#define TYPVAL_ENCODE_CONV_NIL(tv)
Definition: helpers.c:413
#define _mp_init
Definition: typval_encode.h:68
#define S_LEN(s)
Definition: macros.h:30
void internal_error(char *where)
Give an "Internal error" message.
Definition: message.c:815
#define TYPVAL_ENCODE_CONV_EMPTY_LIST(tv)
Definition: helpers.c:453
return NULL
Definition: eval.c:23938
int len
Definition: helpers.c:1461
String, .v_string is used.
Definition: typval.h:112
int get_copyID(void)
Definition: eval.c:5270
Structure representing current VimL to messagepack conversion state.
Definition: typval_encode.h:34
Convert partial_T* partial.
Definition: typval_encode.h:22
#define TYPVAL_ENCODE_SCOPE
Definition: helpers.c:570
const dict_T *const TYPVAL_ENCODE_NODICT_VAR
Definition: typval_encode.c.h:250
struct MPConvStackVal::@9::@12 p
State of partial conversion.
Number, .v_number is used.
Definition: typval.h:111
#define TYPVAL_ENCODE_CONV_FLOAT(tv, flt)
Definition: helpers.c:424
int saved_copyID
copyID item used to have.
Definition: typval_encode.h:37
Convert argc/argv pair coming from a partial.
Definition: typval_encode.h:23
v:null
Definition: typval.h:98
static int REAL_FATTR_WARN_UNUSED_RESULT
Definition: typval_encode.c.h:295
int pt_argc
Number of arguments.
Definition: typval.h:306
return OK
Definition: eval.c:1061
Convert list_T *list.
Definition: typval_encode.h:20
VarType v_type
Variable type.
Definition: typval.h:124
struct MPConvStackVal::@9::@11 l
State of list or generic mapping conversion.
partial_T * v_partial
Closure: function with args.
Definition: typval.h:133
v:false
Definition: typval.h:96
SpecialVarValue v_special
Special value, for VAR_SPECIAL.
Definition: typval.h:128
#define STR(x)
Definition: macros.h:155
#define TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(tv, dict)
Definition: helpers.c:551
#define TYPVAL_ENCODE_CONV_LIST_END(tv)
Definition: helpers.c:499
#define _mp_destroy
Definition: typval_encode.h:69
#define TYPVAL_ENCODE_FIRST_ARG_NAME
Definition: helpers.c:573
Definition: coverity-model.c:40
#define TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(tv)
Definition: helpers.c:486
#define TYPVAL_ENCODE_CONV_NUMBER(tv, num)
Definition: helpers.c:419
list_T * v_list
List for VAR_LIST, can be NULL.
Definition: typval.h:131
char *const buf
Definition: encode.c:231
#define TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER
Definition: helpers.c:422
struct MPConvStackVal::@9::@13 a
State of list or generic mapping conversion.
#define _mp_last
Definition: typval_encode.h:72
Convert dict_T *dictionary.
Definition: typval_encode.h:19
dictitem_T * tv_dict_find(const dict_T *const d, const char *const key, const ptrdiff_t len) FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
Definition: typval.c:1415
typval_T * pt_argv
Arguments in allocated array.
Definition: typval.h:307
TYPVAL_ENCODE_SCOPE int _TYPVAL_ENCODE_ENCODE(TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME, typval_T *const tv, const char *const objname) REAL_FATTR_NONNULL_ARG(2
Definition: typval_encode.c.h:653
#define TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, len)
Definition: helpers.c:450
Floating-point value, .v_float is used.
Definition: typval.h:116
typval_T * tv
Currently converted typval_T.
Definition: typval_encode.h:36
#define REAL_FATTR_NONNULL_ARG(...)
Definition: func_attr.h:187
char_u * v_string
String, for VAR_STRING and VAR_FUNC, can be NULL.
Definition: typval.h:130
union typval_T::typval_vval_union vval
Actual value.
dictitem_T *const di
Definition: typval.c:1533
#define TYPVAL_ENCODE_CONV_DICT_END(tv, dict)
Definition: helpers.c:564
varnumber_T v_number
Number, for VAR_NUMBER.
Definition: typval.h:127
#define _mp_push
Definition: typval_encode.h:70
List, .v_list is used.
Definition: typval.h:114
MPConvStackValType
Type of the stack entry.
Definition: typval_encode.h:18
About to convert arguments.
Definition: typval_encode.h:28
#define TYPVAL_ENCODE_CONV_FUNC_END(tv)
Definition: helpers.c:451
#define NOTDONE
Definition: vim.h:94
#define TV_LIST_ITEM_NEXT(l, li)
Definition: typval.h:747
#define TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, dict)
Definition: helpers.c:456
void argv[0] v_type
Definition: typval.c:1178
MessagePackType
All recognized msgpack types.
Definition: eval.h:124
#define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun)
Definition: helpers.c:443
#define inline
Definition: stack.c:17
#define TYPVAL_ENCODE_CONV_RECURSE(val, conv_type)
Definition: helpers.c:567
static int REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE
Definition: typval_encode.c.h:258
int64_t varnumber_T
Type used for VimL VAR_NUMBER values.
Definition: typval.h:26
return FAIL
Definition: eval.c:1058
#define TYPVAL_ENCODE_CONV_DICT_START(tv, dict, len)
Definition: helpers.c:514
#define TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK(label, kv_pair)
Definition: helpers.c:519
Function reference, .v_string is used as function name.
Definition: typval.h:113
int i
Definition: typval.c:868
bool encode_vim_list_to_buf(const list_T *const list, size_t *const ret_len, char **const ret_buf) FUNC_ATTR_NONNULL_ARG(2
#define _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val, copyID_attr, copyID, conv_type)
Definition: typval_encode.h:101
#define TYPVAL_ENCODE_FIRST_ARG_TYPE
Definition: helpers.c:572
#define TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, len)
Definition: helpers.c:449
#define TYPVAL_ENCODE_CONV_STRING(tv, str, len)
Definition: helpers.c:427
#define TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(tv, dict)
Definition: helpers.c:538
err type
Definition: helpers.c:1470
About to convert self dictionary.
Definition: typval_encode.h:29
#define _TYPVAL_ENCODE_CONVERT_ONE_VALUE
Name of the …convert_one_value function.
Definition: typval_encode.h:139
Dictionary, .v_dict is used.
Definition: typval.h:115
float_T v_float
Floating-point number, for VAR_FLOAT.
Definition: typval.h:129
listitem_T * li
Definition: eval.c:15488
const list_T * eval_msgpack_type_lists[]
Array mapping values from MessagePackType to corresponding list pointers.
Definition: eval.c:524
char_u * partial_name(partial_T *pt)
Definition: eval.c:5127
dict_T * pt_dict
Dict for "self".
Definition: typval.h:308
#define ARRAY_SIZE(arr)
Definition: macros.h:141
#define _TYPVAL_ENCODE_CHECK_SELF_REFERENCE
Self reference checker function name.
Definition: typval_encode.h:131