1 #ifndef NVIM_EVAL_USERFUNC_H
2 #define NVIM_EVAL_USERFUNC_H
3 
4 #include "nvim/eval/typval.h"
5 #include "nvim/ex_cmds_defs.h"
6 
7 ///< Structure used by trans_function_name()
8 typedef struct {
9   dict_T *fd_dict;  ///< Dictionary used.
10   char_u *fd_newkey;  ///< New key in "dict" in allocated memory.
11   dictitem_T *fd_di;  ///< Dictionary item used.
12 } funcdict_T;
13 
14 typedef struct funccal_entry funccal_entry_T;
15 struct funccal_entry {
16   void *top_funccal;
17   funccal_entry_T *next;
18 };
19 
20 /// errors for when calling a function
21 typedef enum {
22   ERROR_UNKNOWN = 0,
23   ERROR_TOOMANY,
24   ERROR_TOOFEW,
25   ERROR_SCRIPT,
26   ERROR_DICT,
27   ERROR_NONE,
28   ERROR_OTHER,
29   ERROR_BOTH,
30   ERROR_DELETED,
31   ERROR_NOTMETHOD,
32 } FnameTransError;
33 
34 /// Used in funcexe_T. Returns the new argcount.
35 typedef int (*ArgvFunc)(int current_argcount, typval_T *argv, int argskip,
36                         int called_func_argcount);
37 
38 /// Structure passed between functions dealing with function call execution.
39 typedef struct {
40   ArgvFunc argv_func;  ///< when not NULL, can be used to fill in arguments only
41                        ///< when the invoked function uses them
42   linenr_T firstline;  ///< first line of range
43   linenr_T lastline;   ///< last line of range
44   bool *doesrange;     ///< [out] if not NULL: function handled range
45   bool evaluate;       ///< actually evaluate expressions
46   partial_T *partial;  ///< for extra arguments
47   dict_T *selfdict;    ///< Dictionary for "self"
48   typval_T *basetv;    ///< base for base->method()
49 } funcexe_T;
50 
51 #define FUNCEXE_INIT (funcexe_T) { \
52   .argv_func = NULL, \
53   .firstline = 0, \
54   .lastline = 0, \
55   .doesrange = NULL, \
56   .evaluate = false, \
57   .partial = NULL, \
58   .selfdict = NULL, \
59   .basetv = NULL, \
60 }
61 
62 #define FUNCARG(fp, j)  ((char_u **)(fp->uf_args.ga_data))[j]
63 #define FUNCLINE(fp, j) ((char_u **)(fp->uf_lines.ga_data))[j]
64 
65 #ifdef INCLUDE_GENERATED_DECLARATIONS
66 # include "eval/userfunc.h.generated.h"
67 #endif
68 #endif  // NVIM_EVAL_USERFUNC_H
69