aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/encode.c
diff options
context:
space:
mode:
authorMichael Ennen <mike.ennen@gmail.com>2016-10-24 23:53:07 -0700
committerJames McCoy <jamessan@jamessan.com>2016-12-12 10:17:34 -0500
commit521e45f2a8c0619335288accdda0f0aaa1fc6513 (patch)
treec9f188f26ae7738a2dc2e71e3c816cdf62d5c151 /src/nvim/eval/encode.c
parent75c18b6aaa8430596fa10466dc7918047b13ff2b (diff)
downloadrneovim-521e45f2a8c0619335288accdda0f0aaa1fc6513.tar.gz
rneovim-521e45f2a8c0619335288accdda0f0aaa1fc6513.tar.bz2
rneovim-521e45f2a8c0619335288accdda0f0aaa1fc6513.zip
vim-patch:7.4.1559
Problem: Passing cookie to a callback is clumsy. Solution: Change function() to take arguments and return a partial. https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Diffstat (limited to 'src/nvim/eval/encode.c')
-rw-r--r--src/nvim/eval/encode.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c
index 869eae74a3..57507f4430 100644
--- a/src/nvim/eval/encode.c
+++ b/src/nvim/eval/encode.c
@@ -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