eval.h
Go to the documentation of this file.
1 #ifndef NVIM_EVAL_H
2 #define NVIM_EVAL_H
3 
4 #include "nvim/buffer_defs.h"
5 #include "nvim/channel.h"
6 #include "nvim/eval/funcs.h" // For FunPtr
7 #include "nvim/event/time.h" // For TimeWatcher
8 #include "nvim/ex_cmds_defs.h" // For exarg_T
9 #include "nvim/os/fileio.h" // For FileDescriptor
10 #include "nvim/os/stdpaths_defs.h" // For XDGVarType
11 
12 #define COPYID_INC 2
13 #define COPYID_MASK (~0x1)
14 
15 // All user-defined functions are found in this hashtable.
16 extern hashtab_T func_hashtab;
17 
18 // From user function to hashitem and back.
20 #define UF2HIKEY(fp) ((fp)->uf_name)
21 #define HIKEY2UF(p) ((ufunc_T *)(p - offsetof(ufunc_T, uf_name)))
22 #define HI2UF(hi) HIKEY2UF((hi)->hi_key)
23 
24 /*
25  * Structure returned by get_lval() and used by set_var_lval().
26  * For a plain name:
27  * "name" points to the variable name.
28  * "exp_name" is NULL.
29  * "tv" is NULL
30  * For a magic braces name:
31  * "name" points to the expanded variable name.
32  * "exp_name" is non-NULL, to be freed later.
33  * "tv" is NULL
34  * For an index in a list:
35  * "name" points to the (expanded) variable name.
36  * "exp_name" NULL or non-NULL, to be freed later.
37  * "tv" points to the (first) list item value
38  * "li" points to the (first) list item
39  * "range", "n1", "n2" and "empty2" indicate what items are used.
40  * For an existing Dict item:
41  * "name" points to the (expanded) variable name.
42  * "exp_name" NULL or non-NULL, to be freed later.
43  * "tv" points to the dict item value
44  * "newkey" is NULL
45  * For a non-existing Dict item:
46  * "name" points to the (expanded) variable name.
47  * "exp_name" NULL or non-NULL, to be freed later.
48  * "tv" points to the Dictionary typval_T
49  * "newkey" is the key for the new item.
50  */
51 typedef struct lval_S {
52  const char *ll_name;
53  size_t ll_name_len;
54  char *ll_exp_name;
56  listitem_T *ll_li;
59  bool ll_range;
60  bool ll_empty2;
61  long ll_n1;
62  long ll_n2;
67 } lval_T;
68 
70 typedef enum {
71  VAR_FLAVOUR_DEFAULT = 1, // doesn't start with uppercase
72  VAR_FLAVOUR_SESSION = 2, // starts with uppercase, some lower
73  VAR_FLAVOUR_SHADA = 4 // all uppercase
75 
77 typedef enum {
164  // Neovim
167  VV__NULL_STRING, // String with NULL value. For test purposes only.
168  VV__NULL_LIST, // List with NULL value. For test purposes only.
169  VV__NULL_DICT, // Dictionary with NULL value. For test purposes only.
170  VV__NULL_BLOB, // Blob with NULL value. For test purposes only.
172 } VimVarIndex;
173 
175 typedef enum {
185 #define LAST_MSGPACK_TYPE kMPExt
187 
190 
191 #undef LAST_MSGPACK_TYPE
192 
194 typedef enum {
195  TFN_INT = 1,
196  TFN_QUIET = 2,
201 
203 typedef enum {
207 } GetLvalFlags;
209 
211 #define FNE_INCL_BR 1 /* find_name_end(): include [] in name */
212 #define FNE_CHECK_START 2 /* find_name_end(): check name starts with
213  valid character */
214 
215 typedef struct {
217  int timer_id;
218  int repeat_count;
219  int refcount;
220  int emsg_count;
221  long timeout;
222  bool stopped;
223  bool paused;
224  Callback callback;
225 } timer_T;
226 
228 typedef enum
229 {
235  ASSERT_OTHER,
236 } assert_type_T;
237 
239 typedef enum {
250  EXPR_ISNOT,
251 } exprtype_T;
252 
254 typedef enum {
258 } DictListType;
259 
260 typedef int (*ex_unletlock_callback)(lval_T *, char_u *, exarg_T *, int);
261 
262 // Used for checking if local variables or arguments used in a lambda.
263 extern bool *eval_lavars_used;
264 
265 #ifdef INCLUDE_GENERATED_DECLARATIONS
266 # include "eval.h.generated.h"
267 #endif
268 #endif // NVIM_EVAL_H
VV_EVENT
@ VV_EVENT
Definition: eval.h:159
kMPInteger
@ kMPInteger
Definition: eval.h:178
lval_S::ll_n1
long ll_n1
First index for list.
Definition: eval.h:61
VV_CMDARG
@ VV_CMDARG
Definition: eval.h:99
VV_CMDBANG
@ VV_CMDBANG
Definition: eval.h:110
VV_THROWPOINT
@ VV_THROWPOINT
Definition: eval.h:108
VV_TYPE_DICT
@ VV_TYPE_DICT
Definition: eval.h:155
VV__NULL_BLOB
@ VV__NULL_BLOB
Definition: eval.h:170
lval_S::ll_exp_name
char * ll_exp_name
NULL or expanded name in allocated memory.
Definition: eval.h:54
VV_INSERTMODE
@ VV_INSERTMODE
Definition: eval.h:111
VV_OPTION_TYPE
@ VV_OPTION_TYPE
Definition: eval.h:141
TransFunctionNameFlags
TransFunctionNameFlags
trans_function_name() flags
Definition: eval.h:194
lval_S::ll_dict
dict_T * ll_dict
The Dictionary or NULL.
Definition: eval.h:63
VV__NULL_DICT
@ VV__NULL_DICT
Definition: eval.h:169
VV_ERRMSG
@ VV_ERRMSG
Definition: eval.h:81
var_flavour_T
var_flavour_T
enum used by var_flavour()
Definition: eval.h:70
typval_T
Structure that holds an internal variable value.
Definition: typval.h:131
VV_FNAME_NEW
@ VV_FNAME_NEW
Definition: eval.h:97
kMPBinary
@ kMPBinary
Definition: eval.h:181
VV_SWAPCHOICE
@ VV_SWAPCHOICE
Definition: eval.h:125
VV_OP
@ VV_OP
Definition: eval.h:132
timer_T
Definition: eval.h:214
VV_ECHOSPACE
@ VV_ECHOSPACE
Definition: eval.h:160
VV_TRUE
@ VV_TRUE
Definition: eval.h:144
VV_WARNINGMSG
@ VV_WARNINGMSG
Definition: eval.h:82
VV_FNAME_IN
@ VV_FNAME_IN
Definition: eval.h:95
VV_PROFILING
@ VV_PROFILING
Definition: eval.h:114
channel.h
time.h
VV_CC_TO
@ VV_CC_TO
Definition: eval.h:94
lval_S::ll_name
const char * ll_name
Start of variable name (can be NULL).
Definition: eval.h:52
time_watcher
Definition: time.h:11
listvar_S
Definition: typval.h:174
lval_S::ll_li
listitem_T * ll_li
The list item or NULL.
Definition: eval.h:57
VV_LC_TIME
@ VV_LC_TIME
Definition: eval.h:91
exprtype_T
exprtype_T
types for expressions.
Definition: eval.h:238
VV_BEVAL_WINNR
@ VV_BEVAL_WINNR
Definition: eval.h:118
kMPFloat
@ kMPFloat
Definition: eval.h:179
VV_NUMBERMAX
@ VV_NUMBERMAX
Definition: eval.h:146
dumuf
EXTERN ufunc_T dumuf
Definition: eval.h:19
VV_MOUSE_COL
@ VV_MOUSE_COL
Definition: eval.h:131
ASSERT_OTHER
@ ASSERT_OTHER
Definition: eval.h:234
VV_CTYPE
@ VV_CTYPE
Definition: eval.h:92
VV_FOLDEND
@ VV_FOLDEND
Definition: eval.h:101
VV_TYPE_BLOB
@ VV_TYPE_BLOB
Definition: eval.h:158
VV_NUMBERMIN
@ VV_NUMBERMIN
Definition: eval.h:147
VV_FOLDLEVEL
@ VV_FOLDLEVEL
Definition: eval.h:103
blobvar_S
Structure to hold info about a Blob.
Definition: typval.h:259
VV_BEVAL_LNUM
@ VV_BEVAL_LNUM
Definition: eval.h:120
VV_CHAR
@ VV_CHAR
Definition: eval.h:127
VV_OPTION_OLD
@ VV_OPTION_OLD
Definition: eval.h:140
lval_S::ll_blob
blob_T * ll_blob
The Blob or NULL.
Definition: eval.h:66
hashtable_S
Definition: hashtab.h:63
VV_LNUM
@ VV_LNUM
Definition: eval.h:87
kMPNil
@ kMPNil
Definition: eval.h:176
EXPR_UNKNOWN
@ EXPR_UNKNOWN
Definition: eval.h:239
VV_KEY
@ VV_KEY
Definition: eval.h:113
VV_VIM_DID_ENTER
@ VV_VIM_DID_ENTER
Definition: eval.h:149
lval_S::ll_newkey
char_u * ll_newkey
New key for Dict in allocated memory or NULL.
Definition: eval.h:65
VV_MSGPACK_TYPES
@ VV_MSGPACK_TYPES
Definition: eval.h:166
VV_ARGV
@ VV_ARGV
Definition: eval.h:161
VV_EXITING
@ VV_EXITING
Definition: eval.h:163
kMPString
@ kMPString
Definition: eval.h:180
VV_FOLDSTART
@ VV_FOLDSTART
Definition: eval.h:100
VV_WINDOWID
@ VV_WINDOWID
Definition: eval.h:136
ASSERT_INRANGE
@ ASSERT_INRANGE
Definition: eval.h:233
kDictListItems
@ kDictListItems
List dictionary contents: [keys, values].
Definition: eval.h:256
VV_VAL
@ VV_VAL
Definition: eval.h:112
lval_S::ll_tv
typval_T * ll_tv
isn't NULL it's the Dict to which to add the item.
Definition: eval.h:55
VV_TYPE_LIST
@ VV_TYPE_LIST
Definition: eval.h:154
lval_S::ll_list
list_T * ll_list
The list or NULL.
Definition: eval.h:58
exarg
Arguments used for Ex commands.
Definition: ex_cmds_defs.h:145
VV_EXCEPTION
@ VV_EXCEPTION
Definition: eval.h:107
DictListType
DictListType
Type for dict_list function.
Definition: eval.h:253
VV_PROGPATH
@ VV_PROGPATH
Definition: eval.h:137
VV_DYING
@ VV_DYING
Definition: eval.h:106
VV_SWAPCOMMAND
@ VV_SWAPCOMMAND
Definition: eval.h:126
VV_MOUSE_WIN
@ VV_MOUSE_WIN
Definition: eval.h:128
lval_S::ll_empty2
bool ll_empty2
Second index is empty: [i:].
Definition: eval.h:60
EXPR_MATCH
@ EXPR_MATCH
=~
Definition: eval.h:246
VV_TERMRESPONSE
@ VV_TERMRESPONSE
Definition: eval.h:88
lval_S::ll_di
dictitem_T * ll_di
The dictitem or NULL.
Definition: eval.h:64
VV_PROGNAME
@ VV_PROGNAME
Definition: eval.h:104
func_hashtab
hashtab_T func_hashtab
Definition: userfunc.c:45
ASSERT_NOTMATCH
@ ASSERT_NOTMATCH
Definition: eval.h:232
VV_TESTING
@ VV_TESTING
Definition: eval.h:150
kMPMap
@ kMPMap
Definition: eval.h:183
MessagePackType
MessagePackType
All recognized msgpack types.
Definition: eval.h:175
VV_LANG
@ VV_LANG
Definition: eval.h:90
VV_SWAPNAME
@ VV_SWAPNAME
Definition: eval.h:124
VV_COUNT
@ VV_COUNT
Definition: eval.h:78
VV_LUA
@ VV_LUA
Definition: eval.h:171
VV_TYPE_NUMBER
@ VV_TYPE_NUMBER
Definition: eval.h:151
ex_unletlock_callback
int(* ex_unletlock_callback)(lval_T *, char_u *, exarg_T *, int)
Definition: eval.h:259
VV_FALSE
@ VV_FALSE
Definition: eval.h:143
VV_FNAME
@ VV_FNAME
Definition: eval.h:89
ufunc
Structure to hold info for a user function.
Definition: typval.h:323
ASSERT_EQUAL
@ ASSERT_EQUAL
Definition: eval.h:229
kDictListValues
@ kDictListValues
List dictionary values.
Definition: eval.h:255
VV_SHELL_ERROR
@ VV_SHELL_ERROR
Definition: eval.h:84
EXPR_EQUAL
@ EXPR_EQUAL
==
Definition: eval.h:240
VV_FNAME_OUT
@ VV_FNAME_OUT
Definition: eval.h:96
VV_OLDFILES
@ VV_OLDFILES
Definition: eval.h:135
VV_BEVAL_BUFNR
@ VV_BEVAL_BUFNR
Definition: eval.h:117
VV_NUMBERSIZE
@ VV_NUMBERSIZE
Definition: eval.h:148
VV_TYPE_FUNC
@ VV_TYPE_FUNC
Definition: eval.h:153
kMPArray
@ kMPArray
Definition: eval.h:182
VV_SEARCHFORWARD
@ VV_SEARCHFORWARD
Definition: eval.h:133
lval_S
Definition: eval.h:51
VV_ERRORS
@ VV_ERRORS
Definition: eval.h:142
eval_msgpack_type_lists
const list_T * eval_msgpack_type_lists[LAST_MSGPACK_TYPE+1]
Array mapping values from MessagePackType to corresponding list pointers.
Definition: eval.c:289
VV_SEND_SERVER
@ VV_SEND_SERVER
Definition: eval.h:105
EXPR_SEQUAL
@ EXPR_SEQUAL
<=
Definition: eval.h:245
EXPR_NEQUAL
@ EXPR_NEQUAL
!=
Definition: eval.h:241
VV_STDERR
@ VV_STDERR
Definition: eval.h:165
TFN_NO_AUTOLOAD
@ TFN_NO_AUTOLOAD
Do not use script autoloading.
Definition: eval.h:197
kMPBoolean
@ kMPBoolean
Definition: eval.h:177
VV_TYPE_FLOAT
@ VV_TYPE_FLOAT
Definition: eval.h:156
fileio.h
TFN_INT
@ TFN_INT
May use internal function name.
Definition: eval.h:195
VV_STATUSMSG
@ VV_STATUSMSG
Definition: eval.h:83
LAST_MSGPACK_TYPE
#define LAST_MSGPACK_TYPE
Definition: eval.h:185
stdpaths_defs.h
eval_lavars_used
bool * eval_lavars_used
Used for checking if local variables or arguments used in a lambda.
Definition: eval.c:89
VV_REG
@ VV_REG
Definition: eval.h:109
TFN_READ_ONLY
@ TFN_READ_ONLY
Will not change the variable.
Definition: eval.h:199
EXTERN
#define EXTERN
Definition: macros.h:9
VV_FNAME_DIFF
@ VV_FNAME_DIFF
Definition: eval.h:98
TFN_QUIET
@ TFN_QUIET
Do not emit error messages.
Definition: eval.h:196
VV_TYPE_BOOL
@ VV_TYPE_BOOL
Definition: eval.h:157
VV_FCS_CHOICE
@ VV_FCS_CHOICE
Definition: eval.h:116
VV_NULL
@ VV_NULL
Definition: eval.h:145
VV_CC_FROM
@ VV_CC_FROM
Definition: eval.h:93
GLV_QUIET
@ GLV_QUIET
Do not emit error messages.
Definition: eval.h:204
VV_BEVAL_TEXT
@ VV_BEVAL_TEXT
Definition: eval.h:122
dictitem_T
Definition: coverity-model.c:39
VV_MOUSE_WINID
@ VV_MOUSE_WINID
Definition: eval.h:129
lval_S::ll_range
bool ll_range
true when a [i:j] range was used.
Definition: eval.h:59
listitem_S
Definition: typval.h:158
char_u
unsigned char char_u
Definition: types.h:12
VV_COMPLETED_ITEM
@ VV_COMPLETED_ITEM
Definition: eval.h:138
EXPR_NOMATCH
@ EXPR_NOMATCH
!~
Definition: eval.h:247
VV__NULL_LIST
@ VV__NULL_LIST
Definition: eval.h:168
EXPR_ISNOT
@ EXPR_ISNOT
isnot
Definition: eval.h:249
GLV_READ_ONLY
@ GLV_READ_ONLY
Definition: eval.h:206
lval_S::ll_n2
long ll_n2
Second index for list range.
Definition: eval.h:62
VV_BEVAL_WINID
@ VV_BEVAL_WINID
Definition: eval.h:119
VV_SCROLLSTART
@ VV_SCROLLSTART
Definition: eval.h:123
VV_VERSION
@ VV_VERSION
Definition: eval.h:86
VAR_FLAVOUR_SHADA
@ VAR_FLAVOUR_SHADA
Definition: eval.h:73
VV_FCS_REASON
@ VV_FCS_REASON
Definition: eval.h:115
Callback
Definition: typval.h:77
kDictListKeys
@ kDictListKeys
List dictionary keys.
Definition: eval.h:254
VV__NULL_STRING
@ VV__NULL_STRING
Definition: eval.h:167
EXPR_GEQUAL
@ EXPR_GEQUAL
>=
Definition: eval.h:243
ex_cmds_defs.h
VAR_FLAVOUR_DEFAULT
@ VAR_FLAVOUR_DEFAULT
Definition: eval.h:71
buffer_defs.h
VV_MOUSE_LNUM
@ VV_MOUSE_LNUM
Definition: eval.h:130
assert_type_T
assert_type_T
Type of assert_* check being performed.
Definition: eval.h:227
GLV_NO_AUTOLOAD
@ GLV_NO_AUTOLOAD
Do not use script autoloading.
Definition: eval.h:205
dict_T
Definition: coverity-model.c:40
VV_BEVAL_COL
@ VV_BEVAL_COL
Definition: eval.h:121
VAR_FLAVOUR_SESSION
@ VAR_FLAVOUR_SESSION
Definition: eval.h:72
EXPR_GREATER
@ EXPR_GREATER
Definition: eval.h:242
TFN_NO_DEREF
@ TFN_NO_DEREF
Do not dereference a Funcref.
Definition: eval.h:198
VV_OPTION_NEW
@ VV_OPTION_NEW
Definition: eval.h:139
ASSERT_MATCH
@ ASSERT_MATCH
Definition: eval.h:231
VV_THIS_SESSION
@ VV_THIS_SESSION
Definition: eval.h:85
VV_TYPE_STRING
@ VV_TYPE_STRING
Definition: eval.h:152
ASSERT_NOTEQUAL
@ ASSERT_NOTEQUAL
Definition: eval.h:230
VV_HLSEARCH
@ VV_HLSEARCH
Definition: eval.h:134
lval_S::ll_name_len
size_t ll_name_len
Length of the .ll_name.
Definition: eval.h:53
VV_FOLDDASHES
@ VV_FOLDDASHES
Definition: eval.h:102
GetLvalFlags
GetLvalFlags
get_lval() flags
Definition: eval.h:203
VV_COUNT1
@ VV_COUNT1
Definition: eval.h:79
EXPR_SMALLER
@ EXPR_SMALLER
<
Definition: eval.h:244
VV_PREVCOUNT
@ VV_PREVCOUNT
Definition: eval.h:80
lval_T
struct lval_S lval_T
EXPR_IS
@ EXPR_IS
is
Definition: eval.h:248
kMPExt
@ kMPExt
Definition: eval.h:184
funcs.h
VV_COLLATE
@ VV_COLLATE
Definition: eval.h:162
VimVarIndex
VimVarIndex
Defines for Vim variables.
Definition: eval.h:77