typval_encode.c.h
Go to the documentation of this file.
1 
15 
26 
33 
43 
50 
61 
72 
85 
92 
98 
105 
113 
118 
123 
131 
138 
148 
153 
158 
171 
179 
185 
193 
201 
209 
215 
221 
224 
232 
237 
243 #include <assert.h>
244 #include <inttypes.h>
245 #include <stddef.h>
246 
247 #include "nvim/eval/encode.h"
248 #include "nvim/eval/typval.h"
249 #include "nvim/eval/typval_encode.h"
250 #include "nvim/func_attr.h"
251 #include "nvim/lib/kvec.h"
252 
253 // -V::1063
254 
260 
261 static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
263  void *const val, int *const val_copyID,
264  const MPConvStack *const mpstack, const int copyID,
265  const MPConvStackValType conv_type,
266  const char *const objname)
269 
284 static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
285  TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME, void *const val, int *const val_copyID,
286  const MPConvStack *const mpstack, const int copyID, const MPConvStackValType conv_type,
287  const char *const objname)
288 {
289  if (*val_copyID == copyID) {
290  TYPVAL_ENCODE_CONV_RECURSE(val, conv_type);
291  return OK;
292  }
293  *val_copyID = copyID;
294  return NOTDONE;
295 }
296 
299  MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
300  typval_T *const tv, const int copyID,
301  const char *const objname)
303 
323  MPConvStackVal *const cur_mpsv, typval_T *const tv, const int copyID, const char *const objname)
324 {
325  switch (tv->v_type) {
326  case VAR_STRING:
328  break;
329  case VAR_NUMBER:
331  break;
332  case VAR_FLOAT:
334  break;
335  case VAR_BLOB:
337  tv_blob_len(tv->vval.v_blob));
338  break;
339  case VAR_FUNC:
344  break;
345  case VAR_PARTIAL: {
346  partial_T *const pt = tv->vval.v_partial;
347  (void)pt;
348  TYPVAL_ENCODE_CONV_FUNC_START(tv, (pt == NULL ? NULL : (char_u *)partial_name(pt))); // -V547
349  _mp_push(*mpstack, ((MPConvStackVal) { // -V779
350  .type = kMPConvPartial,
351  .tv = tv,
352  .saved_copyID = copyID - 1,
353  .data = {
354  .p = {
355  .stage = kMPConvPartialArgs,
356  .pt = tv->vval.v_partial,
357  },
358  },
359  }));
360  break;
361  }
362  case VAR_LIST: {
363  if (tv->vval.v_list == NULL || tv_list_len(tv->vval.v_list) == 0) {
365  break;
366  }
367  const int saved_copyID = tv_list_copyid(tv->vval.v_list);
369  kMPConvList);
371  assert(saved_copyID != copyID);
372  _mp_push(*mpstack, ((MPConvStackVal) {
373  .type = kMPConvList,
374  .tv = tv,
375  .saved_copyID = saved_copyID,
376  .data = {
377  .l = {
378  .list = tv->vval.v_list,
379  .li = tv_list_first(tv->vval.v_list),
380  },
381  },
382  }));
384  break;
385  }
386  case VAR_BOOL:
387  switch (tv->vval.v_bool) {
388  case kBoolVarTrue:
389  case kBoolVarFalse:
391  break;
392  }
393  break;
394  case VAR_SPECIAL:
395  switch (tv->vval.v_special) {
396  case kSpecialVarNull:
397  TYPVAL_ENCODE_CONV_NIL(tv); // -V1037
398  break;
399  }
400  break;
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  case kMPBoolean:
430  if (val_di->di_tv.v_type != VAR_NUMBER) {
431  goto _convert_one_value_regular_dict;
432  }
433  TYPVAL_ENCODE_CONV_BOOL(tv, val_di->di_tv.vval.v_number);
434  break;
435  case kMPInteger: {
436  const list_T *val_list;
438  varnumber_T highest_bits;
439  varnumber_T high_bits;
440  varnumber_T low_bits;
441  // List of 4 integers; first is signed (should be 1 or -1, but
442  // this is not checked), second is unsigned and have at most
443  // one (sign is -1) or two (sign is 1) non-zero bits (number of
444  // bits is not checked), other unsigned and have at most 31
445  // non-zero bits (number of bits is not checked).
446  if (val_di->di_tv.v_type != VAR_LIST
447  || tv_list_len(val_list = val_di->di_tv.vval.v_list) != 4) {
448  goto _convert_one_value_regular_dict;
449  }
450 
451  const listitem_T *const sign_li = tv_list_first(val_list);
452  if (TV_LIST_ITEM_TV(sign_li)->v_type != VAR_NUMBER
453  || (sign = TV_LIST_ITEM_TV(sign_li)->vval.v_number) == 0) {
454  goto _convert_one_value_regular_dict;
455  }
456 
457  const listitem_T *const highest_bits_li = (
458  TV_LIST_ITEM_NEXT(val_list, sign_li));
459  if (TV_LIST_ITEM_TV(highest_bits_li)->v_type != VAR_NUMBER
460  || ((highest_bits
461  = TV_LIST_ITEM_TV(highest_bits_li)->vval.v_number)
462  < 0)) {
463  goto _convert_one_value_regular_dict;
464  }
465 
466  const listitem_T *const high_bits_li = (
467  TV_LIST_ITEM_NEXT(val_list, highest_bits_li));
468  if (TV_LIST_ITEM_TV(high_bits_li)->v_type != VAR_NUMBER
469  || ((high_bits = TV_LIST_ITEM_TV(high_bits_li)->vval.v_number)
470  < 0)) {
471  goto _convert_one_value_regular_dict;
472  }
473 
474  const listitem_T *const low_bits_li = tv_list_last(val_list);
475  if (TV_LIST_ITEM_TV(low_bits_li)->v_type != VAR_NUMBER
476  || ((low_bits = TV_LIST_ITEM_TV(low_bits_li)->vval.v_number)
477  < 0)) {
478  goto _convert_one_value_regular_dict;
479  }
480 
481  const uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62)
482  | (uint64_t)(((uint64_t)high_bits) << 31)
483  | (uint64_t)low_bits);
484  if (sign > 0) {
486  } else {
487  TYPVAL_ENCODE_CONV_NUMBER(tv, -number);
488  }
489  break;
490  }
491  case kMPFloat:
492  if (val_di->di_tv.v_type != VAR_FLOAT) {
493  goto _convert_one_value_regular_dict;
494  }
495  TYPVAL_ENCODE_CONV_FLOAT(tv, val_di->di_tv.vval.v_float);
496  break;
497  case kMPString:
498  case kMPBinary: {
499  const bool is_string = ((MessagePackType)i == kMPString);
500  if (val_di->di_tv.v_type != VAR_LIST) {
501  goto _convert_one_value_regular_dict;
502  }
503  size_t len;
504  char *buf;
505  if (!encode_vim_list_to_buf(val_di->di_tv.vval.v_list, &len,
506  &buf)) {
507  goto _convert_one_value_regular_dict;
508  }
509  if (is_string) {
511  } else { // -V523
513  }
514  xfree(buf);
515  break;
516  }
517  case kMPArray: {
518  if (val_di->di_tv.v_type != VAR_LIST) {
519  goto _convert_one_value_regular_dict;
520  }
521  const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
522  _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_di->di_tv.vval.v_list,
523  lv_copyID, copyID,
524  kMPConvList);
525  TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(val_di->di_tv.vval.v_list));
526  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
527  _mp_push(*mpstack, ((MPConvStackVal) {
528  .tv = tv,
529  .type = kMPConvList,
530  .saved_copyID = saved_copyID,
531  .data = {
532  .l = {
533  .list = val_di->di_tv.vval.v_list,
534  .li = tv_list_first(val_di->di_tv.vval.v_list),
535  },
536  },
537  }));
538  break;
539  }
540  case kMPMap: {
541  if (val_di->di_tv.v_type != VAR_LIST) {
542  goto _convert_one_value_regular_dict;
543  }
544  list_T *const val_list = val_di->di_tv.vval.v_list;
545  if (val_list == NULL || tv_list_len(val_list) == 0) {
548  break;
549  }
550  TV_LIST_ITER_CONST(val_list, li, {
552  || tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) != 2) {
553  goto _convert_one_value_regular_dict;
554  }
555  });
556  const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
557  _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_list, lv_copyID, copyID,
558  kMPConvPairs);
560  tv_list_len(val_list));
561  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
562  _mp_push(*mpstack, ((MPConvStackVal) {
563  .tv = tv,
564  .type = kMPConvPairs,
565  .saved_copyID = saved_copyID,
566  .data = {
567  .l = {
568  .list = val_list,
569  .li = tv_list_first(val_list),
570  },
571  },
572  }));
573  break;
574  }
575  case kMPExt: {
576  const list_T *val_list;
578  if (val_di->di_tv.v_type != VAR_LIST
579  || tv_list_len((val_list = val_di->di_tv.vval.v_list)) != 2
580  || (TV_LIST_ITEM_TV(tv_list_first(val_list))->v_type
581  != VAR_NUMBER)
582  || ((type
583  = TV_LIST_ITEM_TV(tv_list_first(val_list))->vval.v_number)
584  > INT8_MAX)
585  || type < INT8_MIN
586  || (TV_LIST_ITEM_TV(tv_list_last(val_list))->v_type
587  != VAR_LIST)) {
588  goto _convert_one_value_regular_dict;
589  }
590  size_t len;
591  char *buf;
592  if (!(
593  encode_vim_list_to_buf(TV_LIST_ITEM_TV(tv_list_last(val_list))->vval.v_list, &len,
594  &buf))) {
595  goto _convert_one_value_regular_dict;
596  }
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;
607  kMPConvDict);
609  tv->vval.v_dict->dv_hashtab.ht_used);
610  assert(saved_copyID != copyID);
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 typval_encode_stop_converting_one_item:
633  return OK;
634  // Prevent “unused label” warnings.
635  goto typval_encode_stop_converting_one_item; // -V779
636 }
637 
640  typval_T *const tv, const char *const objname)
642 
654  const char *const objname)
655 {
656  const int copyID = get_copyID();
657  MPConvStack mpstack;
658  _mp_init(mpstack);
660  NULL,
661  top_tv, copyID, objname)
662  == FAIL) {
663  goto encode_vim_to__error_ret;
664  }
667 typval_encode_stop_converting_one_item:
668  while (_mp_size(mpstack)) {
669  MPConvStackVal *cur_mpsv = &_mp_last(mpstack);
670  typval_T *tv = NULL;
671  switch (cur_mpsv->type) {
672  case kMPConvDict: {
673  if (!cur_mpsv->data.d.todo) {
674  (void)_mp_pop(mpstack);
675  cur_mpsv->data.d.dict->dv_copyID = cur_mpsv->saved_copyID;
676  TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, *cur_mpsv->data.d.dictp);
677  continue;
678  } else if (cur_mpsv->data.d.todo
679  != cur_mpsv->data.d.dict->dv_hashtab.ht_used) {
681  *cur_mpsv->data.d.dictp);
682  }
683  while (HASHITEM_EMPTY(cur_mpsv->data.d.hi)) {
684  cur_mpsv->data.d.hi++;
685  }
686  dictitem_T *const di = TV_DICT_HI2DI(cur_mpsv->data.d.hi);
687  cur_mpsv->data.d.todo--;
688  cur_mpsv->data.d.hi++;
690  strlen((char *)&di->di_key[0]));
692  *cur_mpsv->data.d.dictp);
693  tv = &di->di_tv;
694  break;
695  }
696  case kMPConvList:
697  if (cur_mpsv->data.l.li == NULL) {
698  (void)_mp_pop(mpstack);
699  tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
700  TYPVAL_ENCODE_CONV_LIST_END(cur_mpsv->tv);
701  continue;
702  } else if (cur_mpsv->data.l.li
703  != tv_list_first(cur_mpsv->data.l.list)) {
705  }
706  tv = TV_LIST_ITEM_TV(cur_mpsv->data.l.li);
707  cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
708  cur_mpsv->data.l.li);
709  break;
710  case kMPConvPairs: {
711  if (cur_mpsv->data.l.li == NULL) {
712  (void)_mp_pop(mpstack);
713  tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
715  continue;
716  } else if (cur_mpsv->data.l.li
717  != tv_list_first(cur_mpsv->data.l.list)) {
719  }
720  const list_T *const kv_pair = (
721  TV_LIST_ITEM_TV(cur_mpsv->data.l.li)->vval.v_list);
722  TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK(encode_vim_to__error_ret,
723  *TV_LIST_ITEM_TV(tv_list_first(kv_pair)));
724  if (
726  TV_LIST_ITEM_TV(tv_list_first(kv_pair)), copyID, objname)
727  == FAIL) {
728  goto encode_vim_to__error_ret;
729  }
732  tv = TV_LIST_ITEM_TV(tv_list_last(kv_pair));
733  cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
734  cur_mpsv->data.l.li);
735  break;
736  }
737  case kMPConvPartial: {
738  partial_T *const pt = cur_mpsv->data.p.pt;
739  tv = cur_mpsv->tv;
740  (void)tv;
741  switch (cur_mpsv->data.p.stage) {
742  case kMPConvPartialArgs:
744  pt == NULL ? 0 : pt->pt_argc);
745  cur_mpsv->data.p.stage = kMPConvPartialSelf;
746  if (pt != NULL && pt->pt_argc > 0) {
748  _mp_push(mpstack, ((MPConvStackVal) {
749  .type = kMPConvPartialList,
750  .tv = NULL,
751  .saved_copyID = copyID - 1,
752  .data = {
753  .a = {
754  .arg = pt->pt_argv,
755  .argv = pt->pt_argv,
756  .todo = (size_t)pt->pt_argc,
757  },
758  },
759  }));
760  }
761  break;
762  case kMPConvPartialSelf: {
763  cur_mpsv->data.p.stage = kMPConvPartialEnd;
764  dict_T *const dict = pt == NULL ? NULL : pt->pt_dict;
765  if (dict != NULL) {
766  TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, dict->dv_hashtab.ht_used);
767  if (dict->dv_hashtab.ht_used == 0) {
769  continue;
770  }
771  const int saved_copyID = dict->dv_copyID;
773  dict, &dict->dv_copyID,
774  &mpstack, copyID, kMPConvDict,
775  objname);
776  if (te_csr_ret != NOTDONE) {
777  if (te_csr_ret == FAIL) {
778  goto encode_vim_to__error_ret;
779  } else {
780  continue;
781  }
782  }
784  dict->dv_hashtab.ht_used);
785  assert(saved_copyID != copyID && saved_copyID != copyID - 1);
786  _mp_push(mpstack, ((MPConvStackVal) {
787  .type = kMPConvDict,
788  .tv = NULL,
789  .saved_copyID = saved_copyID,
790  .data = {
791  .d = {
792  .dict = dict,
793  .dictp = &pt->pt_dict,
794  .hi = dict->dv_hashtab.ht_array,
795  .todo = dict->dv_hashtab.ht_used,
796  },
797  },
798  }));
800  _mp_last(mpstack));
801  } else {
803  }
804  break;
805  }
806  case kMPConvPartialEnd:
808  (void)_mp_pop(mpstack);
809  break;
810  }
811  continue;
812  }
813  case kMPConvPartialList:
814  if (!cur_mpsv->data.a.todo) {
815  (void)_mp_pop(mpstack);
817  continue;
818  } else if (cur_mpsv->data.a.argv != cur_mpsv->data.a.arg) {
820  }
821  tv = cur_mpsv->data.a.arg++;
822  cur_mpsv->data.a.todo--;
823  break;
824  }
825  assert(tv != NULL);
827  cur_mpsv, tv, copyID, objname)
828  == FAIL) {
829  goto encode_vim_to__error_ret;
830  }
831  }
832  _mp_destroy(mpstack);
833  return OK;
834 encode_vim_to__error_ret:
835  _mp_destroy(mpstack);
836  return FAIL;
837  // Prevent “unused label” warnings.
838  goto typval_encode_stop_converting_one_item; // -V779
839 }
kMPInteger
@ kMPInteger
Definition: eval.h:181
_mp_init
#define _mp_init
Definition: typval_encode.h:68
_TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE
#define _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val, copyID_attr, copyID, conv_type)
Definition: typval_encode.h:99
VAR_FLOAT
@ VAR_FLOAT
Floating-point value, .v_float is used.
Definition: typval.h:126
TYPVAL_ENCODE_ALLOW_SPECIALS
#define TYPVAL_ENCODE_ALLOW_SPECIALS
Definition: converter.c:26
typval_T::typval_vval_union::v_special
SpecialVarValue v_special
Special value, for VAR_SPECIAL.
Definition: typval.h:141
partial_S::pt_dict
dict_T * pt_dict
Dict for "self".
Definition: typval.h:373
tv
typval_T tv
Definition: typval.c:1705
TV_LIST_ITER_CONST
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);} })
typval_T::typval_vval_union::v_number
varnumber_T v_number
Number, for VAR_NUMBER.
Definition: typval.h:139
TYPVAL_ENCODE_CONV_BLOB
#define TYPVAL_ENCODE_CONV_BLOB(tv, blob, len)
Definition: converter.c:55
MPConvStackVal::saved_copyID
int saved_copyID
copyID item used to have.
Definition: typval_encode.h:37
typval_T
Structure that holds an internal variable value.
Definition: typval.h:135
kMPBinary
@ kMPBinary
Definition: eval.h:184
typval_T::typval_vval_union::v_partial
partial_T * v_partial
Closure: function with args.
Definition: typval.h:146
TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS
#define TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(tv)
Definition: converter.c:113
TYPVAL_ENCODE_FIRST_ARG_TYPE
#define TYPVAL_ENCODE_FIRST_ARG_TYPE
Definition: converter.c:197
TYPVAL_ENCODE_SCOPE
#define TYPVAL_ENCODE_SCOPE
Definition: converter.c:195
encode.h
VAR_STRING
@ VAR_STRING
String, .v_string is used.
Definition: typval.h:122
i
static void int i
Definition: edit.c:3047
kMPConvPartialArgs
@ kMPConvPartialArgs
About to convert arguments.
Definition: typval_encode.h:28
typval_encode.h
listvar_S
Definition: typval.h:178
TV_LIST_ITEM_NEXT
#define TV_LIST_ITEM_NEXT(l, li)
Definition: typval.h:867
TYPVAL_ENCODE_CONV_EMPTY_DICT
#define TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, dict)
Definition: converter.c:84
MPConvStackVal::d
struct MPConvStackVal::@19::@20 d
State of dictionary conversion.
_mp_destroy
#define _mp_destroy
Definition: typval_encode.h:69
TYPVAL_ENCODE_CONV_FUNC_START
#define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun)
Definition: converter.c:65
internal_error
void internal_error(char *where)
Give an "Internal error" message.
Definition: message.c:817
MPConvStackVal::l
struct MPConvStackVal::@19::@21 l
State of list or generic mapping conversion.
TYPVAL_ENCODE_CONV_FUNC_END
#define TYPVAL_ENCODE_CONV_FUNC_END(tv)
Definition: converter.c:79
VAR_UNKNOWN
@ VAR_UNKNOWN
Unknown (unspecified) value.
Definition: typval.h:120
type
err type
Definition: helpers.c:1114
kMPFloat
@ kMPFloat
Definition: eval.h:182
_mp_size
#define _mp_size
Definition: typval_encode.h:67
TYPVAL_ENCODE_CONV_STRING
#define TYPVAL_ENCODE_CONV_STRING(tv, str, len)
Definition: converter.c:42
TYPVAL_ENCODE_CONV_BOOL
#define TYPVAL_ENCODE_CONV_BOOL(tv, num)
Definition: converter.c:31
kMPConvPartialSelf
@ kMPConvPartialSelf
About to convert self dictionary.
Definition: typval_encode.h:29
TYPVAL_ENCODE_CONV_NIL
#define TYPVAL_ENCODE_CONV_NIL(tv)
Definition: converter.c:28
MPConvStackValType
MPConvStackValType
Type of the stack entry.
Definition: typval_encode.h:18
eval_msgpack_type_lists
const list_T * eval_msgpack_type_lists[]
Array mapping values from MessagePackType to corresponding list pointers.
Definition: eval.c:295
assert.h
TYPVAL_ENCODE_CONV_EXT_STRING
#define TYPVAL_ENCODE_CONV_EXT_STRING(tv, str, len, type)
Definition: converter.c:52
MPConvStackVal
Structure representing current VimL to messagepack conversion state.
Definition: typval_encode.h:34
kMPConvPairs
@ kMPConvPairs
Convert mapping represented as a list_T* of pairs.
Definition: typval_encode.h:21
TYPVAL_ENCODE_CONV_FLOAT
#define TYPVAL_ENCODE_CONV_FLOAT(tv, flt)
Definition: converter.c:39
TYPVAL_ENCODE_CONV_DICT_START
#define TYPVAL_ENCODE_CONV_DICT_START(tv, dict, len)
Definition: converter.c:139
TYPVAL_ENCODE_CONV_RECURSE
#define TYPVAL_ENCODE_CONV_RECURSE(val, conv_type)
Definition: converter.c:192
kMPNil
@ kMPNil
Definition: eval.h:179
typval_T::typval_vval_union::v_string
char * v_string
String, for VAR_STRING and VAR_FUNC, can be NULL.
Definition: typval.h:143
typval_T::typval_vval_union::v_list
list_T * v_list
List for VAR_LIST, can be NULL.
Definition: typval.h:144
kBoolVarFalse
@ kBoolVarFalse
v:false
Definition: typval.h:102
typval_T::typval_vval_union::v_float
float_T v_float
Floating-point number, for VAR_FLOAT.
Definition: typval.h:142
_mp_last
#define _mp_last
Definition: typval_encode.h:72
_TYPVAL_ENCODE_CHECK_SELF_REFERENCE
#define _TYPVAL_ENCODE_CHECK_SELF_REFERENCE
Self reference checker function name.
Definition: typval_encode.h:129
MPConvStackVal::a
struct MPConvStackVal::@19::@23 a
State of list or generic mapping conversion.
typval_T::typval_vval_union::v_bool
BoolVarValue v_bool
Bool value, for VAR_BOOL.
Definition: typval.h:140
partial_S::pt_argc
int pt_argc
Number of arguments.
Definition: typval.h:371
kMPString
@ kMPString
Definition: eval.h:183
void
void(WINAPI *pClosePseudoConsole)(HPCON)
TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER
#define TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER
Definition: converter.c:37
typval_T::v_type
VarType v_type
Variable type.
Definition: typval.h:136
TYPVAL_ENCODE_CONV_EMPTY_LIST
#define TYPVAL_ENCODE_CONV_EMPTY_LIST(tv)
Definition: converter.c:81
kMPConvPartialEnd
@ kMPConvPartialEnd
Already converted everything.
Definition: typval_encode.h:30
MPConvStackVal::type
MPConvStackValType type
Type of the stack entry.
Definition: typval_encode.h:35
partial_S::pt_argv
typval_T * pt_argv
Arguments in allocated array.
Definition: typval.h:372
MPConvStackVal::tv
typval_T * tv
Currently converted typval_T.
Definition: typval_encode.h:36
TV_LIST_ITEM_TV
#define TV_LIST_ITEM_TV(li)
Definition: typval.h:859
TYPVAL_ENCODE_CONV_LIST_END
#define TYPVAL_ENCODE_CONV_LIST_END(tv)
Definition: converter.c:126
TYPVAL_ENCODE_CONV_DICT_AFTER_KEY
#define TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(tv, dict)
Definition: converter.c:163
tv_dict_find
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:1540
_TYPVAL_ENCODE_CONVERT_ONE_VALUE
#define _TYPVAL_ENCODE_CONVERT_ONE_VALUE
Name of the …convert_one_value function.
Definition: typval_encode.h:137
MPConvStackVal::data
union MPConvStackVal::@19 data
Data to convert.
encode_vim_list_to_buf
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
kMPMap
@ kMPMap
Definition: eval.h:186
MessagePackType
MessagePackType
All recognized msgpack types.
Definition: eval.h:178
VAR_PARTIAL
@ VAR_PARTIAL
Partial, .v_partial is used.
Definition: typval.h:130
TYPVAL_ENCODE_CONV_REAL_LIST_AFTER_START
#define TYPVAL_ENCODE_CONV_REAL_LIST_AFTER_START(tv, mpsv)
Definition: converter.c:101
VAR_BOOL
@ VAR_BOOL
true, false
Definition: typval.h:127
typval_T::typval_vval_union::v_blob
blob_T * v_blob
Blob for VAR_BLOB, can be NULL.
Definition: typval.h:147
typval_T::typval_vval_union::v_dict
dict_T * v_dict
Dictionary for VAR_DICT, can be NULL.
Definition: typval.h:145
VAR_BLOB
@ VAR_BLOB
Blob, .v_blob is used.
Definition: typval.h:131
VAR_LIST
@ VAR_LIST
List, .v_list is used.
Definition: typval.h:124
OK
#define OK
Definition: vim.h:90
kvec.h
VAR_SPECIAL
@ VAR_SPECIAL
Definition: typval.h:128
buf
char *const buf
Definition: encode.c:234
kMPConvPartial
@ kMPConvPartial
Convert partial_T* partial.
Definition: typval_encode.h:22
TYPVAL_ENCODE_CONV_DICT_END
#define TYPVAL_ENCODE_CONV_DICT_END(tv, dict)
Definition: converter.c:189
partial_S
Definition: typval.h:364
kMPArray
@ kMPArray
Definition: eval.h:185
kMPConvPartialList
@ kMPConvPartialList
Convert argc/argv pair coming from a partial.
Definition: typval_encode.h:23
VAR_NUMBER
@ VAR_NUMBER
Number, .v_number is used.
Definition: typval.h:121
TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS
#define TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(tv, dict)
Definition: converter.c:176
assert
assert(len >=0)
varnumber_T
int64_t varnumber_T
Type used for VimL VAR_NUMBER values.
Definition: typval.h:26
kMPBoolean
@ kMPBoolean
Definition: eval.h:180
typval.h
li
listitem_T * li
Definition: eval.c:6883
typval_T::vval
union typval_T::typval_vval_union vval
Actual value.
FAIL
return FAIL
Definition: ex_docmd.c:5624
REAL_FATTR_NONNULL_ARG
#define REAL_FATTR_NONNULL_ARG(...)
Definition: func_attr.h:187
TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF
#define TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, len)
Definition: converter.c:78
kMPConvList
@ kMPConvList
Convert list_T *list.
Definition: typval_encode.h:20
v_type
void argv[0] v_type
Definition: typval.c:1286
partial_name
char * partial_name(partial_T *pt) FUNC_ATTR_PURE
Definition: eval.c:5048
TYPVAL_ENCODE_FIRST_ARG_NAME
#define TYPVAL_ENCODE_FIRST_ARG_NAME
Definition: converter.c:198
_mp_pop
#define _mp_pop
Definition: typval_encode.h:71
NOTDONE
#define NOTDONE
Definition: vim.h:93
VAR_FUNC
@ VAR_FUNC
Function reference, .v_string is used as function name.
Definition: typval.h:123
dictitem_T
Definition: coverity-model.c:39
S_LEN
#define S_LEN(s)
Definition: macros.h:32
listitem_S
Definition: typval.h:162
char_u
unsigned char char_u
Definition: types.h:12
MPConvStackVal::p
struct MPConvStackVal::@19::@22 p
State of partial conversion.
_mp_push
#define _mp_push
Definition: typval_encode.h:70
ARRAY_SIZE
#define ARRAY_SIZE(arr)
Definition: macros.h:127
kMPConvDict
@ kMPConvDict
Convert dict_T *dictionary.
Definition: typval_encode.h:19
TV_DICT_HI2DI
tv_copy & TV_DICT_HI2DI(hi) ->di_tv, rettv
dict_T
Definition: coverity-model.c:40
kBoolVarTrue
@ kBoolVarTrue
v:true
Definition: typval.h:103
kSpecialVarNull
@ kSpecialVarNull
v:null
Definition: typval.h:108
VAR_DICT
@ VAR_DICT
Dictionary, .v_dict is used.
Definition: typval.h:125
func_attr.h
REAL_FATTR_ALWAYS_INLINE
static int REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE
Definition: typval_encode.c.h:267
get_copyID
int get_copyID(void)
Definition: eval.c:5189
TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START
#define TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(tv, dict, mpsv)
Definition: converter.c:142
TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS
#define TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, len)
Definition: converter.c:77
sign
Definition: sign.c:27
TYPVAL_ENCODE_CONV_LIST_START
#define TYPVAL_ENCODE_CONV_LIST_START(tv, len)
Definition: converter.c:98
TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK
#define TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK(label, kv_pair)
Definition: converter.c:144
NULL
return NULL
Definition: eval.c:9968
TYPVAL_ENCODE_CONV_STR_STRING
#define TYPVAL_ENCODE_CONV_STR_STRING
Definition: converter.c:50
REAL_FATTR_WARN_UNUSED_RESULT
static int REAL_FATTR_WARN_UNUSED_RESULT
Definition: typval_encode.c.h:302
xfree
xfree(pat2)
kMPExt
@ kMPExt
Definition: eval.h:187
_TYPVAL_ENCODE_ENCODE
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:652
len
int len
Definition: helpers.c:1105
di
dictitem_T *const di
Definition: typval.c:1694
STR
#define STR(x)
Definition: macros.h:141
HASHITEM_EMPTY
#define HASHITEM_EMPTY(hi)
Definition: hashtab.h:19
TYPVAL_ENCODE_CONV_NUMBER
#define TYPVAL_ENCODE_CONV_NUMBER(tv, num)
Definition: converter.c:34
TYPVAL_ENCODE_NODICT_VAR
const dict_T *const TYPVAL_ENCODE_NODICT_VAR
Definition: typval_encode.c.h:259