aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/encode.h
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2016-02-03 18:50:19 +0300
committerZyX <kp-pav@yandex.ru>2016-04-18 02:45:49 +0300
commit41b44d114c030e01a7e15084d0510555ec363605 (patch)
treebd26689febd21e38739fdb625a9042c664e09f8a /src/nvim/eval/encode.h
parent704accfbfae881f60c77bf9d6147a4431f0ed5da (diff)
downloadrneovim-41b44d114c030e01a7e15084d0510555ec363605.tar.gz
rneovim-41b44d114c030e01a7e15084d0510555ec363605.tar.bz2
rneovim-41b44d114c030e01a7e15084d0510555ec363605.zip
eval: Move encode.c to eval/encode.c
Diffstat (limited to 'src/nvim/eval/encode.h')
-rw-r--r--src/nvim/eval/encode.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/nvim/eval/encode.h b/src/nvim/eval/encode.h
new file mode 100644
index 0000000000..0e60c96155
--- /dev/null
+++ b/src/nvim/eval/encode.h
@@ -0,0 +1,60 @@
+#ifndef NVIM_EVAL_ENCODE_H
+#define NVIM_EVAL_ENCODE_H
+
+#include <stddef.h>
+
+#include <msgpack.h>
+
+#include "nvim/eval.h"
+#include "nvim/garray.h"
+#include "nvim/vim.h" // For STRLEN
+
+/// Convert VimL value to msgpack string
+///
+/// @param[out] packer Packer to save results in.
+/// @param[in] tv Dumped value.
+/// @param[in] objname Object name, used for error message.
+///
+/// @return OK in case of success, FAIL otherwise.
+int encode_vim_to_msgpack(msgpack_packer *const packer,
+ typval_T *const tv,
+ const char *const objname);
+
+/// Convert VimL value to :echo output
+///
+/// @param[out] packer Packer to save results in.
+/// @param[in] tv Dumped value.
+/// @param[in] objname Object name, used for error message.
+///
+/// @return OK in case of success, FAIL otherwise.
+int encode_vim_to_echo(garray_T *const packer,
+ typval_T *const tv,
+ const char *const objname);
+
+/// Structure defining state for read_from_list()
+typedef struct {
+ const listitem_T *li; ///< Item currently read.
+ size_t offset; ///< Byte offset inside the read item.
+ size_t li_length; ///< Length of the string inside the read item.
+} ListReaderState;
+
+/// Initialize ListReaderState structure
+static inline ListReaderState encode_init_lrstate(const list_T *const list)
+ FUNC_ATTR_NONNULL_ALL
+{
+ return (ListReaderState) {
+ .li = list->lv_first,
+ .offset = 0,
+ .li_length = (list->lv_first->li_tv.vval.v_string == NULL
+ ? 0
+ : STRLEN(list->lv_first->li_tv.vval.v_string)),
+ };
+}
+
+/// Array mapping values from SpecialVarValue enum to names
+extern const char *const encode_special_var_names[];
+
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "eval/encode.h.generated.h"
+#endif
+#endif // NVIM_EVAL_ENCODE_H