mirror of
https://github.com/vim/vim
synced 2025-07-16 09:12:00 +00:00
patch 8.2.0847: typval related code is spread out
Problem: Typval related code is spread out. Solution: Move code to new typval.c file. (Yegappan Lakshmanan, closes #6093)
This commit is contained in:
3
Filelist
3
Filelist
@ -133,6 +133,7 @@ SRC_ALL = \
|
||||
src/textobject.c \
|
||||
src/textprop.c \
|
||||
src/time.c \
|
||||
src/typval.c \
|
||||
src/ui.c \
|
||||
src/undo.c \
|
||||
src/usercmd.c \
|
||||
@ -285,6 +286,7 @@ SRC_ALL = \
|
||||
src/proto/textobject.pro \
|
||||
src/proto/textprop.pro \
|
||||
src/proto/time.pro \
|
||||
src/proto/typval.pro \
|
||||
src/proto/ui.pro \
|
||||
src/proto/undo.pro \
|
||||
src/proto/usercmd.pro \
|
||||
@ -347,6 +349,7 @@ SRC_ALL = \
|
||||
src/libvterm/t/29state_fallback.test \
|
||||
src/libvterm/t/30state_pen.test \
|
||||
src/libvterm/t/31state_rep.test \
|
||||
src/libvterm/t/32state_flow.test \
|
||||
src/libvterm/t/60screen_ascii.test \
|
||||
src/libvterm/t/61screen_unicode.test \
|
||||
src/libvterm/t/62screen_damage.test \
|
||||
|
@ -791,6 +791,7 @@ OBJ = \
|
||||
$(OUTDIR)/textobject.o \
|
||||
$(OUTDIR)/textprop.o \
|
||||
$(OUTDIR)/time.o \
|
||||
$(OUTDIR)/typval.o \
|
||||
$(OUTDIR)/ui.o \
|
||||
$(OUTDIR)/undo.o \
|
||||
$(OUTDIR)/usercmd.o \
|
||||
|
@ -107,6 +107,7 @@ SRC = arabic.c \
|
||||
textobject.c \
|
||||
textprop.c \
|
||||
time.c \
|
||||
typval.c \
|
||||
ui.c \
|
||||
undo.c \
|
||||
usercmd.c \
|
||||
|
@ -811,6 +811,7 @@ OBJ = \
|
||||
$(OUTDIR)\textobject.obj \
|
||||
$(OUTDIR)\textprop.obj \
|
||||
$(OUTDIR)\time.obj \
|
||||
$(OUTDIR)\typval.obj \
|
||||
$(OUTDIR)\ui.obj \
|
||||
$(OUTDIR)\undo.obj \
|
||||
$(OUTDIR)\usercmd.obj \
|
||||
@ -1755,6 +1756,8 @@ $(OUTDIR)/textprop.obj: $(OUTDIR) textprop.c $(INCL)
|
||||
|
||||
$(OUTDIR)/time.obj: $(OUTDIR) time.c $(INCL)
|
||||
|
||||
$(OUTDIR)/typval.obj: $(OUTDIR) typval.c $(INCL)
|
||||
|
||||
$(OUTDIR)/ui.obj: $(OUTDIR) ui.c $(INCL)
|
||||
|
||||
$(OUTDIR)/undo.obj: $(OUTDIR) undo.c $(INCL)
|
||||
@ -1954,6 +1957,7 @@ proto.h: \
|
||||
proto/textobject.pro \
|
||||
proto/textprop.pro \
|
||||
proto/time.pro \
|
||||
proto/typval.pro \
|
||||
proto/ui.pro \
|
||||
proto/undo.pro \
|
||||
proto/usercmd.pro \
|
||||
|
@ -386,6 +386,7 @@ SRC = \
|
||||
textobject.c \
|
||||
textprop.c \
|
||||
time.c \
|
||||
typval.c \
|
||||
ui.c \
|
||||
undo.c \
|
||||
usercmd.c \
|
||||
@ -497,6 +498,7 @@ OBJ = \
|
||||
textobject.obj \
|
||||
textprop.obj \
|
||||
time.obj \
|
||||
typval.obj \
|
||||
ui.obj \
|
||||
undo.obj \
|
||||
usercmd.obj \
|
||||
@ -1005,6 +1007,9 @@ textprop.obj : textprop.c vim.h [.auto]config.h feature.h os_unix.h \
|
||||
time.obj : time.c vim.h [.auto]config.h feature.h os_unix.h \
|
||||
ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \
|
||||
[.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h
|
||||
typval.obj : typval.c vim.h [.auto]config.h feature.h os_unix.h \
|
||||
ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \
|
||||
[.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h
|
||||
ui.obj : ui.c vim.h [.auto]config.h feature.h os_unix.h \
|
||||
ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \
|
||||
[.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h
|
||||
|
10
src/Makefile
10
src/Makefile
@ -1686,6 +1686,7 @@ BASIC_SRC = \
|
||||
textobject.c \
|
||||
textprop.c \
|
||||
time.c \
|
||||
typval.c \
|
||||
ui.c \
|
||||
undo.c \
|
||||
usercmd.c \
|
||||
@ -1830,6 +1831,7 @@ OBJ_COMMON = \
|
||||
objects/textobject.o \
|
||||
objects/textprop.o \
|
||||
objects/time.o \
|
||||
objects/typval.o \
|
||||
objects/ui.o \
|
||||
objects/undo.o \
|
||||
objects/usercmd.o \
|
||||
@ -2006,6 +2008,7 @@ PRO_AUTO = \
|
||||
textobject.pro \
|
||||
textprop.pro \
|
||||
time.pro \
|
||||
typval.pro \
|
||||
ui.pro \
|
||||
undo.pro \
|
||||
usercmd.pro \
|
||||
@ -3496,6 +3499,9 @@ objects/textprop.o: textprop.c
|
||||
objects/time.o: time.c
|
||||
$(CCC) -o $@ time.c
|
||||
|
||||
objects/typval.o: typval.c
|
||||
$(CCC) -o $@ typval.c
|
||||
|
||||
objects/ui.o: ui.c
|
||||
$(CCC) -o $@ ui.c
|
||||
|
||||
@ -4098,6 +4104,10 @@ objects/time.o: time.c vim.h protodef.h auto/config.h feature.h os_unix.h \
|
||||
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
||||
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
||||
proto.h globals.h
|
||||
objects/typval.o: typval.c vim.h protodef.h auto/config.h feature.h os_unix.h \
|
||||
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
||||
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
||||
proto.h globals.h
|
||||
objects/ui.o: ui.c vim.h protodef.h auto/config.h feature.h os_unix.h \
|
||||
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
||||
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
||||
|
@ -84,6 +84,7 @@ textformat.c | text formatting
|
||||
textobject.c | text objects
|
||||
textprop.c | text properties
|
||||
time.c | time and timer functions
|
||||
typval.c | vim script type/value functions
|
||||
undo.c | undo and redo
|
||||
usercmd.c | user defined commands
|
||||
userfunc.c | user defined functions
|
||||
|
1428
src/eval.c
1428
src/eval.c
File diff suppressed because it is too large
Load Diff
@ -1269,44 +1269,6 @@ non_zero_arg(typval_T *argvars)
|
||||
&& *argvars[0].vval.v_string != NUL));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the lnum from the first argument.
|
||||
* Also accepts ".", "$", etc., but that only works for the current buffer.
|
||||
* Returns -1 on error.
|
||||
*/
|
||||
linenr_T
|
||||
tv_get_lnum(typval_T *argvars)
|
||||
{
|
||||
linenr_T lnum;
|
||||
|
||||
lnum = (linenr_T)tv_get_number_chk(&argvars[0], NULL);
|
||||
if (lnum == 0) // no valid number, try using arg like line()
|
||||
{
|
||||
int fnum;
|
||||
pos_T *fp = var2fpos(&argvars[0], TRUE, &fnum);
|
||||
|
||||
if (fp != NULL)
|
||||
lnum = fp->lnum;
|
||||
}
|
||||
return lnum;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the lnum from the first argument.
|
||||
* Also accepts "$", then "buf" is used.
|
||||
* Returns 0 on error.
|
||||
*/
|
||||
linenr_T
|
||||
tv_get_lnum_buf(typval_T *argvars, buf_T *buf)
|
||||
{
|
||||
if (argvars[0].v_type == VAR_STRING
|
||||
&& argvars[0].vval.v_string != NULL
|
||||
&& argvars[0].vval.v_string[0] == '$'
|
||||
&& buf != NULL)
|
||||
return buf->b_ml.ml_line_count;
|
||||
return (linenr_T)tv_get_number_chk(&argvars[0], NULL);
|
||||
}
|
||||
|
||||
#ifdef FEAT_FLOAT
|
||||
/*
|
||||
* Get the float value of "argvars[0]" into "f".
|
||||
@ -1500,33 +1462,6 @@ f_balloon_split(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get buffer by number or pattern.
|
||||
*/
|
||||
buf_T *
|
||||
tv_get_buf(typval_T *tv, int curtab_only)
|
||||
{
|
||||
char_u *name = tv->vval.v_string;
|
||||
buf_T *buf;
|
||||
|
||||
if (tv->v_type == VAR_NUMBER)
|
||||
return buflist_findnr((int)tv->vval.v_number);
|
||||
if (tv->v_type != VAR_STRING)
|
||||
return NULL;
|
||||
if (name == NULL || *name == NUL)
|
||||
return curbuf;
|
||||
if (name[0] == '$' && name[1] == NUL)
|
||||
return lastbuf;
|
||||
|
||||
buf = buflist_find_by_name(name, curtab_only);
|
||||
|
||||
// If not found, try expanding the name, like done for bufexists().
|
||||
if (buf == NULL)
|
||||
buf = find_buffer(tv);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the buffer from "arg" and give an error and return NULL if it is not
|
||||
* valid.
|
||||
@ -5105,22 +5040,6 @@ f_invert(typval_T *argvars, typval_T *rettv)
|
||||
rettv->vval.v_number = ~tv_get_number_chk(&argvars[0], NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if typeval "tv" is locked: Either that value is locked itself
|
||||
* or it refers to a List or Dictionary that is locked.
|
||||
*/
|
||||
static int
|
||||
tv_islocked(typval_T *tv)
|
||||
{
|
||||
return (tv->v_lock & VAR_LOCKED)
|
||||
|| (tv->v_type == VAR_LIST
|
||||
&& tv->vval.v_list != NULL
|
||||
&& (tv->vval.v_list->lv_lock & VAR_LOCKED))
|
||||
|| (tv->v_type == VAR_DICT
|
||||
&& tv->vval.v_dict != NULL
|
||||
&& (tv->vval.v_dict->dv_lock & VAR_LOCKED));
|
||||
}
|
||||
|
||||
/*
|
||||
* "islocked()" function
|
||||
*/
|
||||
|
@ -1748,6 +1748,9 @@ EXTERN char e_notset[] INIT(= N_("E764: Option '%s' is not set"));
|
||||
#ifndef FEAT_CLIPBOARD
|
||||
EXTERN char e_invalidreg[] INIT(= N_("E850: Invalid register name"));
|
||||
#endif
|
||||
#ifdef FEAT_FLOAT
|
||||
EXTERN char e_float_as_string[] INIT(= N_("E806: using Float as a String"));
|
||||
#endif
|
||||
EXTERN char e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\""));
|
||||
EXTERN char e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior"));
|
||||
#ifdef FEAT_MENU
|
||||
|
@ -226,6 +226,7 @@ void mbyte_im_set_active(int active_arg);
|
||||
# include "textobject.pro"
|
||||
# include "textformat.pro"
|
||||
# include "time.pro"
|
||||
# include "typval.pro"
|
||||
# include "ui.pro"
|
||||
# include "undo.pro"
|
||||
# include "usercmd.pro"
|
||||
|
@ -29,13 +29,8 @@ int eval0(char_u *arg, typval_T *rettv, char_u **nextcmd, int evaluate);
|
||||
int eval1(char_u **arg, typval_T *rettv, int evaluate);
|
||||
void eval_addblob(typval_T *tv1, typval_T *tv2);
|
||||
int eval_addlist(typval_T *tv1, typval_T *tv2);
|
||||
int get_option_tv(char_u **arg, typval_T *rettv, int evaluate);
|
||||
int get_number_tv(char_u **arg, typval_T *rettv, int evaluate, int want_string);
|
||||
int get_string_tv(char_u **arg, typval_T *rettv, int evaluate);
|
||||
int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate);
|
||||
char_u *partial_name(partial_T *pt);
|
||||
void partial_unref(partial_T *pt);
|
||||
int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
|
||||
int get_copyID(void);
|
||||
int garbage_collect(int testing);
|
||||
int set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack);
|
||||
@ -45,10 +40,8 @@ int set_ref_in_list_items(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 composite_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);
|
||||
int get_env_tv(char_u **arg, typval_T *rettv, int evaluate);
|
||||
pos_T *var2fpos(typval_T *varp, int dollar_lnum, int *fnum);
|
||||
int list2fpos(typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp);
|
||||
int get_env_len(char_u **arg);
|
||||
@ -58,19 +51,6 @@ char_u *find_name_end(char_u *arg, char_u **expr_start, char_u **expr_end, int f
|
||||
int eval_isnamec(int c);
|
||||
int eval_isnamec1(int c);
|
||||
int handle_subscript(char_u **arg, typval_T *rettv, int evaluate, int verbose, char_u *start_leader, char_u **end_leaderp);
|
||||
typval_T *alloc_tv(void);
|
||||
typval_T *alloc_string_tv(char_u *s);
|
||||
void free_tv(typval_T *varp);
|
||||
void clear_tv(typval_T *varp);
|
||||
void init_tv(typval_T *varp);
|
||||
varnumber_T tv_get_number(typval_T *varp);
|
||||
varnumber_T tv_get_number_chk(typval_T *varp, int *denote);
|
||||
float_T tv_get_float(typval_T *varp);
|
||||
char_u *tv_get_string(typval_T *varp);
|
||||
char_u *tv_get_string_buf(typval_T *varp, char_u *buf);
|
||||
char_u *tv_get_string_chk(typval_T *varp);
|
||||
char_u *tv_get_string_buf_chk(typval_T *varp, char_u *buf);
|
||||
void copy_tv(typval_T *from, typval_T *to);
|
||||
int item_copy(typval_T *from, typval_T *to, int deep, int copyID);
|
||||
void echo_one(typval_T *rettv, int with_space, int *atstart, int *needclr);
|
||||
void ex_echo(exarg_T *eap);
|
||||
@ -79,7 +59,5 @@ int get_echo_attr(void);
|
||||
void ex_execute(exarg_T *eap);
|
||||
char_u *find_option_end(char_u **arg, int *opt_flags);
|
||||
void last_set_msg(sctx_T script_ctx);
|
||||
int typval_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int ic);
|
||||
char_u *typval_tostring(typval_T *arg);
|
||||
char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, typval_T *expr, char_u *flags);
|
||||
/* vim: set ft=c : */
|
||||
|
@ -10,9 +10,6 @@ int call_internal_func(char_u *name, int argcount, typval_T *argvars, typval_T *
|
||||
void call_internal_func_by_idx(int idx, typval_T *argvars, typval_T *rettv);
|
||||
int call_internal_method(char_u *name, int argcount, typval_T *argvars, typval_T *rettv, typval_T *basetv);
|
||||
int non_zero_arg(typval_T *argvars);
|
||||
linenr_T tv_get_lnum(typval_T *argvars);
|
||||
linenr_T tv_get_lnum_buf(typval_T *argvars, buf_T *buf);
|
||||
buf_T *tv_get_buf(typval_T *tv, int curtab_only);
|
||||
buf_T *get_buf_arg(typval_T *arg);
|
||||
win_T *get_optional_window(typval_T *argvars, int idx);
|
||||
void execute_redir_str(char_u *value, int value_len);
|
||||
|
30
src/proto/typval.pro
Normal file
30
src/proto/typval.pro
Normal file
@ -0,0 +1,30 @@
|
||||
/* typval.c */
|
||||
typval_T *alloc_tv(void);
|
||||
typval_T *alloc_string_tv(char_u *s);
|
||||
void free_tv(typval_T *varp);
|
||||
void clear_tv(typval_T *varp);
|
||||
void init_tv(typval_T *varp);
|
||||
int tv_check_lock(typval_T *tv, char_u *name, int use_gettext);
|
||||
void copy_tv(typval_T *from, typval_T *to);
|
||||
int typval_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int ic);
|
||||
char_u *typval_tostring(typval_T *arg);
|
||||
int tv_islocked(typval_T *tv);
|
||||
int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
|
||||
int get_option_tv(char_u **arg, typval_T *rettv, int evaluate);
|
||||
int get_number_tv(char_u **arg, typval_T *rettv, int evaluate, int want_string);
|
||||
int get_string_tv(char_u **arg, typval_T *rettv, int evaluate);
|
||||
int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate);
|
||||
char_u *tv2string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID);
|
||||
int get_env_tv(char_u **arg, typval_T *rettv, int evaluate);
|
||||
varnumber_T tv_get_number(typval_T *varp);
|
||||
varnumber_T tv_get_number_chk(typval_T *varp, int *denote);
|
||||
float_T tv_get_float(typval_T *varp);
|
||||
char_u *tv_get_string(typval_T *varp);
|
||||
char_u *tv_get_string_buf(typval_T *varp, char_u *buf);
|
||||
char_u *tv_get_string_chk(typval_T *varp);
|
||||
char_u *tv_get_string_buf_chk(typval_T *varp, char_u *buf);
|
||||
linenr_T tv_get_lnum(typval_T *argvars);
|
||||
linenr_T tv_get_lnum_buf(typval_T *argvars, buf_T *buf);
|
||||
buf_T *tv_get_buf(typval_T *tv, int curtab_only);
|
||||
char_u *tv_stringify(typval_T *varp, char_u *buf);
|
||||
/* vim: set ft=c : */
|
1508
src/typval.c
Normal file
1508
src/typval.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -746,6 +746,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
847,
|
||||
/**/
|
||||
846,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user