typval_encode.c.h
Go to the documentation of this file.
1 
15 
26 
33 
43 
50 
61 
72 
85 
91 
98 
106 
111 
116 
124 
131 
141 
146 
151 
164 
172 
178 
186 
194 
202 
208 
214 
217 
225 
230 
236 #include <stddef.h>
237 #include <inttypes.h>
238 #include <assert.h>
239 
240 #include "nvim/lib/kvec.h"
241 #include "nvim/eval/typval.h"
242 #include "nvim/eval/encode.h"
243 #include "nvim/func_attr.h"
244 #include "nvim/eval/typval_encode.h"
245 
251 
252 static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
254  void *const val, int *const val_copyID,
255  const MPConvStack *const mpstack, const int copyID,
256  const MPConvStackValType conv_type,
257  const char *const objname)
260 
275 static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
276  TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
277  void *const val, int *const val_copyID,
278  const MPConvStack *const mpstack, const int copyID,
279  const MPConvStackValType conv_type,
280  const char *const objname)
281 {
282  if (*val_copyID == copyID) {
283  TYPVAL_ENCODE_CONV_RECURSE(val, conv_type);
284  return OK;
285  }
286  *val_copyID = copyID;
287  return NOTDONE;
288 }
289 
292  MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
293  typval_T *const tv, const int copyID,
294  const char *const objname)
296 
316  MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
317  typval_T *const tv, const int copyID,
318  const char *const objname)
319 {
320  switch (tv->v_type) {
321  case VAR_STRING: {
322  TYPVAL_ENCODE_CONV_STRING(tv, tv->vval.v_string, tv_strlen(tv));
323  break;
324  }
325  case VAR_NUMBER: {
327  break;
328  }
329  case VAR_FLOAT: {
331  break;
332  }
333  case VAR_FUNC: {
338  break;
339  }
340  case VAR_PARTIAL: {
341  partial_T *const pt = tv->vval.v_partial;
342  (void)pt;
344  tv, (pt == NULL ? NULL : partial_name(pt)));
345  _mp_push(*mpstack, ((MPConvStackVal) { // -V779
346  .type = kMPConvPartial,
347  .tv = tv,
348  .saved_copyID = copyID - 1,
349  .data = {
350  .p = {
351  .stage = kMPConvPartialArgs,
352  .pt = tv->vval.v_partial,
353  },
354  },
355  }));
356  break;
357  }
358  case VAR_LIST: {
359  if (tv->vval.v_list == NULL || tv_list_len(tv->vval.v_list) == 0) {
361  break;
362  }
363  const int saved_copyID = tv_list_copyid(tv->vval.v_list);
364  _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_list, lv_copyID, copyID,
365  kMPConvList);
366  TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(tv->vval.v_list));
367  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
368  _mp_push(*mpstack, ((MPConvStackVal) {
369  .type = kMPConvList,
370  .tv = tv,
371  .saved_copyID = saved_copyID,
372  .data = {
373  .l = {
374  .list = tv->vval.v_list,
375  .li = tv_list_first(tv->vval.v_list),
376  },
377  },
378  }));
380  break;
381  }
382  case VAR_SPECIAL: {
383  switch (tv->vval.v_special) {
384  case kSpecialVarNull: {
386  break;
387  }
388  case kSpecialVarTrue:
389  case kSpecialVarFalse: {
391  break;
392  }
393  }
394  break;
395  }
396  case VAR_DICT: {
397  if (tv->vval.v_dict == NULL
398  || tv->vval.v_dict->dv_hashtab.ht_used == 0) {
400  break;
401  }
402  const dictitem_T *type_di;
403  const dictitem_T *val_di;
405  && tv->vval.v_dict->dv_hashtab.ht_used == 2
406  && (type_di = tv_dict_find((dict_T *)tv->vval.v_dict,
407  S_LEN("_TYPE"))) != NULL
408  && type_di->di_tv.v_type == VAR_LIST
409  && (val_di = tv_dict_find((dict_T *)tv->vval.v_dict,
410  S_LEN("_VAL"))) != NULL) {
411  size_t i;
412  for (i = 0; i < ARRAY_SIZE(eval_msgpack_type_lists); i++) {
413  if (type_di->di_tv.vval.v_list == eval_msgpack_type_lists[i]) {
414  break;
415  }
416  }
418  goto _convert_one_value_regular_dict;
419  }
420  switch ((MessagePackType)i) {
421  case kMPNil: {
423  break;
424  }
425  case kMPBoolean: {
426  if (val_di->di_tv.v_type != VAR_NUMBER) {
427  goto _convert_one_value_regular_dict;
428  }
429  TYPVAL_ENCODE_CONV_BOOL(tv, val_di->di_tv.vval.v_number);
430  break;
431  }
432  case kMPInteger: {
433  const list_T *val_list;
435  varnumber_T highest_bits;
436  varnumber_T high_bits;
437  varnumber_T low_bits;
438  // List of 4 integers; first is signed (should be 1 or -1, but
439  // this is not checked), second is unsigned and have at most
440  // one (sign is -1) or two (sign is 1) non-zero bits (number of
441  // bits is not checked), other unsigned and have at most 31
442  // non-zero bits (number of bits is not checked).
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;
446  }
447 
448  const listitem_T *const sign_li = tv_list_first(val_list);
449  if (TV_LIST_ITEM_TV(sign_li)->v_type != VAR_NUMBER
450  || (sign = TV_LIST_ITEM_TV(sign_li)->vval.v_number) == 0) {
451  goto _convert_one_value_regular_dict;
452  }
453 
454  const listitem_T *const highest_bits_li = (
455  TV_LIST_ITEM_NEXT(val_list, sign_li));
456  if (TV_LIST_ITEM_TV(highest_bits_li)->v_type != VAR_NUMBER
457  || ((highest_bits
458  = TV_LIST_ITEM_TV(highest_bits_li)->vval.v_number)
459  < 0)) {
460  goto _convert_one_value_regular_dict;
461  }
462 
463  const listitem_T *const high_bits_li = (
464  TV_LIST_ITEM_NEXT(val_list, highest_bits_li));
465  if (TV_LIST_ITEM_TV(high_bits_li)->v_type != VAR_NUMBER
466  || ((high_bits = TV_LIST_ITEM_TV(high_bits_li)->vval.v_number)
467  < 0)) {
468  goto _convert_one_value_regular_dict;
469  }
470 
471  const listitem_T *const low_bits_li = tv_list_last(val_list);
472  if (TV_LIST_ITEM_TV(low_bits_li)->v_type != VAR_NUMBER
473  || ((low_bits = TV_LIST_ITEM_TV(low_bits_li)->vval.v_number)
474  < 0)) {
475  goto _convert_one_value_regular_dict;
476  }
477 
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);
481  if (sign > 0) {
483  } else {
484  TYPVAL_ENCODE_CONV_NUMBER(tv, -number);
485  }
486  break;
487  }
488  case kMPFloat: {
489  if (val_di->di_tv.v_type != VAR_FLOAT) {
490  goto _convert_one_value_regular_dict;
491  }
492  TYPVAL_ENCODE_CONV_FLOAT(tv, val_di->di_tv.vval.v_float);
493  break;
494  }
495  case kMPString:
496  case kMPBinary: {
497  const bool is_string = ((MessagePackType)i == kMPString);
498  if (val_di->di_tv.v_type != VAR_LIST) {
499  goto _convert_one_value_regular_dict;
500  }
501  size_t len;
502  char *buf;
503  if (!encode_vim_list_to_buf(val_di->di_tv.vval.v_list, &len,
504  &buf)) {
505  goto _convert_one_value_regular_dict;
506  }
507  if (is_string) {
508  TYPVAL_ENCODE_CONV_STR_STRING(tv, buf, len);
509  } else { // -V523
510  TYPVAL_ENCODE_CONV_STRING(tv, buf, len);
511  }
512  xfree(buf);
513  break;
514  }
515  case kMPArray: {
516  if (val_di->di_tv.v_type != VAR_LIST) {
517  goto _convert_one_value_regular_dict;
518  }
519  const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
520  _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_di->di_tv.vval.v_list,
521  lv_copyID, copyID,
522  kMPConvList);
524  tv, tv_list_len(val_di->di_tv.vval.v_list));
525  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
526  _mp_push(*mpstack, ((MPConvStackVal) {
527  .tv = tv,
528  .type = kMPConvList,
529  .saved_copyID = saved_copyID,
530  .data = {
531  .l = {
532  .list = val_di->di_tv.vval.v_list,
533  .li = tv_list_first(val_di->di_tv.vval.v_list),
534  },
535  },
536  }));
537  break;
538  }
539  case kMPMap: {
540  if (val_di->di_tv.v_type != VAR_LIST) {
541  goto _convert_one_value_regular_dict;
542  }
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);
547  break;
548  }
549  TV_LIST_ITER_CONST(val_list, li, {
550  if (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST
551  || tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) != 2) {
552  goto _convert_one_value_regular_dict;
553  }
554  });
555  const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
556  _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_list, lv_copyID, copyID,
557  kMPConvPairs);
558  TYPVAL_ENCODE_CONV_DICT_START(tv, TYPVAL_ENCODE_NODICT_VAR,
559  tv_list_len(val_list));
560  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
561  _mp_push(*mpstack, ((MPConvStackVal) {
562  .tv = tv,
563  .type = kMPConvPairs,
564  .saved_copyID = saved_copyID,
565  .data = {
566  .l = {
567  .list = val_list,
568  .li = tv_list_first(val_list),
569  },
570  },
571  }));
572  break;
573  }
574  case kMPExt: {
575  const list_T *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
579  || (TV_LIST_ITEM_TV(tv_list_first(val_list))->v_type
580  != VAR_NUMBER)
581  || ((type
582  = TV_LIST_ITEM_TV(tv_list_first(val_list))->vval.v_number)
583  > INT8_MAX)
584  || type < INT8_MIN
585  || (TV_LIST_ITEM_TV(tv_list_last(val_list))->v_type
586  != VAR_LIST)) {
587  goto _convert_one_value_regular_dict;
588  }
589  size_t len;
590  char *buf;
591  if (!(
593  TV_LIST_ITEM_TV(tv_list_last(val_list))->vval.v_list, &len,
594  &buf))) {
595  goto _convert_one_value_regular_dict;
596  }
597  TYPVAL_ENCODE_CONV_EXT_STRING(tv, buf, len, type);
598  xfree(buf);
599  break;
600  }
601  }
602  break;
603  }
604 _convert_one_value_regular_dict: {}
605  const int saved_copyID = tv->vval.v_dict->dv_copyID;
606  _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_dict, dv_copyID, copyID,
607  kMPConvDict);
609  tv->vval.v_dict->dv_hashtab.ht_used);
610  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
611  _mp_push(*mpstack, ((MPConvStackVal) {
612  .tv = tv,
613  .type = kMPConvDict,
614  .saved_copyID = saved_copyID,
615  .data = {
616  .d = {
617  .dict = tv->vval.v_dict,
618  .dictp = &tv->vval.v_dict,
619  .hi = tv->vval.v_dict->dv_hashtab.ht_array,
620  .todo = tv->vval.v_dict->dv_hashtab.ht_used,
621  },
622  },
623  }));
625  _mp_last(*mpstack));
626  break;
627  }
628  case VAR_UNKNOWN: {
630  return FAIL;
631  }
632  }
633 typval_encode_stop_converting_one_item:
634  return OK;
635  // Prevent “unused label” warnings.
636  goto typval_encode_stop_converting_one_item; // -V779
637 }
638 
641  typval_T *const tv, const char *const objname)
643 
655  typval_T *const top_tv, const char *const objname)
656 {
657  const int copyID = get_copyID();
658  MPConvStack mpstack;
659  _mp_init(mpstack);
660  if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack,
661  NULL,
662  top_tv, copyID, objname)
663  == FAIL) {
664  goto encode_vim_to__error_ret;
665  }
668 typval_encode_stop_converting_one_item:
669  while (_mp_size(mpstack)) {
670  MPConvStackVal *cur_mpsv = &_mp_last(mpstack);
671  typval_T *tv = NULL;
672  switch (cur_mpsv->type) {
673  case kMPConvDict: {
674  if (!cur_mpsv->data.d.todo) {
675  (void)_mp_pop(mpstack);
676  cur_mpsv->data.d.dict->dv_copyID = cur_mpsv->saved_copyID;
677  TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, *cur_mpsv->data.d.dictp);
678  continue;
679  } else if (cur_mpsv->data.d.todo
680  != cur_mpsv->data.d.dict->dv_hashtab.ht_used) {
682  *cur_mpsv->data.d.dictp);
683  }
684  while (HASHITEM_EMPTY(cur_mpsv->data.d.hi)) {
685  cur_mpsv->data.d.hi++;
686  }
687  dictitem_T *const di = TV_DICT_HI2DI(cur_mpsv->data.d.hi);
688  cur_mpsv->data.d.todo--;
689  cur_mpsv->data.d.hi++;
690  TYPVAL_ENCODE_CONV_STR_STRING(NULL, &di->di_key[0],
691  strlen((char *)&di->di_key[0]));
693  *cur_mpsv->data.d.dictp);
694  tv = &di->di_tv;
695  break;
696  }
697  case kMPConvList: {
698  if (cur_mpsv->data.l.li == NULL) {
699  (void)_mp_pop(mpstack);
700  tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
701  TYPVAL_ENCODE_CONV_LIST_END(cur_mpsv->tv);
702  continue;
703  } else if (cur_mpsv->data.l.li
704  != tv_list_first(cur_mpsv->data.l.list)) {
706  }
707  tv = TV_LIST_ITEM_TV(cur_mpsv->data.l.li);
708  cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
709  cur_mpsv->data.l.li);
710  break;
711  }
712  case kMPConvPairs: {
713  if (cur_mpsv->data.l.li == NULL) {
714  (void)_mp_pop(mpstack);
715  tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
716  TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
717  continue;
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);
722  }
723  const list_T *const kv_pair = (
724  TV_LIST_ITEM_TV(cur_mpsv->data.l.li)->vval.v_list);
726  encode_vim_to__error_ret, *TV_LIST_ITEM_TV(tv_list_first(kv_pair)));
727  if (
729  TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack, cur_mpsv,
730  TV_LIST_ITEM_TV(tv_list_first(kv_pair)), copyID, objname)
731  == FAIL) {
732  goto encode_vim_to__error_ret;
733  }
735  TYPVAL_ENCODE_NODICT_VAR);
736  tv = TV_LIST_ITEM_TV(tv_list_last(kv_pair));
737  cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
738  cur_mpsv->data.l.li);
739  break;
740  }
741  case kMPConvPartial: {
742  partial_T *const pt = cur_mpsv->data.p.pt;
743  tv = cur_mpsv->tv;
744  (void)tv;
745  switch (cur_mpsv->data.p.stage) {
746  case kMPConvPartialArgs: {
748  pt == NULL ? 0 : pt->pt_argc);
749  cur_mpsv->data.p.stage = kMPConvPartialSelf;
750  if (pt != NULL && pt->pt_argc > 0) {
752  _mp_push(mpstack, ((MPConvStackVal) {
753  .type = kMPConvPartialList,
754  .tv = NULL,
755  .saved_copyID = copyID - 1,
756  .data = {
757  .a = {
758  .arg = pt->pt_argv,
759  .argv = pt->pt_argv,
760  .todo = (size_t)pt->pt_argc,
761  },
762  },
763  }));
764  }
765  break;
766  }
767  case kMPConvPartialSelf: {
768  cur_mpsv->data.p.stage = kMPConvPartialEnd;
769  dict_T *const dict = pt == NULL ? NULL : pt->pt_dict;
770  if (dict != NULL) {
771  TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, dict->dv_hashtab.ht_used);
772  if (dict->dv_hashtab.ht_used == 0) {
774  continue;
775  }
776  const int saved_copyID = dict->dv_copyID;
777  const int te_csr_ret = _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
778  TYPVAL_ENCODE_FIRST_ARG_NAME,
779  dict, &dict->dv_copyID, &mpstack, copyID, kMPConvDict,
780  objname);
781  if (te_csr_ret != NOTDONE) {
782  if (te_csr_ret == FAIL) {
783  goto encode_vim_to__error_ret;
784  } else {
785  continue;
786  }
787  }
789  dict->dv_hashtab.ht_used);
790  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
791  _mp_push(mpstack, ((MPConvStackVal) {
792  .type = kMPConvDict,
793  .tv = NULL,
794  .saved_copyID = saved_copyID,
795  .data = {
796  .d = {
797  .dict = dict,
798  .dictp = &pt->pt_dict,
799  .hi = dict->dv_hashtab.ht_array,
800  .todo = dict->dv_hashtab.ht_used,
801  },
802  },
803  }));
805  _mp_last(mpstack));
806  } else {
808  }
809  break;
810  }
811  case kMPConvPartialEnd: {
813  (void)_mp_pop(mpstack);
814  break;
815  }
816  }
817  continue;
818  }
819  case kMPConvPartialList: {
820  if (!cur_mpsv->data.a.todo) {
821  (void)_mp_pop(mpstack);
823  continue;
824  } else if (cur_mpsv->data.a.argv != cur_mpsv->data.a.arg) {
826  }
827  tv = cur_mpsv->data.a.arg++;
828  cur_mpsv->data.a.todo--;
829  break;
830  }
831  }
832  assert(tv != NULL);
833  if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack,
834  cur_mpsv, tv, copyID, objname)
835  == FAIL) {
836  goto encode_vim_to__error_ret;
837  }
838  }
839  _mp_destroy(mpstack);
840  return OK;
841 encode_vim_to__error_ret:
842  _mp_destroy(mpstack);
843  return FAIL;
844  // Prevent “unused label” warnings.
845  goto typval_encode_stop_converting_one_item; // -V779
846 }
typval_T tv
Definition: typval.c:1539
dict_T * v_dict
Dictionary for VAR_DICT, can be NULL.
Definition: typval.h:134
#define TYPVAL_ENCODE_CONV_LIST_START(tv, len)
Definition: helpers.c:462
Unknown (unspecified) value.
Definition: typval.h:112
#define TYPVAL_ENCODE_CONV_STR_STRING
Definition: helpers.c:429
Definition: eval.h:119
#define HASHITEM_EMPTY(hi)
Definition: hashtab.h:19
#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:508
Partial, .v_partial is used.
Definition: typval.h:121
Convert mapping represented as a list_T* of pairs.
Definition: typval_encode.h:21
Definition: typval.h:166
#define TYPVAL_ENCODE_CONV_BOOL(tv, num)
Definition: helpers.c:407
tv_copy & TV_DICT_HI2DI(hi) ->di_tv, rettv
#define TYPVAL_ENCODE_CONV_REAL_LIST_AFTER_START(tv, mpsv)
Definition: helpers.c:465
Definition: coverity-model.c:65
#define _mp_pop
Definition: typval_encode.h:71
Structure that holds an internal variable value.
Definition: typval.h:125
#define TYPVAL_ENCODE_CONV_EXT_STRING(tv, str, len, type)
Definition: helpers.c:431
Definition: typval.h:150
struct MPConvStackVal::@6::@10 a
State of list or generic mapping conversion.
Definition: eval.h:120
#define TV_LIST_ITEM_TV(li)
Definition: typval.h:728
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:402
MPConvStackValType type
Type of the stack entry.
Definition: typval_encode.h:35
v:true
Definition: typval.h:99
#define TYPVAL_ENCODE_CONV_NIL(tv)
Definition: helpers.c:404
#define _mp_init
Definition: typval_encode.h:68
#define S_LEN(s)
Definition: macros.h:29
Definition: eval.h:124
void internal_error(char *where)
Give an "Internal error" message.
Definition: message.c:637
#define TYPVAL_ENCODE_CONV_EMPTY_LIST(tv)
Definition: helpers.c:444
return NULL
Definition: eval.c:22200
int len
Definition: helpers.c:1160
String, .v_string is used.
Definition: typval.h:114
int get_copyID(void)
Definition: eval.c:4992
Definition: eval.h:118
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:561
const dict_T *const TYPVAL_ENCODE_NODICT_VAR
Definition: typval_encode.c.h:250
Number, .v_number is used.
Definition: typval.h:113
#define TYPVAL_ENCODE_CONV_FLOAT(tv, flt)
Definition: helpers.c:415
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:100
static int REAL_FATTR_WARN_UNUSED_RESULT
Definition: typval_encode.c.h:295
int pt_argc
Number of arguments.
Definition: typval.h:295
Definition: eval.h:121
Definition: eval.h:117
Convert list_T *list.
Definition: typval_encode.h:20
VarType v_type
Variable type.
Definition: typval.h:126
partial_T * v_partial
Closure: function with args.
Definition: typval.h:135
Definition: typval.h:288
v:false
Definition: typval.h:98
SpecialVarValue v_special
Special value, for VAR_SPECIAL.
Definition: typval.h:130
#define STR(x)
Definition: macros.h:154
struct MPConvStackVal::@6::@7 d
State of dictionary conversion.
#define TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(tv, dict)
Definition: helpers.c:542
assert(len >=0)
#define TYPVAL_ENCODE_CONV_LIST_END(tv)
Definition: helpers.c:490
#define _mp_destroy
Definition: typval_encode.h:69
#define TYPVAL_ENCODE_FIRST_ARG_NAME
Definition: helpers.c:564
Definition: coverity-model.c:66
#define TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(tv)
Definition: helpers.c:477
#define TYPVAL_ENCODE_CONV_NUMBER(tv, num)
Definition: helpers.c:410
list_T * v_list
List for VAR_LIST, can be NULL.
Definition: typval.h:133
Definition: eval.h:116
char *const buf
Definition: encode.c:235
#define TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER
Definition: helpers.c:413
Definition: ex_cmds.c:5514
#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:1410
#define FAIL
Definition: vim.h:93
typval_T * pt_argv
Arguments in allocated array.
Definition: typval.h:296
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:441
Floating-point value, .v_float is used.
Definition: typval.h:118
typval_T * tv
Currently converted typval_T.
Definition: typval_encode.h:36
struct MPConvStackVal::@6::@8 l
State of list or generic mapping conversion.
#define REAL_FATTR_NONNULL_ARG(...)
Definition: func_attr.h:187
Definition: typval.h:119
char_u * v_string
String, for VAR_STRING and VAR_FUNC, can be NULL.
Definition: typval.h:132
union typval_T::typval_vval_union vval
Actual value.
dictitem_T *const di
Definition: typval.c:1528
union MPConvStackVal::@6 data
Data to convert.
#define TYPVAL_ENCODE_CONV_DICT_END(tv, dict)
Definition: helpers.c:555
varnumber_T v_number
Number, for VAR_NUMBER.
Definition: typval.h:129
#define _mp_push
Definition: typval_encode.h:70
List, .v_list is used.
Definition: typval.h:116
MPConvStackValType
Type of the stack entry.
Definition: typval_encode.h:18
About to convert arguments.
Definition: typval_encode.h:28
struct MPConvStackVal::@6::@9 p
State of partial conversion.
#define TYPVAL_ENCODE_CONV_FUNC_END(tv)
Definition: helpers.c:442
#define NOTDONE
Definition: vim.h:94
#define TV_LIST_ITEM_NEXT(l, li)
Definition: typval.h:736
#define TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, dict)
Definition: helpers.c:447
void argv[0] v_type
Definition: typval.c:1178
Definition: eval.h:123
MessagePackType
All recognized msgpack types.
Definition: eval.h:115
#define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun)
Definition: helpers.c:434
#define TYPVAL_ENCODE_CONV_RECURSE(val, conv_type)
Definition: helpers.c:558
Definition: eval.h:122
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:28
#define TYPVAL_ENCODE_CONV_DICT_START(tv, dict, len)
Definition: helpers.c:505
#define TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK(label, kv_pair)
Definition: helpers.c:510
Function reference, .v_string is used as function name.
Definition: typval.h:115
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:563
#define OK
Definition: vim.h:91
#define TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, len)
Definition: helpers.c:440
#define TYPVAL_ENCODE_CONV_STRING(tv, str, len)
Definition: helpers.c:418
#define TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(tv, dict)
Definition: helpers.c:529
err type
Definition: helpers.c:1169
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:117
float_T v_float
Floating-point number, for VAR_FLOAT.
Definition: typval.h:131
xfree(sourcing_name)
const list_T * eval_msgpack_type_lists[]
Array mapping values from MessagePackType to corresponding list pointers.
Definition: eval.c:521
char_u * partial_name(partial_T *pt)
Definition: eval.c:4849
dict_T * pt_dict
Dict for "self".
Definition: typval.h:297
#define ARRAY_SIZE(arr)
Definition: macros.h:140
#define _TYPVAL_ENCODE_CHECK_SELF_REFERENCE
Self reference checker function name.
Definition: typval_encode.h:131