diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-06-25 15:44:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-25 15:44:39 -0400 |
commit | 26d8ab51daf8ff524d7f6edb843fe1c61f943425 (patch) | |
tree | d8a9b9311888272da3301c7e0b9396b19fd65b1c /src/nvim/eval/encode.c | |
parent | be0f96ab73733d611c5a719298dfd167e340e276 (diff) | |
parent | 142d00e8dacfee2aa78ca7a267736fbeff0b3c41 (diff) | |
download | rneovim-26d8ab51daf8ff524d7f6edb843fe1c61f943425.tar.gz rneovim-26d8ab51daf8ff524d7f6edb843fe1c61f943425.tar.bz2 rneovim-26d8ab51daf8ff524d7f6edb843fe1c61f943425.zip |
Merge #4607 from ZyX-I/luaviml'/lua'/encode_vim_to_object
Remove recursion from various serializers/converters
Diffstat (limited to 'src/nvim/eval/encode.c')
-rw-r--r-- | src/nvim/eval/encode.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 54daf7557e..670437ceda 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -344,7 +344,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, #define TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS() \ ga_concat(gap, ", ") -#define TYPVAL_ENCODE_CONV_SPECIAL_DICT_KEY_CHECK(label, kv_pair) +#define TYPVAL_ENCODE_CONV_SPECIAL_DICT_KEY_CHECK(label, key) #define TYPVAL_ENCODE_CONV_LIST_END() \ ga_append(gap, ']') @@ -379,7 +379,6 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, } \ vim_snprintf(ebuf, ARRAY_SIZE(ebuf), "{E724@%zu}", backref); \ ga_concat(gap, &ebuf[0]); \ - return OK; \ } while (0) #define TYPVAL_ENCODE_ALLOW_SPECIALS false @@ -426,7 +425,6 @@ TYPVAL_ENCODE_DEFINE_CONV_FUNCTIONS(, echo, garray_T *const, gap) EMSG(_("E724: unable to correctly dump variable " \ "with self-referencing container")); \ } \ - return OK; \ } while (0) #undef TYPVAL_ENCODE_ALLOW_SPECIALS @@ -662,9 +660,8 @@ static inline int convert_to_json_string(garray_T *const gap, /// Check whether given key can be used in json_encode() /// /// @param[in] tv Key to check. -static inline bool check_json_key(const typval_T *const tv) +bool encode_check_json_key(const typval_T *const tv) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE - FUNC_ATTR_ALWAYS_INLINE { if (tv->v_type == VAR_STRING) { return true; @@ -699,9 +696,9 @@ static inline bool check_json_key(const typval_T *const tv) } #undef TYPVAL_ENCODE_CONV_SPECIAL_DICT_KEY_CHECK -#define TYPVAL_ENCODE_CONV_SPECIAL_DICT_KEY_CHECK(label, kv_pair) \ +#define TYPVAL_ENCODE_CONV_SPECIAL_DICT_KEY_CHECK(label, key) \ do { \ - if (!check_json_key(&kv_pair->lv_first->li_tv)) { \ + if (!encode_check_json_key(&key)) { \ EMSG(_("E474: Invalid key in special dictionary")); \ goto label; \ } \ @@ -876,7 +873,7 @@ char *encode_tv2json(typval_T *tv, size_t *len) #define TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS() -#define TYPVAL_ENCODE_CONV_SPECIAL_DICT_KEY_CHECK(label, kv_pair) +#define TYPVAL_ENCODE_CONV_SPECIAL_DICT_KEY_CHECK(label, key) #define TYPVAL_ENCODE_CONV_LIST_END() |