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 
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);
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_BOOL: {
383  switch (tv->vval.v_bool) {
384  case kBoolVarTrue:
385  case kBoolVarFalse: {
387  break;
388  }
389  }
390  break;
391  }
392  case VAR_SPECIAL: {
393  switch (tv->vval.v_special) {
394  case kSpecialVarNull: {
395  TYPVAL_ENCODE_CONV_NIL(tv); // -V1037
396  break;
397  }
398  }
399  break;
400  }
401  case VAR_DICT: {
402  if (tv->vval.v_dict == NULL
403  || tv->vval.v_dict->dv_hashtab.ht_used == 0) {
405  break;
406  }
407  const dictitem_T *type_di;
408  const dictitem_T *val_di;
410  && tv->vval.v_dict->dv_hashtab.ht_used == 2
411  && (type_di = tv_dict_find((dict_T *)tv->vval.v_dict,
412  S_LEN("_TYPE"))) != NULL
413  && type_di->di_tv.v_type == VAR_LIST
414  && (val_di = tv_dict_find((dict_T *)tv->vval.v_dict,
415  S_LEN("_VAL"))) != NULL) {
416  size_t i;
417  for (i = 0; i < ARRAY_SIZE(eval_msgpack_type_lists); i++) {
418  if (type_di->di_tv.vval.v_list == eval_msgpack_type_lists[i]) {
419  break;
420  }
421  }
423  goto _convert_one_value_regular_dict;
424  }
425  switch ((MessagePackType)i) {
426  case kMPNil: {
428  break;
429  }
430  case kMPBoolean: {
431  if (val_di->di_tv.v_type != VAR_NUMBER) {
432  goto _convert_one_value_regular_dict;
433  }
434  TYPVAL_ENCODE_CONV_BOOL(tv, val_di->di_tv.vval.v_number);
435  break;
436  }
437  case kMPInteger: {
438  const list_T *val_list;
440  varnumber_T highest_bits;
441  varnumber_T high_bits;
442  varnumber_T low_bits;
443  // List of 4 integers; first is signed (should be 1 or -1, but
444  // this is not checked), second is unsigned and have at most
445  // one (sign is -1) or two (sign is 1) non-zero bits (number of
446  // bits is not checked), other unsigned and have at most 31
447  // non-zero bits (number of bits is not checked).
448  if (val_di->di_tv.v_type != VAR_LIST
449  || tv_list_len(val_list = val_di->di_tv.vval.v_list) != 4) {
450  goto _convert_one_value_regular_dict;
451  }
452 
453  const listitem_T *const sign_li = tv_list_first(val_list);
454  if (TV_LIST_ITEM_TV(sign_li)->v_type != VAR_NUMBER
455  || (sign = TV_LIST_ITEM_TV(sign_li)->vval.v_number) == 0) {
456  goto _convert_one_value_regular_dict;
457  }
458 
459  const listitem_T *const highest_bits_li = (
460  TV_LIST_ITEM_NEXT(val_list, sign_li));
461  if (TV_LIST_ITEM_TV(highest_bits_li)->v_type != VAR_NUMBER
462  || ((highest_bits
463  = TV_LIST_ITEM_TV(highest_bits_li)->vval.v_number)
464  < 0)) {
465  goto _convert_one_value_regular_dict;
466  }
467 
468  const listitem_T *const high_bits_li = (
469  TV_LIST_ITEM_NEXT(val_list, highest_bits_li));
470  if (TV_LIST_ITEM_TV(high_bits_li)->v_type != VAR_NUMBER
471  || ((high_bits = TV_LIST_ITEM_TV(high_bits_li)->vval.v_number)
472  < 0)) {
473  goto _convert_one_value_regular_dict;
474  }
475 
476  const listitem_T *const low_bits_li = tv_list_last(val_list);
477  if (TV_LIST_ITEM_TV(low_bits_li)->v_type != VAR_NUMBER
478  || ((low_bits = TV_LIST_ITEM_TV(low_bits_li)->vval.v_number)
479  < 0)) {
480  goto _convert_one_value_regular_dict;
481  }
482 
483  const uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62)
484  | (uint64_t)(((uint64_t)high_bits) << 31)
485  | (uint64_t)low_bits);
486  if (sign > 0) {
488  } else {
489  TYPVAL_ENCODE_CONV_NUMBER(tv, -number);
490  }
491  break;
492  }
493  case kMPFloat: {
494  if (val_di->di_tv.v_type != VAR_FLOAT) {
495  goto _convert_one_value_regular_dict;
496  }
497  TYPVAL_ENCODE_CONV_FLOAT(tv, val_di->di_tv.vval.v_float);
498  break;
499  }
500  case kMPString:
501  case kMPBinary: {
502  const bool is_string = ((MessagePackType)i == kMPString);
503  if (val_di->di_tv.v_type != VAR_LIST) {
504  goto _convert_one_value_regular_dict;
505  }
506  size_t len;
507  char *buf;
508  if (!encode_vim_list_to_buf(val_di->di_tv.vval.v_list, &len,
509  &buf)) {
510  goto _convert_one_value_regular_dict;
511  }
512  if (is_string) {
513  TYPVAL_ENCODE_CONV_STR_STRING(tv, buf, len);
514  } else { // -V523
515  TYPVAL_ENCODE_CONV_STRING(tv, buf, len);
516  }
517  xfree(buf);
518  break;
519  }
520  case kMPArray: {
521  if (val_di->di_tv.v_type != VAR_LIST) {
522  goto _convert_one_value_regular_dict;
523  }
524  const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
525  _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_di->di_tv.vval.v_list,
526  lv_copyID, copyID,
527  kMPConvList);
529  tv, tv_list_len(val_di->di_tv.vval.v_list));
530  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
531  _mp_push(*mpstack, ((MPConvStackVal) {
532  .tv = tv,
533  .type = kMPConvList,
534  .saved_copyID = saved_copyID,
535  .data = {
536  .l = {
537  .list = val_di->di_tv.vval.v_list,
538  .li = tv_list_first(val_di->di_tv.vval.v_list),
539  },
540  },
541  }));
542  break;
543  }
544  case kMPMap: {
545  if (val_di->di_tv.v_type != VAR_LIST) {
546  goto _convert_one_value_regular_dict;
547  }
548  list_T *const val_list = val_di->di_tv.vval.v_list;
549  if (val_list == NULL || tv_list_len(val_list) == 0) {
551  tv, TYPVAL_ENCODE_NODICT_VAR);
552  break;
553  }
554  TV_LIST_ITER_CONST(val_list, li, {
556  || tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) != 2) {
557  goto _convert_one_value_regular_dict;
558  }
559  });
560  const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
561  _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_list, lv_copyID, copyID,
562  kMPConvPairs);
563  TYPVAL_ENCODE_CONV_DICT_START(tv, TYPVAL_ENCODE_NODICT_VAR,
564  tv_list_len(val_list));
565  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
566  _mp_push(*mpstack, ((MPConvStackVal) {
567  .tv = tv,
568  .type = kMPConvPairs,
569  .saved_copyID = saved_copyID,
570  .data = {
571  .l = {
572  .list = val_list,
573  .li = tv_list_first(val_list),
574  },
575  },
576  }));
577  break;
578  }
579  case kMPExt: {
580  const list_T *val_list;
582  if (val_di->di_tv.v_type != VAR_LIST
583  || tv_list_len((val_list = val_di->di_tv.vval.v_list)) != 2
584  || (TV_LIST_ITEM_TV(tv_list_first(val_list))->v_type
585  != VAR_NUMBER)
586  || ((type
587  = TV_LIST_ITEM_TV(tv_list_first(val_list))->vval.v_number)
588  > INT8_MAX)
589  || type < INT8_MIN
590  || (TV_LIST_ITEM_TV(tv_list_last(val_list))->v_type
591  != VAR_LIST)) {
592  goto _convert_one_value_regular_dict;
593  }
594  size_t len;
595  char *buf;
596  if (!(
598  TV_LIST_ITEM_TV(tv_list_last(val_list))->vval.v_list, &len,
599  &buf))) {
600  goto _convert_one_value_regular_dict;
601  }
602  TYPVAL_ENCODE_CONV_EXT_STRING(tv, buf, len, type);
603  xfree(buf);
604  break;
605  }
606  }
607  break;
608  }
609 _convert_one_value_regular_dict: {}
610  const int saved_copyID = tv->vval.v_dict->dv_copyID;
611  _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_dict, dv_copyID, copyID,
612  kMPConvDict);
614  tv->vval.v_dict->dv_hashtab.ht_used);
615  assert(saved_copyID != copyID);
616  _mp_push(*mpstack, ((MPConvStackVal) {
617  .tv = tv,
618  .type = kMPConvDict,
619  .saved_copyID = saved_copyID,
620  .data = {
621  .d = {
622  .dict = tv->vval.v_dict,
623  .dictp = &tv->vval.v_dict,
624  .hi = tv->vval.v_dict->dv_hashtab.ht_array,
625  .todo = tv->vval.v_dict->dv_hashtab.ht_used,
626  },
627  },
628  }));
630  _mp_last(*mpstack));
631  break;
632  }
633  case VAR_UNKNOWN: {
635  return FAIL;
636  }
637  }
638 typval_encode_stop_converting_one_item:
639  return OK;
640  // Prevent “unused label” warnings.
641  goto typval_encode_stop_converting_one_item; // -V779
642 }
643 
646  typval_T *const tv, const char *const objname)
648 
660  typval_T *const top_tv, const char *const objname)
661 {
662  const int copyID = get_copyID();
663  MPConvStack mpstack;
664  _mp_init(mpstack);
665  if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack,
666  NULL,
667  top_tv, copyID, objname)
668  == FAIL) {
669  goto encode_vim_to__error_ret;
670  }
673 typval_encode_stop_converting_one_item:
674  while (_mp_size(mpstack)) {
675  MPConvStackVal *cur_mpsv = &_mp_last(mpstack);
676  typval_T *tv = NULL;
677  switch (cur_mpsv->type) {
678  case kMPConvDict: {
679  if (!cur_mpsv->data.d.todo) {
680  (void)_mp_pop(mpstack);
681  cur_mpsv->data.d.dict->dv_copyID = cur_mpsv->saved_copyID;
682  TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, *cur_mpsv->data.d.dictp);
683  continue;
684  } else if (cur_mpsv->data.d.todo
685  != cur_mpsv->data.d.dict->dv_hashtab.ht_used) {
687  *cur_mpsv->data.d.dictp);
688  }
689  while (HASHITEM_EMPTY(cur_mpsv->data.d.hi)) {
690  cur_mpsv->data.d.hi++;
691  }
692  dictitem_T *const di = TV_DICT_HI2DI(cur_mpsv->data.d.hi);
693  cur_mpsv->data.d.todo--;
694  cur_mpsv->data.d.hi++;
695  TYPVAL_ENCODE_CONV_STR_STRING(NULL, &di->di_key[0],
696  strlen((char *)&di->di_key[0]));
698  *cur_mpsv->data.d.dictp);
699  tv = &di->di_tv;
700  break;
701  }
702  case kMPConvList: {
703  if (cur_mpsv->data.l.li == NULL) {
704  (void)_mp_pop(mpstack);
705  tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
706  TYPVAL_ENCODE_CONV_LIST_END(cur_mpsv->tv);
707  continue;
708  } else if (cur_mpsv->data.l.li
709  != tv_list_first(cur_mpsv->data.l.list)) {
711  }
712  tv = TV_LIST_ITEM_TV(cur_mpsv->data.l.li);
713  cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
714  cur_mpsv->data.l.li);
715  break;
716  }
717  case kMPConvPairs: {
718  if (cur_mpsv->data.l.li == NULL) {
719  (void)_mp_pop(mpstack);
720  tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
721  TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
722  continue;
723  } else if (cur_mpsv->data.l.li
724  != tv_list_first(cur_mpsv->data.l.list)) {
726  cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
727  }
728  const list_T *const kv_pair = (
729  TV_LIST_ITEM_TV(cur_mpsv->data.l.li)->vval.v_list);
731  encode_vim_to__error_ret, *TV_LIST_ITEM_TV(tv_list_first(kv_pair)));
732  if (
734  TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack, cur_mpsv,
735  TV_LIST_ITEM_TV(tv_list_first(kv_pair)), copyID, objname)
736  == FAIL) {
737  goto encode_vim_to__error_ret;
738  }
740  TYPVAL_ENCODE_NODICT_VAR);
741  tv = TV_LIST_ITEM_TV(tv_list_last(kv_pair));
742  cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
743  cur_mpsv->data.l.li);
744  break;
745  }
746  case kMPConvPartial: {
747  partial_T *const pt = cur_mpsv->data.p.pt;
748  tv = cur_mpsv->tv;
749  (void)tv;
750  switch (cur_mpsv->data.p.stage) {
751  case kMPConvPartialArgs: {
753  pt == NULL ? 0 : pt->pt_argc);
754  cur_mpsv->data.p.stage = kMPConvPartialSelf;
755  if (pt != NULL && pt->pt_argc > 0) {
757  _mp_push(mpstack, ((MPConvStackVal) {
758  .type = kMPConvPartialList,
759  .tv = NULL,
760  .saved_copyID = copyID - 1,
761  .data = {
762  .a = {
763  .arg = pt->pt_argv,
764  .argv = pt->pt_argv,
765  .todo = (size_t)pt->pt_argc,
766  },
767  },
768  }));
769  }
770  break;
771  }
772  case kMPConvPartialSelf: {
773  cur_mpsv->data.p.stage = kMPConvPartialEnd;
774  dict_T *const dict = pt == NULL ? NULL : pt->pt_dict;
775  if (dict != NULL) {
776  TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, dict->dv_hashtab.ht_used);
777  if (dict->dv_hashtab.ht_used == 0) {
779  continue;
780  }
781  const int saved_copyID = dict->dv_copyID;
782  const int te_csr_ret = _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
783  TYPVAL_ENCODE_FIRST_ARG_NAME,
784  dict, &dict->dv_copyID, &mpstack, copyID, kMPConvDict,
785  objname);
786  if (te_csr_ret != NOTDONE) {
787  if (te_csr_ret == FAIL) {
788  goto encode_vim_to__error_ret;
789  } else {
790  continue;
791  }
792  }
794  dict->dv_hashtab.ht_used);
795  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
796  _mp_push(mpstack, ((MPConvStackVal) {
797  .type = kMPConvDict,
798  .tv = NULL,
799  .saved_copyID = saved_copyID,
800  .data = {
801  .d = {
802  .dict = dict,
803  .dictp = &pt->pt_dict,
804  .hi = dict->dv_hashtab.ht_array,
805  .todo = dict->dv_hashtab.ht_used,
806  },
807  },
808  }));
810  _mp_last(mpstack));
811  } else {
813  }
814  break;
815  }
816  case kMPConvPartialEnd: {
818  (void)_mp_pop(mpstack);
819  break;
820  }
821  }
822  continue;
823  }
824  case kMPConvPartialList: {
825  if (!cur_mpsv->data.a.todo) {
826  (void)_mp_pop(mpstack);
828  continue;
829  } else if (cur_mpsv->data.a.argv != cur_mpsv->data.a.arg) {
831  }
832  tv = cur_mpsv->data.a.arg++;
833  cur_mpsv->data.a.todo--;
834  break;
835  }
836  }
837  assert(tv != NULL);
838  if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack,
839  cur_mpsv, tv, copyID, objname)
840  == FAIL) {
841  goto encode_vim_to__error_ret;
842  }
843  }
844  _mp_destroy(mpstack);
845  return OK;
846 encode_vim_to__error_ret:
847  _mp_destroy(mpstack);
848  return FAIL;
849  // Prevent “unused label” warnings.
850  goto typval_encode_stop_converting_one_item; // -V779
851 }
typval_T tv
Definition: typval.c:1562
dict_T * v_dict
Dictionary for VAR_DICT, can be NULL.
Definition: typval.h:138
#define TYPVAL_ENCODE_CONV_LIST_START(tv, len)
Definition: helpers.c:471
Unknown (unspecified) value.
Definition: typval.h:114
#define TYPVAL_ENCODE_CONV_STR_STRING
Definition: helpers.c:438
Definition: eval.h:170
#define HASHITEM_EMPTY(hi)
Definition: hashtab.h:19
BoolVarValue v_bool
Bool value, for VAR_BOOL.
Definition: typval.h:133
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:124
Convert mapping represented as a list_T* of pairs.
Definition: typval_encode.h:21
xfree(sourcing_name)
#define INT8_MAX
Definition: umachine.h:198
Definition: typval.h:170
#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:128
#define TYPVAL_ENCODE_CONV_EXT_STRING(tv, str, len, type)
Definition: helpers.c:440
Definition: typval.h:154
Definition: eval.h:171
#define TV_LIST_ITEM_TV(li)
Definition: typval.h:772
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
#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
Definition: eval.h:175
void internal_error(char *where)
Give an "Internal error" message.
Definition: message.c:816
#define TYPVAL_ENCODE_CONV_EMPTY_LIST(tv)
Definition: helpers.c:453
return NULL
Definition: eval.c:9784
String, .v_string is used.
Definition: typval.h:116
int get_copyID(void)
Definition: eval.c:4835
Definition: eval.h:169
Structure representing current VimL to messagepack conversion state.
Definition: typval_encode.h:34
Convert partial_T* partial.
Definition: typval_encode.h:22
v:false
Definition: typval.h:96
#define TYPVAL_ENCODE_SCOPE
Definition: helpers.c:570
int len
Definition: helpers.c:1464
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:115
#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:102
static int REAL_FATTR_WARN_UNUSED_RESULT
Definition: typval_encode.c.h:295
int pt_argc
Number of arguments.
Definition: typval.h:339
return OK
Definition: eval.c:769
Definition: eval.h:172
Definition: eval.h:168
#define INT8_MIN
Definition: umachine.h:185
Convert list_T *list.
Definition: typval_encode.h:20
VarType v_type
Variable type.
Definition: typval.h:129
struct MPConvStackVal::@9::@11 l
State of list or generic mapping conversion.
partial_T * v_partial
Closure: function with args.
Definition: typval.h:139
Definition: typval.h:332
SpecialVarValue v_special
Special value, for VAR_SPECIAL.
Definition: typval.h:134
#define STR(x)
Definition: macros.h:151
void argv[0] v_type
Definition: typval.c:1179
#define TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(tv, dict)
Definition: helpers.c:551
assert(len >=0)
#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:137
Definition: eval.h:167
char *const buf
Definition: encode.c:234
#define TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER
Definition: helpers.c:422
Definition: sign.c:25
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:1416
typval_T * pt_argv
Arguments in allocated array.
Definition: typval.h:340
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:658
#define TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, len)
Definition: helpers.c:450
Floating-point value, .v_float is used.
Definition: typval.h:120
typval_T * tv
Currently converted typval_T.
Definition: typval_encode.h:36
#define REAL_FATTR_NONNULL_ARG(...)
Definition: func_attr.h:187
Definition: typval.h:122
char_u * v_string
String, for VAR_STRING and VAR_FUNC, can be NULL.
Definition: typval.h:136
union typval_T::typval_vval_union vval
Actual value.
dictitem_T *const di
Definition: typval.c:1551
#define TYPVAL_ENCODE_CONV_DICT_END(tv, dict)
Definition: helpers.c:564
varnumber_T v_number
Number, for VAR_NUMBER.
Definition: typval.h:132
#define _mp_push
Definition: typval_encode.h:70
List, .v_list is used.
Definition: typval.h:118
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:780
void(WINAPI *pClosePseudoConsole)(HPCON)
#define TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, dict)
Definition: helpers.c:456
Definition: eval.h:174
MessagePackType
All recognized msgpack types.
Definition: eval.h:166
#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
Definition: eval.h:173
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:766
#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:117
int i
Definition: typval.c:869
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:1473
true, false
Definition: typval.h:121
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:119
float_T v_float
Floating-point number, for VAR_FLOAT.
Definition: typval.h:135
listitem_T * li
Definition: eval.c:6831
const list_T * eval_msgpack_type_lists[]
Array mapping values from MessagePackType to corresponding list pointers.
Definition: eval.c:275
char_u * partial_name(partial_T *pt)
Definition: eval.c:4692
dict_T * pt_dict
Dict for "self".
Definition: typval.h:341
#define ARRAY_SIZE(arr)
Definition: macros.h:137
v:true
Definition: typval.h:97
#define _TYPVAL_ENCODE_CHECK_SELF_REFERENCE
Self reference checker function name.
Definition: typval_encode.h:131