mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 04:28:33 +00:00
vim-patch:7.4.1559
Problem: Passing cookie to a callback is clumsy.
Solution: Change function() to take arguments and return a partial.
1735bc988c
This commit is contained in:

committed by
James McCoy

parent
75c18b6aaa
commit
521e45f2a8
@@ -315,6 +315,13 @@ int encode_read_from_list(ListReaderState *const state, char *const buf,
|
||||
ga_append(gap, ')'); \
|
||||
} while (0)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_PARTIAL(partial) \
|
||||
do { \
|
||||
ga_concat(gap, "partial("); \
|
||||
TYPVAL_ENCODE_CONV_STRING(partial, STRLEN(partial)); \
|
||||
ga_append(gap, ')'); \
|
||||
} while (0)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_EMPTY_LIST() \
|
||||
ga_concat(gap, "[]")
|
||||
|
||||
@@ -661,6 +668,12 @@ static inline int convert_to_json_string(garray_T *const gap,
|
||||
"attempt to dump function reference"), \
|
||||
mpstack, objname)
|
||||
|
||||
#undef TYPVAL_ENCODE_CONV_PARTIAL
|
||||
#define TYPVAL_ENCODE_CONV_PARTIAL(partial) \
|
||||
return conv_error(_("E474: Error while dumping %s, %s: " \
|
||||
"attempt to dump partial"), \
|
||||
mpstack, objname)
|
||||
|
||||
/// Check whether given key can be used in json_encode()
|
||||
///
|
||||
/// @param[in] tv Key to check.
|
||||
@@ -718,6 +731,7 @@ TYPVAL_ENCODE_DEFINE_CONV_FUNCTIONS(static, json, garray_T *const, gap)
|
||||
#undef TYPVAL_ENCODE_CONV_NUMBER
|
||||
#undef TYPVAL_ENCODE_CONV_FLOAT
|
||||
#undef TYPVAL_ENCODE_CONV_FUNC
|
||||
#undef TYPVAL_ENCODE_CONV_PARTIAL
|
||||
#undef TYPVAL_ENCODE_CONV_EMPTY_LIST
|
||||
#undef TYPVAL_ENCODE_CONV_LIST_START
|
||||
#undef TYPVAL_ENCODE_CONV_EMPTY_DICT
|
||||
@@ -846,6 +860,11 @@ char *encode_tv2json(typval_T *tv, size_t *len)
|
||||
"attempt to dump function reference"), \
|
||||
mpstack, objname)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_PARTIAL(partial) \
|
||||
return conv_error(_("E951: Error while dumping %s, %s: " \
|
||||
"attempt to dump partial"), \
|
||||
mpstack, objname)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_EMPTY_LIST() \
|
||||
msgpack_pack_array(packer, 0)
|
||||
|
||||
@@ -902,6 +921,7 @@ TYPVAL_ENCODE_DEFINE_CONV_FUNCTIONS(, msgpack, msgpack_packer *const, packer)
|
||||
#undef TYPVAL_ENCODE_CONV_NUMBER
|
||||
#undef TYPVAL_ENCODE_CONV_FLOAT
|
||||
#undef TYPVAL_ENCODE_CONV_FUNC
|
||||
#undef TYPVAL_ENCODE_CONV_PARTIAL
|
||||
#undef TYPVAL_ENCODE_CONV_EMPTY_LIST
|
||||
#undef TYPVAL_ENCODE_CONV_LIST_START
|
||||
#undef TYPVAL_ENCODE_CONV_EMPTY_DICT
|
||||
|
Reference in New Issue
Block a user