diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-06-24 00:43:35 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-06-24 00:43:35 +0200 |
commit | 0a1f56fcfe31be929e9cd8c3d81a984c960e4180 (patch) | |
tree | 7bc7684aa4eccb489a5a6a1636dd612397c7348f /src/evalfunc.c | |
parent | 7be3ab25891fec711d8a2d9d242711a9155852b6 (diff) | |
download | vim-git-0a1f56fcfe31be929e9cd8c3d81a984c960e4180.tar.gz |
patch 8.1.1584: the evalfunc.c file is getting too bigv8.1.1584
Problem: The evalfunc.c file is getting too big.
Solution: Move channel and job related functions to channel.c.
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 470 |
1 files changed, 0 insertions, 470 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 7930eb982..faedda31c 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -86,26 +86,6 @@ static void f_call(typval_T *argvars, typval_T *rettv); #ifdef FEAT_FLOAT static void f_ceil(typval_T *argvars, typval_T *rettv); #endif -#ifdef FEAT_JOB_CHANNEL -static void f_ch_canread(typval_T *argvars, typval_T *rettv); -static void f_ch_close(typval_T *argvars, typval_T *rettv); -static void f_ch_close_in(typval_T *argvars, typval_T *rettv); -static void f_ch_evalexpr(typval_T *argvars, typval_T *rettv); -static void f_ch_evalraw(typval_T *argvars, typval_T *rettv); -static void f_ch_getbufnr(typval_T *argvars, typval_T *rettv); -static void f_ch_getjob(typval_T *argvars, typval_T *rettv); -static void f_ch_info(typval_T *argvars, typval_T *rettv); -static void f_ch_log(typval_T *argvars, typval_T *rettv); -static void f_ch_logfile(typval_T *argvars, typval_T *rettv); -static void f_ch_open(typval_T *argvars, typval_T *rettv); -static void f_ch_read(typval_T *argvars, typval_T *rettv); -static void f_ch_readblob(typval_T *argvars, typval_T *rettv); -static void f_ch_readraw(typval_T *argvars, typval_T *rettv); -static void f_ch_sendexpr(typval_T *argvars, typval_T *rettv); -static void f_ch_sendraw(typval_T *argvars, typval_T *rettv); -static void f_ch_setoptions(typval_T *argvars, typval_T *rettv); -static void f_ch_status(typval_T *argvars, typval_T *rettv); -#endif static void f_changenr(typval_T *argvars, typval_T *rettv); static void f_char2nr(typval_T *argvars, typval_T *rettv); static void f_chdir(typval_T *argvars, typval_T *rettv); @@ -246,14 +226,6 @@ static void f_isinf(typval_T *argvars, typval_T *rettv); static void f_isnan(typval_T *argvars, typval_T *rettv); #endif static void f_items(typval_T *argvars, typval_T *rettv); -#ifdef FEAT_JOB_CHANNEL -static void f_job_getchannel(typval_T *argvars, typval_T *rettv); -static void f_job_info(typval_T *argvars, typval_T *rettv); -static void f_job_setoptions(typval_T *argvars, typval_T *rettv); -static void f_job_start(typval_T *argvars, typval_T *rettv); -static void f_job_stop(typval_T *argvars, typval_T *rettv); -static void f_job_status(typval_T *argvars, typval_T *rettv); -#endif static void f_join(typval_T *argvars, typval_T *rettv); static void f_js_decode(typval_T *argvars, typval_T *rettv); static void f_js_encode(typval_T *argvars, typval_T *rettv); @@ -309,11 +281,6 @@ static void f_pow(typval_T *argvars, typval_T *rettv); #endif static void f_prevnonblank(typval_T *argvars, typval_T *rettv); static void f_printf(typval_T *argvars, typval_T *rettv); -#ifdef FEAT_JOB_CHANNEL -static void f_prompt_setcallback(typval_T *argvars, typval_T *rettv); -static void f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv); -static void f_prompt_setprompt(typval_T *argvars, typval_T *rettv); -#endif static void f_pumvisible(typval_T *argvars, typval_T *rettv); #ifdef FEAT_PYTHON3 static void f_py3eval(typval_T *argvars, typval_T *rettv); @@ -2271,262 +2238,6 @@ f_ceil(typval_T *argvars, typval_T *rettv) } #endif -#ifdef FEAT_JOB_CHANNEL -/* - * "ch_canread()" function - */ - static void -f_ch_canread(typval_T *argvars, typval_T *rettv) -{ - channel_T *channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); - - rettv->vval.v_number = 0; - if (channel != NULL) - rettv->vval.v_number = channel_has_readahead(channel, PART_SOCK) - || channel_has_readahead(channel, PART_OUT) - || channel_has_readahead(channel, PART_ERR); -} - -/* - * "ch_close()" function - */ - static void -f_ch_close(typval_T *argvars, typval_T *rettv UNUSED) -{ - channel_T *channel = get_channel_arg(&argvars[0], TRUE, FALSE, 0); - - if (channel != NULL) - { - channel_close(channel, FALSE); - channel_clear(channel); - } -} - -/* - * "ch_close()" function - */ - static void -f_ch_close_in(typval_T *argvars, typval_T *rettv UNUSED) -{ - channel_T *channel = get_channel_arg(&argvars[0], TRUE, FALSE, 0); - - if (channel != NULL) - channel_close_in(channel); -} - -/* - * "ch_getbufnr()" function - */ - static void -f_ch_getbufnr(typval_T *argvars, typval_T *rettv) -{ - channel_T *channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); - - rettv->vval.v_number = -1; - if (channel != NULL) - { - char_u *what = tv_get_string(&argvars[1]); - int part; - - if (STRCMP(what, "err") == 0) - part = PART_ERR; - else if (STRCMP(what, "out") == 0) - part = PART_OUT; - else if (STRCMP(what, "in") == 0) - part = PART_IN; - else - part = PART_SOCK; - if (channel->ch_part[part].ch_bufref.br_buf != NULL) - rettv->vval.v_number = - channel->ch_part[part].ch_bufref.br_buf->b_fnum; - } -} - -/* - * "ch_getjob()" function - */ - static void -f_ch_getjob(typval_T *argvars, typval_T *rettv) -{ - channel_T *channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); - - if (channel != NULL) - { - rettv->v_type = VAR_JOB; - rettv->vval.v_job = channel->ch_job; - if (channel->ch_job != NULL) - ++channel->ch_job->jv_refcount; - } -} - -/* - * "ch_info()" function - */ - static void -f_ch_info(typval_T *argvars, typval_T *rettv UNUSED) -{ - channel_T *channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); - - if (channel != NULL && rettv_dict_alloc(rettv) != FAIL) - channel_info(channel, rettv->vval.v_dict); -} - -/* - * "ch_log()" function - */ - static void -f_ch_log(typval_T *argvars, typval_T *rettv UNUSED) -{ - char_u *msg = tv_get_string(&argvars[0]); - channel_T *channel = NULL; - - if (argvars[1].v_type != VAR_UNKNOWN) - channel = get_channel_arg(&argvars[1], FALSE, FALSE, 0); - - ch_log(channel, "%s", msg); -} - -/* - * "ch_logfile()" function - */ - static void -f_ch_logfile(typval_T *argvars, typval_T *rettv UNUSED) -{ - char_u *fname; - char_u *opt = (char_u *)""; - char_u buf[NUMBUFLEN]; - - /* Don't open a file in restricted mode. */ - if (check_restricted() || check_secure()) - return; - fname = tv_get_string(&argvars[0]); - if (argvars[1].v_type == VAR_STRING) - opt = tv_get_string_buf(&argvars[1], buf); - ch_logfile(fname, opt); -} - -/* - * "ch_open()" function - */ - static void -f_ch_open(typval_T *argvars, typval_T *rettv) -{ - rettv->v_type = VAR_CHANNEL; - if (check_restricted() || check_secure()) - return; - rettv->vval.v_channel = channel_open_func(argvars); -} - -/* - * "ch_read()" function - */ - static void -f_ch_read(typval_T *argvars, typval_T *rettv) -{ - common_channel_read(argvars, rettv, FALSE, FALSE); -} - -/* - * "ch_readblob()" function - */ - static void -f_ch_readblob(typval_T *argvars, typval_T *rettv) -{ - common_channel_read(argvars, rettv, TRUE, TRUE); -} - -/* - * "ch_readraw()" function - */ - static void -f_ch_readraw(typval_T *argvars, typval_T *rettv) -{ - common_channel_read(argvars, rettv, TRUE, FALSE); -} - -/* - * "ch_evalexpr()" function - */ - static void -f_ch_evalexpr(typval_T *argvars, typval_T *rettv) -{ - ch_expr_common(argvars, rettv, TRUE); -} - -/* - * "ch_sendexpr()" function - */ - static void -f_ch_sendexpr(typval_T *argvars, typval_T *rettv) -{ - ch_expr_common(argvars, rettv, FALSE); -} - -/* - * "ch_evalraw()" function - */ - static void -f_ch_evalraw(typval_T *argvars, typval_T *rettv) -{ - ch_raw_common(argvars, rettv, TRUE); -} - -/* - * "ch_sendraw()" function - */ - static void -f_ch_sendraw(typval_T *argvars, typval_T *rettv) -{ - ch_raw_common(argvars, rettv, FALSE); -} - -/* - * "ch_setoptions()" function - */ - static void -f_ch_setoptions(typval_T *argvars, typval_T *rettv UNUSED) -{ - channel_T *channel; - jobopt_T opt; - - channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); - if (channel == NULL) - return; - clear_job_options(&opt); - if (get_job_options(&argvars[1], &opt, - JO_CB_ALL + JO_TIMEOUT_ALL + JO_MODE_ALL, 0) == OK) - channel_set_options(channel, &opt); - free_job_options(&opt); -} - -/* - * "ch_status()" function - */ - static void -f_ch_status(typval_T *argvars, typval_T *rettv) -{ - channel_T *channel; - jobopt_T opt; - int part = -1; - - /* return an empty string by default */ - rettv->v_type = VAR_STRING; - rettv->vval.v_string = NULL; - - channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); - - if (argvars[1].v_type != VAR_UNKNOWN) - { - clear_job_options(&opt); - if (get_job_options(&argvars[1], &opt, JO_PART, 0) == OK - && (opt.jo_set & JO_PART)) - part = opt.jo_part; - } - - rettv->vval.v_string = vim_strsave((char_u *)channel_status(channel, part)); -} -#endif - /* * "changenr()" function */ @@ -7750,119 +7461,6 @@ f_items(typval_T *argvars, typval_T *rettv) dict_list(argvars, rettv, 2); } -#if defined(FEAT_JOB_CHANNEL) || defined(PROTO) -/* - * Get the job from the argument. - * Returns NULL if the job is invalid. - */ - static job_T * -get_job_arg(typval_T *tv) -{ - job_T *job; - - if (tv->v_type != VAR_JOB) - { - semsg(_(e_invarg2), tv_get_string(tv)); - return NULL; - } - job = tv->vval.v_job; - - if (job == NULL) - emsg(_("E916: not a valid job")); - return job; -} - -/* - * "job_getchannel()" function - */ - static void -f_job_getchannel(typval_T *argvars, typval_T *rettv) -{ - job_T *job = get_job_arg(&argvars[0]); - - if (job != NULL) - { - rettv->v_type = VAR_CHANNEL; - rettv->vval.v_channel = job->jv_channel; - if (job->jv_channel != NULL) - ++job->jv_channel->ch_refcount; - } -} - -/* - * "job_info()" function - */ - static void -f_job_info(typval_T *argvars, typval_T *rettv) -{ - if (argvars[0].v_type != VAR_UNKNOWN) - { - job_T *job = get_job_arg(&argvars[0]); - - if (job != NULL && rettv_dict_alloc(rettv) != FAIL) - job_info(job, rettv->vval.v_dict); - } - else if (rettv_list_alloc(rettv) == OK) - job_info_all(rettv->vval.v_list); -} - -/* - * "job_setoptions()" function - */ - static void -f_job_setoptions(typval_T *argvars, typval_T *rettv UNUSED) -{ - job_T *job = get_job_arg(&argvars[0]); - jobopt_T opt; - - if (job == NULL) - return; - clear_job_options(&opt); - if (get_job_options(&argvars[1], &opt, JO_STOPONEXIT + JO_EXIT_CB, 0) == OK) - job_set_options(job, &opt); - free_job_options(&opt); -} - -/* - * "job_start()" function - */ - static void -f_job_start(typval_T *argvars, typval_T *rettv) -{ - rettv->v_type = VAR_JOB; - if (check_restricted() || check_secure()) - return; - rettv->vval.v_job = job_start(argvars, NULL, NULL, FALSE); -} - -/* - * "job_status()" function - */ - static void -f_job_status(typval_T *argvars, typval_T *rettv) -{ - job_T *job = get_job_arg(&argvars[0]); - - if (job != NULL) - { - rettv->v_type = VAR_STRING; - rettv->vval.v_string = vim_strsave((char_u *)job_status(job)); - } -} - -/* - * "job_stop()" function - */ - static void -f_job_stop(typval_T *argvars, typval_T *rettv) -{ - job_T *job = get_job_arg(&argvars[0]); - - if (job != NULL) - rettv->vval.v_number = job_stop(job, argvars, NULL); -} -#endif - /* * "join()" function */ @@ -9248,74 +8846,6 @@ f_printf(typval_T *argvars, typval_T *rettv) did_emsg |= saved_did_emsg; } -#ifdef FEAT_JOB_CHANNEL -/* - * "prompt_setcallback({buffer}, {callback})" function - */ - static void -f_prompt_setcallback(typval_T *argvars, typval_T *rettv UNUSED) -{ - buf_T *buf; - callback_T callback; - - if (check_secure()) - return; - buf = tv_get_buf(&argvars[0], FALSE); - if (buf == NULL) - return; - - callback = get_callback(&argvars[1]); - if (callback.cb_name == NULL) - return; - - free_callback(&buf->b_prompt_callback); - set_callback(&buf->b_prompt_callback, &callback); -} - -/* - * "prompt_setinterrupt({buffer}, {callback})" function - */ - static void -f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv UNUSED) -{ - buf_T *buf; - callback_T callback; - - if (check_secure()) - return; - buf = tv_get_buf(&argvars[0], FALSE); - if (buf == NULL) - return; - - callback = get_callback(&argvars[1]); - if (callback.cb_name == NULL) - return; - - free_callback(&buf->b_prompt_interrupt); - set_callback(&buf->b_prompt_interrupt, &callback); -} - -/* - * "prompt_setprompt({buffer}, {text})" function - */ - static void -f_prompt_setprompt(typval_T *argvars, typval_T *rettv UNUSED) -{ - buf_T *buf; - char_u *text; - - if (check_secure()) - return; - buf = tv_get_buf(&argvars[0], FALSE); - if (buf == NULL) - return; - - text = tv_get_string(&argvars[1]); - vim_free(buf->b_prompt_text); - buf->b_prompt_text = vim_strsave(text); -} -#endif - /* * "pumvisible()" function */ |