comparison src/testing.c @ 24998:3b1770226f85 v8.2.3036

patch 8.2.3036: Vim9: builtin function arguments not checked at compile time Commit: https://github.com/vim/vim/commit/7237cab8f1d1a4391372cafdb57f2d97f3b32d05 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Tue Jun 22 19:52:27 2021 +0200 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time Problem: Vim9: builtin function arguments not checked at compile time. Solution: Add more argument type specs. Check arguments to test_setmouse() and test_gui_mouse_event(). (Yegappan Lakshmanan, closes #8425)
author Bram Moolenaar <Bram@vim.org>
date Tue, 22 Jun 2021 20:00:05 +0200
parents 4cb423b9250d
children 496221916885
comparison
equal deleted inserted replaced
24997:6cd844668030 24998:3b1770226f85
1209 #endif 1209 #endif
1210 1210
1211 void 1211 void
1212 f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED) 1212 f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED)
1213 { 1213 {
1214 if (argvars[0].v_type != VAR_NUMBER || (argvars[1].v_type) != VAR_NUMBER)
1215 {
1216 emsg(_(e_invarg));
1217 return;
1218 }
1219
1214 mouse_row = (time_t)tv_get_number(&argvars[0]) - 1; 1220 mouse_row = (time_t)tv_get_number(&argvars[0]) - 1;
1215 mouse_col = (time_t)tv_get_number(&argvars[1]) - 1; 1221 mouse_col = (time_t)tv_get_number(&argvars[1]) - 1;
1216 } 1222 }
1217 1223
1218 void 1224 void
1219 f_test_gui_mouse_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED) 1225 f_test_gui_mouse_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
1220 { 1226 {
1221 #ifdef FEAT_GUI 1227 #ifdef FEAT_GUI
1222 int button = tv_get_number(&argvars[0]); 1228 int button;
1223 int row = tv_get_number(&argvars[1]); 1229 int row;
1224 int col = tv_get_number(&argvars[2]); 1230 int col;
1225 int repeated_click = tv_get_number(&argvars[3]); 1231 int repeated_click;
1226 int_u mods = tv_get_number(&argvars[4]); 1232 int_u mods;
1233
1234 if (argvars[0].v_type != VAR_NUMBER
1235 || (argvars[1].v_type) != VAR_NUMBER
1236 || (argvars[2].v_type) != VAR_NUMBER
1237 || (argvars[3].v_type) != VAR_NUMBER
1238 || (argvars[4].v_type) != VAR_NUMBER)
1239 {
1240 emsg(_(e_invarg));
1241 return;
1242 }
1243
1244 button = tv_get_number(&argvars[0]);
1245 row = tv_get_number(&argvars[1]);
1246 col = tv_get_number(&argvars[2]);
1247 repeated_click = tv_get_number(&argvars[3]);
1248 mods = tv_get_number(&argvars[4]);
1227 1249
1228 gui_send_mouse_event(button, TEXT_X(col - 1), TEXT_Y(row - 1), repeated_click, mods); 1250 gui_send_mouse_event(button, TEXT_X(col - 1), TEXT_Y(row - 1), repeated_click, mods);
1229 #endif 1251 #endif
1230 } 1252 }
1231 1253