blob: 8755ff48ac21d2294664212326304a0827e1bf45 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#ifndef NVIM_EVAL_ENCODE_H
#define NVIM_EVAL_ENCODE_H
#include <msgpack.h>
#include <stddef.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 list_T *const list; ///< List being currently read.
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) {
.list = list,
.li = tv_list_first(list),
.offset = 0,
.li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL
? 0
: STRLEN(TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string)),
};
}
/// Array mapping values from SpecialVarValue enum to names
extern const char *const encode_bool_var_names[];
extern const char *const encode_special_var_names[];
/// First codepoint in high surrogates block
#define SURROGATE_HI_START 0xD800
/// Last codepoint in high surrogates block
#define SURROGATE_HI_END 0xDBFF
/// First codepoint in low surrogates block
#define SURROGATE_LO_START 0xDC00
/// Last codepoint in low surrogates block
#define SURROGATE_LO_END 0xDFFF
/// First character that needs to be encoded as surrogate pair
#define SURROGATE_FIRST_CHAR 0x10000
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "eval/encode.h.generated.h"
#endif
#endif // NVIM_EVAL_ENCODE_H
|