mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 7.4.2058
Problem: eval.c is too big. Solution: Move user functions to userfunc.c
This commit is contained in:
2
Filelist
2
Filelist
@@ -84,6 +84,7 @@ SRC_ALL = \
|
||||
src/termlib.c \
|
||||
src/ui.c \
|
||||
src/undo.c \
|
||||
src/userfunc.c \
|
||||
src/version.c \
|
||||
src/version.h \
|
||||
src/vim.h \
|
||||
@@ -175,6 +176,7 @@ SRC_ALL = \
|
||||
src/proto/termlib.pro \
|
||||
src/proto/ui.pro \
|
||||
src/proto/undo.pro \
|
||||
src/proto/userfunc.pro \
|
||||
src/proto/version.pro \
|
||||
src/proto/winclip.pro \
|
||||
src/proto/window.pro \
|
||||
|
10
src/Makefile
10
src/Makefile
@@ -1531,6 +1531,7 @@ BASIC_SRC = \
|
||||
term.c \
|
||||
ui.c \
|
||||
undo.c \
|
||||
userfunc.c \
|
||||
version.c \
|
||||
window.c \
|
||||
$(OS_EXTRA_SRC)
|
||||
@@ -1631,6 +1632,7 @@ OBJ_COMMON = \
|
||||
objects/term.o \
|
||||
objects/ui.o \
|
||||
objects/undo.o \
|
||||
objects/userfunc.o \
|
||||
objects/version.o \
|
||||
objects/window.o \
|
||||
$(GUI_OBJ) \
|
||||
@@ -1731,6 +1733,7 @@ PRO_AUTO = \
|
||||
termlib.pro \
|
||||
ui.pro \
|
||||
undo.pro \
|
||||
userfunc.pro \
|
||||
version.pro \
|
||||
window.pro \
|
||||
gui_beval.pro \
|
||||
@@ -3066,6 +3069,9 @@ objects/ui.o: ui.c
|
||||
objects/undo.o: undo.c
|
||||
$(CCC) -o $@ undo.c
|
||||
|
||||
objects/userfunc.o: userfunc.c
|
||||
$(CCC) -o $@ userfunc.c
|
||||
|
||||
objects/window.o: window.c
|
||||
$(CCC) -o $@ window.c
|
||||
|
||||
@@ -3379,6 +3385,10 @@ objects/undo.o: undo.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
|
||||
ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
|
||||
gui_beval.h proto/gui_beval.pro alloc.h ex_cmds.h proto.h globals.h \
|
||||
farsi.h arabic.h
|
||||
objects/userfunc.o: userfunc.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
|
||||
ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
|
||||
gui_beval.h proto/gui_beval.pro alloc.h ex_cmds.h proto.h globals.h \
|
||||
farsi.h arabic.h
|
||||
objects/version.o: version.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
|
||||
ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
|
||||
gui_beval.h proto/gui_beval.pro alloc.h ex_cmds.h proto.h globals.h \
|
||||
|
3549
src/eval.c
3549
src/eval.c
File diff suppressed because it is too large
Load Diff
@@ -1536,6 +1536,8 @@ EXTERN char_u e_readonlysbx[] INIT(= N_("E794: Cannot set variable in the sandbo
|
||||
EXTERN char_u e_emptykey[] INIT(= N_("E713: Cannot use empty key for Dictionary"));
|
||||
EXTERN char_u e_dictreq[] INIT(= N_("E715: Dictionary required"));
|
||||
EXTERN char_u e_listidx[] INIT(= N_("E684: list index out of range: %ld"));
|
||||
EXTERN char_u e_toomanyarg[] INIT(= N_("E118: Too many arguments for function: %s"));
|
||||
EXTERN char_u e_dictkey[] INIT(= N_("E716: Key not present in Dictionary: %s"));
|
||||
#endif
|
||||
#ifdef FEAT_QUICKFIX
|
||||
EXTERN char_u e_readerrf[] INIT(= N_("E47: Error while reading errorfile"));
|
||||
|
@@ -165,6 +165,7 @@ void qsort(void *base, size_t elm_count, size_t elm_size, int (*cmp)(const void
|
||||
# endif
|
||||
# include "ui.pro"
|
||||
# include "undo.pro"
|
||||
# include "userfunc.pro"
|
||||
# include "version.pro"
|
||||
# include "window.pro"
|
||||
|
||||
|
@@ -1,11 +1,6 @@
|
||||
/* eval.c */
|
||||
void eval_init(void);
|
||||
void eval_clear(void);
|
||||
char_u *func_name(void *cookie);
|
||||
linenr_T *func_breakpoint(void *cookie);
|
||||
int *func_dbg_tick(void *cookie);
|
||||
int func_level(void *cookie);
|
||||
int current_func_returned(void);
|
||||
void set_internal_string_var(char_u *name, char_u *value);
|
||||
int var_redir_start(char_u *name, int append);
|
||||
void var_redir_str(char_u *value, int value_len);
|
||||
@@ -27,22 +22,21 @@ int call_vim_function(char_u *func, int argc, char_u **argv, int safe, int str_a
|
||||
varnumber_T call_func_retnr(char_u *func, int argc, char_u **argv, int safe);
|
||||
void *call_func_retstr(char_u *func, int argc, char_u **argv, int safe);
|
||||
void *call_func_retlist(char_u *func, int argc, char_u **argv, int safe);
|
||||
void *save_funccal(void);
|
||||
void restore_funccal(void *vfc);
|
||||
void prof_child_enter(proftime_T *tm);
|
||||
void prof_child_exit(proftime_T *tm);
|
||||
int eval_foldexpr(char_u *arg, int *cp);
|
||||
void ex_let(exarg_T *eap);
|
||||
void list_hashtable_vars(hashtab_T *ht, char_u *prefix, int empty, int *first);
|
||||
char_u *get_lval(char_u *name, typval_T *rettv, lval_T *lp, int unlet, int skip, int flags, int fne_flags);
|
||||
void clear_lval(lval_T *lp);
|
||||
void *eval_for_line(char_u *arg, int *errp, char_u **nextcmdp, int skip);
|
||||
int next_for_item(void *fi_void, char_u *arg);
|
||||
void free_for_info(void *fi_void);
|
||||
void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx);
|
||||
void ex_call(exarg_T *eap);
|
||||
void ex_unlet(exarg_T *eap);
|
||||
void ex_lockvar(exarg_T *eap);
|
||||
int do_unlet(char_u *name, int forceit);
|
||||
void del_menutrans_vars(void);
|
||||
char_u *get_user_var_name(expand_T *xp, int idx);
|
||||
int eval0(char_u *arg, typval_T *rettv, char_u **nextcmd, int evaluate);
|
||||
int eval1(char_u **arg, typval_T *rettv, int evaluate);
|
||||
void partial_unref(partial_T *pt);
|
||||
int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
|
||||
@@ -52,20 +46,25 @@ int set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack);
|
||||
int set_ref_in_list(list_T *l, int copyID, ht_stack_T **ht_stack);
|
||||
int set_ref_in_item(typval_T *tv, int copyID, ht_stack_T **ht_stack, list_stack_T **list_stack);
|
||||
char_u *echo_string_core(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID, int echo_style, int restore_copyID, int dict_val);
|
||||
char_u *echo_string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID);
|
||||
char_u *tv2string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID);
|
||||
char_u *string_quote(char_u *str, int function);
|
||||
int string2float(char_u *text, float_T *value);
|
||||
char_u *get_function_name(expand_T *xp, int idx);
|
||||
char_u *get_expr_name(expand_T *xp, int idx);
|
||||
int call_func(char_u *funcname, int len, typval_T *rettv, int argcount_in, typval_T *argvars_in, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate, partial_T *partial, dict_T *selfdict_in);
|
||||
int find_internal_func(char_u *name);
|
||||
int call_internal_func(char_u *name, int argcount, typval_T *argvars, typval_T *rettv);
|
||||
buf_T *buflist_find_by_name(char_u *name, int curtab_only);
|
||||
int func_call(char_u *name, typval_T *args, partial_T *partial, dict_T *selfdict, typval_T *rettv);
|
||||
void execute_redir_str(char_u *value, int value_len);
|
||||
void mzscheme_call_vim(char_u *name, typval_T *args, typval_T *rettv);
|
||||
float_T vim_round(float_T f);
|
||||
long do_searchpair(char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit);
|
||||
char_u *get_callback(typval_T *arg, partial_T **pp);
|
||||
void free_callback(char_u *callback, partial_T *partial);
|
||||
int get_id_len(char_u **arg);
|
||||
char_u *find_name_end(char_u *arg, char_u **expr_start, char_u **expr_end, int flags);
|
||||
int eval_isnamec(int c);
|
||||
int eval_isnamec1(int c);
|
||||
void set_vim_var_nr(int idx, varnumber_T val);
|
||||
varnumber_T get_vim_var_nr(int idx);
|
||||
char_u *get_vim_var_str(int idx);
|
||||
@@ -79,6 +78,7 @@ void set_reg_var(int c);
|
||||
char_u *v_exception(char_u *oldval);
|
||||
char_u *v_throwpoint(char_u *oldval);
|
||||
char_u *set_cmdarg(exarg_T *eap, char_u *oldarg);
|
||||
int handle_subscript(char_u **arg, typval_T *rettv, int evaluate, int verbose);
|
||||
typval_T *alloc_tv(void);
|
||||
void free_tv(typval_T *varp);
|
||||
void clear_tv(typval_T *varp);
|
||||
@@ -88,11 +88,13 @@ char_u *get_tv_string(typval_T *varp);
|
||||
char_u *get_tv_string_buf(typval_T *varp, char_u *buf);
|
||||
char_u *get_tv_string_chk(typval_T *varp);
|
||||
char_u *get_tv_string_buf_chk(typval_T *varp, char_u *buf);
|
||||
dictitem_T *find_var(char_u *name, hashtab_T **htp, int no_autoload);
|
||||
char_u *get_var_value(char_u *name);
|
||||
void new_script_vars(scid_T id);
|
||||
void init_var_dict(dict_T *dict, dictitem_T *dict_var, int scope);
|
||||
void unref_var_dict(dict_T *dict);
|
||||
void vars_clear(hashtab_T *ht);
|
||||
void vars_clear_ext(hashtab_T *ht, int free_val);
|
||||
int var_check_ro(int flags, char_u *name, int use_gettext);
|
||||
int var_check_func_name(char_u *name, int new_var);
|
||||
int valid_varname(char_u *varname);
|
||||
@@ -102,25 +104,8 @@ int item_copy(typval_T *from, typval_T *to, int deep, int copyID);
|
||||
void ex_echo(exarg_T *eap);
|
||||
void ex_echohl(exarg_T *eap);
|
||||
void ex_execute(exarg_T *eap);
|
||||
void ex_function(exarg_T *eap);
|
||||
void free_all_functions(void);
|
||||
int translated_function_exists(char_u *name);
|
||||
char_u *get_expanded_name(char_u *name, int check);
|
||||
void func_dump_profile(FILE *fd);
|
||||
char_u *get_user_func_name(expand_T *xp, int idx);
|
||||
void ex_delfunction(exarg_T *eap);
|
||||
void func_unref(char_u *name);
|
||||
void func_ref(char_u *name);
|
||||
void ex_return(exarg_T *eap);
|
||||
int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv);
|
||||
void discard_pending_return(void *rettv);
|
||||
char_u *get_return_cmd(void *rettv);
|
||||
char_u *get_func_line(int c, void *cookie, int indent);
|
||||
void func_line_start(void *cookie);
|
||||
void func_line_exec(void *cookie);
|
||||
void func_line_end(void *cookie);
|
||||
int func_has_ended(void *cookie);
|
||||
int func_has_abort(void *cookie);
|
||||
char_u *autoload_name(char_u *name);
|
||||
int script_autoload(char_u *name, int reload);
|
||||
int read_viminfo_varlist(vir_T *virp, int writing);
|
||||
void write_viminfo_varlist(FILE *fp);
|
||||
int store_session_globals(FILE *fd);
|
||||
|
52
src/proto/userfunc.pro
Normal file
52
src/proto/userfunc.pro
Normal file
@@ -0,0 +1,52 @@
|
||||
/* userfunc.c */
|
||||
void func_init(void);
|
||||
int get_lambda_tv(char_u **arg, typval_T *rettv, int evaluate);
|
||||
char_u *deref_func_name(char_u *name, int *lenp, partial_T **partialp, int no_autoload);
|
||||
int get_func_tv(char_u *name, int len, typval_T *rettv, char_u **arg, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate, partial_T *partial, dict_T *selfdict);
|
||||
void free_all_functions(void);
|
||||
int func_call(char_u *name, typval_T *args, partial_T *partial, dict_T *selfdict, typval_T *rettv);
|
||||
int call_func(char_u *funcname, int len, typval_T *rettv, int argcount_in, typval_T *argvars_in, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate, partial_T *partial, dict_T *selfdict_in);
|
||||
void ex_function(exarg_T *eap);
|
||||
int eval_fname_script(char_u *p);
|
||||
int translated_function_exists(char_u *name);
|
||||
int function_exists(char_u *name);
|
||||
char_u *get_expanded_name(char_u *name, int check);
|
||||
void func_dump_profile(FILE *fd);
|
||||
void prof_child_enter(proftime_T *tm);
|
||||
void prof_child_exit(proftime_T *tm);
|
||||
char_u *get_user_func_name(expand_T *xp, int idx);
|
||||
void ex_delfunction(exarg_T *eap);
|
||||
void func_unref(char_u *name);
|
||||
void func_ref(char_u *name);
|
||||
void ex_return(exarg_T *eap);
|
||||
void ex_call(exarg_T *eap);
|
||||
int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv);
|
||||
void discard_pending_return(void *rettv);
|
||||
char_u *get_return_cmd(void *rettv);
|
||||
char_u *get_func_line(int c, void *cookie, int indent);
|
||||
void func_line_start(void *cookie);
|
||||
void func_line_exec(void *cookie);
|
||||
void func_line_end(void *cookie);
|
||||
int func_has_ended(void *cookie);
|
||||
int func_has_abort(void *cookie);
|
||||
dict_T *make_partial(dict_T *selfdict_in, typval_T *rettv);
|
||||
char_u *func_name(void *cookie);
|
||||
linenr_T *func_breakpoint(void *cookie);
|
||||
int *func_dbg_tick(void *cookie);
|
||||
int func_level(void *cookie);
|
||||
int current_func_returned(void);
|
||||
void *save_funccal(void);
|
||||
void restore_funccal(void *vfc);
|
||||
int free_unref_funccal(int copyID, int testing);
|
||||
hashtab_T *get_funccal_local_ht(void);
|
||||
dictitem_T *get_funccal_local_var(void);
|
||||
hashtab_T *get_funccal_args_ht(void);
|
||||
dictitem_T *get_funccal_args_var(void);
|
||||
void *clear_current_funccal(void);
|
||||
void restore_current_funccal(void *f);
|
||||
void list_func_vars(int *first);
|
||||
dict_T *get_current_funccal_dict(hashtab_T *ht);
|
||||
int set_ref_in_previous_funccal(int copyID);
|
||||
int set_ref_in_call_stack(int copyID);
|
||||
int set_ref_in_func_args(int copyID);
|
||||
/* vim: set ft=c : */
|
@@ -3117,3 +3117,48 @@ typedef struct
|
||||
int diff_mode; /* start with 'diff' set */
|
||||
#endif
|
||||
} mparm_T;
|
||||
|
||||
/*
|
||||
* Structure returned by get_lval() and used by set_var_lval().
|
||||
* For a plain name:
|
||||
* "name" points to the variable name.
|
||||
* "exp_name" is NULL.
|
||||
* "tv" is NULL
|
||||
* For a magic braces name:
|
||||
* "name" points to the expanded variable name.
|
||||
* "exp_name" is non-NULL, to be freed later.
|
||||
* "tv" is NULL
|
||||
* For an index in a list:
|
||||
* "name" points to the (expanded) variable name.
|
||||
* "exp_name" NULL or non-NULL, to be freed later.
|
||||
* "tv" points to the (first) list item value
|
||||
* "li" points to the (first) list item
|
||||
* "range", "n1", "n2" and "empty2" indicate what items are used.
|
||||
* For an existing Dict item:
|
||||
* "name" points to the (expanded) variable name.
|
||||
* "exp_name" NULL or non-NULL, to be freed later.
|
||||
* "tv" points to the dict item value
|
||||
* "newkey" is NULL
|
||||
* For a non-existing Dict item:
|
||||
* "name" points to the (expanded) variable name.
|
||||
* "exp_name" NULL or non-NULL, to be freed later.
|
||||
* "tv" points to the Dictionary typval_T
|
||||
* "newkey" is the key for the new item.
|
||||
*/
|
||||
typedef struct lval_S
|
||||
{
|
||||
char_u *ll_name; /* start of variable name (can be NULL) */
|
||||
char_u *ll_exp_name; /* NULL or expanded name in allocated memory. */
|
||||
typval_T *ll_tv; /* Typeval of item being used. If "newkey"
|
||||
isn't NULL it's the Dict to which to add
|
||||
the item. */
|
||||
listitem_T *ll_li; /* The list item or NULL. */
|
||||
list_T *ll_list; /* The list or NULL. */
|
||||
int ll_range; /* TRUE when a [i:j] range was used */
|
||||
long ll_n1; /* First index for list */
|
||||
long ll_n2; /* Second index for list range */
|
||||
int ll_empty2; /* Second index is empty: [i:] */
|
||||
dict_T *ll_dict; /* The Dictionary or NULL */
|
||||
dictitem_T *ll_di; /* The dictitem or NULL */
|
||||
char_u *ll_newkey; /* New key for Dict in alloc. mem or NULL. */
|
||||
} lval_T;
|
||||
|
3494
src/userfunc.c
Normal file
3494
src/userfunc.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -758,6 +758,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2058,
|
||||
/**/
|
||||
2057,
|
||||
/**/
|
||||
|
25
src/vim.h
25
src/vim.h
@@ -2407,4 +2407,29 @@ int vim_main2(int argc, char **argv);
|
||||
#define COPYID_INC 2
|
||||
#define COPYID_MASK (~0x1)
|
||||
|
||||
/* Values for trans_function_name() argument: */
|
||||
#define TFN_INT 1 /* internal function name OK */
|
||||
#define TFN_QUIET 2 /* no error messages */
|
||||
#define TFN_NO_AUTOLOAD 4 /* do not use script autoloading */
|
||||
|
||||
/* Values for get_lval() flags argument: */
|
||||
#define GLV_QUIET TFN_QUIET /* no error messages */
|
||||
#define GLV_NO_AUTOLOAD TFN_NO_AUTOLOAD /* do not use script autoloading */
|
||||
|
||||
#define DO_NOT_FREE_CNT 99999 /* refcount for dict or list that should not
|
||||
be freed. */
|
||||
|
||||
/* errors for when calling a function */
|
||||
#define ERROR_UNKNOWN 0
|
||||
#define ERROR_TOOMANY 1
|
||||
#define ERROR_TOOFEW 2
|
||||
#define ERROR_SCRIPT 3
|
||||
#define ERROR_DICT 4
|
||||
#define ERROR_NONE 5
|
||||
#define ERROR_OTHER 6
|
||||
|
||||
/* flags for find_name_end() */
|
||||
#define FNE_INCL_BR 1 /* include [] in name */
|
||||
#define FNE_CHECK_START 2 /* check name starts with valid character */
|
||||
|
||||
#endif /* VIM__H */
|
||||
|
Reference in New Issue
Block a user