Mercurial > vim
diff src/ex_cmds2.c @ 16872:a836d122231a v8.1.1437
patch 8.1.1437: code to handle callbacks is duplicated
commit https://github.com/vim/vim/commit/3a97bb3f0f8bd118ae23f1c97e55d84ff42eef20
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 1 13:28:35 2019 +0200
patch 8.1.1437: code to handle callbacks is duplicated
Problem: Code to handle callbacks is duplicated.
Solution: Add callback_T and functions to deal with it.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Jun 2019 13:30:07 +0200 |
parents | ce04ebdf26b8 |
children | da5f5836e90c |
line wrap: on
line diff
--- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -282,7 +282,7 @@ remove_timer(timer_T *timer) static void free_timer(timer_T *timer) { - free_callback(timer->tr_callback, timer->tr_partial); + free_callback(&timer->tr_callback); vim_free(timer); } @@ -325,9 +325,8 @@ timer_callback(timer_T *timer) argv[0].vval.v_number = (varnumber_T)timer->tr_id; argv[1].v_type = VAR_UNKNOWN; - call_func(timer->tr_callback, -1, - &rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE, - timer->tr_partial, NULL); + call_callback(&timer->tr_callback, -1, + &rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE, NULL); clear_tv(&rettv); } @@ -542,17 +541,8 @@ add_timer_info(typval_T *rettv, timer_T { if (dict_add(dict, di) == FAIL) vim_free(di); - else if (timer->tr_partial != NULL) - { - di->di_tv.v_type = VAR_PARTIAL; - di->di_tv.vval.v_partial = timer->tr_partial; - ++timer->tr_partial->pt_refcount; - } else - { - di->di_tv.v_type = VAR_FUNC; - di->di_tv.vval.v_string = vim_strsave(timer->tr_callback); - } + put_callback(&timer->tr_callback, &di->di_tv); } } @@ -578,15 +568,15 @@ set_ref_in_timer(int copyID) for (timer = first_timer; timer != NULL; timer = timer->tr_next) { - if (timer->tr_partial != NULL) + if (timer->tr_callback.cb_partial != NULL) { tv.v_type = VAR_PARTIAL; - tv.vval.v_partial = timer->tr_partial; + tv.vval.v_partial = timer->tr_callback.cb_partial; } else { tv.v_type = VAR_FUNC; - tv.vval.v_string = timer->tr_callback; + tv.vval.v_string = timer->tr_callback.cb_name; } abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); }