comparison src/channel.c @ 17606:ff097edaae89 v8.1.1800

patch 8.1.1800: function call functions have too many arguments commit https://github.com/vim/vim/commit/c6538bcc1cdd1fb83732f22fdc69bd9bb66f968a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 3 18:17:11 2019 +0200 patch 8.1.1800: function call functions have too many arguments Problem: Function call functions have too many arguments. Solution: Pass values in a funcexe_T struct.
author Bram Moolenaar <Bram@vim.org>
date Sat, 03 Aug 2019 18:30:07 +0200
parents 4a22102fda8f
children 0f7ae8010787
comparison
equal deleted inserted replaced
17605:bb1b495f4e05 17606:ff097edaae89
1631 */ 1631 */
1632 static void 1632 static void
1633 invoke_callback(channel_T *channel, callback_T *callback, typval_T *argv) 1633 invoke_callback(channel_T *channel, callback_T *callback, typval_T *argv)
1634 { 1634 {
1635 typval_T rettv; 1635 typval_T rettv;
1636 int dummy;
1637 1636
1638 if (safe_to_invoke_callback == 0) 1637 if (safe_to_invoke_callback == 0)
1639 iemsg("INTERNAL: Invoking callback when it is not safe"); 1638 iemsg("INTERNAL: Invoking callback when it is not safe");
1640 1639
1641 argv[0].v_type = VAR_CHANNEL; 1640 argv[0].v_type = VAR_CHANNEL;
1642 argv[0].vval.v_channel = channel; 1641 argv[0].vval.v_channel = channel;
1643 1642
1644 call_callback(callback, -1, &rettv, 2, argv, NULL, 1643 call_callback(callback, -1, &rettv, 2, argv);
1645 0L, 0L, &dummy, TRUE, NULL);
1646 clear_tv(&rettv); 1644 clear_tv(&rettv);
1647 channel_need_redraw = TRUE; 1645 channel_need_redraw = TRUE;
1648 } 1646 }
1649 1647
1650 /* 1648 /*
3027 3025
3028 if (channel->ch_close_cb.cb_name != NULL) 3026 if (channel->ch_close_cb.cb_name != NULL)
3029 { 3027 {
3030 typval_T argv[1]; 3028 typval_T argv[1];
3031 typval_T rettv; 3029 typval_T rettv;
3032 int dummy;
3033 3030
3034 /* Increment the refcount to avoid the channel being freed 3031 /* Increment the refcount to avoid the channel being freed
3035 * halfway. */ 3032 * halfway. */
3036 ++channel->ch_refcount; 3033 ++channel->ch_refcount;
3037 ch_log(channel, "Invoking close callback %s", 3034 ch_log(channel, "Invoking close callback %s",
3038 (char *)channel->ch_close_cb.cb_name); 3035 (char *)channel->ch_close_cb.cb_name);
3039 argv[0].v_type = VAR_CHANNEL; 3036 argv[0].v_type = VAR_CHANNEL;
3040 argv[0].vval.v_channel = channel; 3037 argv[0].vval.v_channel = channel;
3041 call_callback(&channel->ch_close_cb, -1, 3038 call_callback(&channel->ch_close_cb, -1, &rettv, 1, argv);
3042 &rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE, NULL);
3043 clear_tv(&rettv); 3039 clear_tv(&rettv);
3044 channel_need_redraw = TRUE; 3040 channel_need_redraw = TRUE;
3045 3041
3046 /* the callback is only called once */ 3042 /* the callback is only called once */
3047 free_callback(&channel->ch_close_cb); 3043 free_callback(&channel->ch_close_cb);
5539 5535
5540 if (job->jv_exit_cb.cb_name != NULL) 5536 if (job->jv_exit_cb.cb_name != NULL)
5541 { 5537 {
5542 typval_T argv[3]; 5538 typval_T argv[3];
5543 typval_T rettv; 5539 typval_T rettv;
5544 int dummy;
5545 5540
5546 /* Invoke the exit callback. Make sure the refcount is > 0. */ 5541 /* Invoke the exit callback. Make sure the refcount is > 0. */
5547 ch_log(job->jv_channel, "Invoking exit callback %s", 5542 ch_log(job->jv_channel, "Invoking exit callback %s",
5548 job->jv_exit_cb.cb_name); 5543 job->jv_exit_cb.cb_name);
5549 ++job->jv_refcount; 5544 ++job->jv_refcount;
5550 argv[0].v_type = VAR_JOB; 5545 argv[0].v_type = VAR_JOB;
5551 argv[0].vval.v_job = job; 5546 argv[0].vval.v_job = job;
5552 argv[1].v_type = VAR_NUMBER; 5547 argv[1].v_type = VAR_NUMBER;
5553 argv[1].vval.v_number = job->jv_exitval; 5548 argv[1].vval.v_number = job->jv_exitval;
5554 call_callback(&job->jv_exit_cb, -1, 5549 call_callback(&job->jv_exit_cb, -1, &rettv, 2, argv);
5555 &rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE, NULL);
5556 clear_tv(&rettv); 5550 clear_tv(&rettv);
5557 --job->jv_refcount; 5551 --job->jv_refcount;
5558 channel_need_redraw = TRUE; 5552 channel_need_redraw = TRUE;
5559 } 5553 }
5560 5554
6034 6028
6035 void 6029 void
6036 invoke_prompt_callback(void) 6030 invoke_prompt_callback(void)
6037 { 6031 {
6038 typval_T rettv; 6032 typval_T rettv;
6039 int dummy;
6040 typval_T argv[2]; 6033 typval_T argv[2];
6041 char_u *text; 6034 char_u *text;
6042 char_u *prompt; 6035 char_u *prompt;
6043 linenr_T lnum = curbuf->b_ml.ml_line_count; 6036 linenr_T lnum = curbuf->b_ml.ml_line_count;
6044 6037
6057 text += STRLEN(prompt); 6050 text += STRLEN(prompt);
6058 argv[0].v_type = VAR_STRING; 6051 argv[0].v_type = VAR_STRING;
6059 argv[0].vval.v_string = vim_strsave(text); 6052 argv[0].vval.v_string = vim_strsave(text);
6060 argv[1].v_type = VAR_UNKNOWN; 6053 argv[1].v_type = VAR_UNKNOWN;
6061 6054
6062 call_callback(&curbuf->b_prompt_callback, -1, 6055 call_callback(&curbuf->b_prompt_callback, -1, &rettv, 1, argv);
6063 &rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE, NULL);
6064 clear_tv(&argv[0]); 6056 clear_tv(&argv[0]);
6065 clear_tv(&rettv); 6057 clear_tv(&rettv);
6066 } 6058 }
6067 6059
6068 /* 6060 /*
6070 */ 6062 */
6071 int 6063 int
6072 invoke_prompt_interrupt(void) 6064 invoke_prompt_interrupt(void)
6073 { 6065 {
6074 typval_T rettv; 6066 typval_T rettv;
6075 int dummy;
6076 typval_T argv[1]; 6067 typval_T argv[1];
6077 6068
6078 if (curbuf->b_prompt_interrupt.cb_name == NULL 6069 if (curbuf->b_prompt_interrupt.cb_name == NULL
6079 || *curbuf->b_prompt_interrupt.cb_name == NUL) 6070 || *curbuf->b_prompt_interrupt.cb_name == NUL)
6080 return FALSE; 6071 return FALSE;
6081 argv[0].v_type = VAR_UNKNOWN; 6072 argv[0].v_type = VAR_UNKNOWN;
6082 6073
6083 got_int = FALSE; // don't skip executing commands 6074 got_int = FALSE; // don't skip executing commands
6084 call_callback(&curbuf->b_prompt_interrupt, -1, 6075 call_callback(&curbuf->b_prompt_interrupt, -1, &rettv, 0, argv);
6085 &rettv, 0, argv, NULL, 0L, 0L, &dummy, TRUE, NULL);
6086 clear_tv(&rettv); 6076 clear_tv(&rettv);
6087 return TRUE; 6077 return TRUE;
6088 } 6078 }
6089 6079
6090 /* 6080 /*