Patch 7.4.1541
Problem: Missing job_info().
Solution: Implement it.
Files: src/eval.c, src/channel.c, src/proto/channel.pro,
src/testdir/test_channel.vim, runtime/doc/eval.txt
*** ../vim-7.4.1540/src/eval.c 2016-03-12 13:43:28.860478230 +0100
--- src/eval.c 2016-03-12 14:50:34.342756694 +0100
***************
*** 632,637 ****
--- 632,638 ----
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);
***************
*** 8208,8213 ****
--- 8209,8215 ----
{"items", 1, 1, f_items},
#ifdef FEAT_JOB_CHANNEL
{"job_getchannel", 1, 1, f_job_getchannel},
+ {"job_info", 1, 1, f_job_info},
{"job_setoptions", 2, 2, f_job_setoptions},
{"job_start", 1, 2, f_job_start},
{"job_status", 1, 1, f_job_status},
***************
*** 14342,14347 ****
--- 14344,14361 ----
}
/*
+ * "job_info()" function
+ */
+ static void
+ f_job_info(typval_T *argvars, typval_T *rettv)
+ {
+ job_T *job = get_job_arg(&argvars[0]);
+
+ if (job != NULL && rettv_dict_alloc(rettv) != FAIL)
+ job_info(job, rettv->vval.v_dict);
+ }
+
+ /*
* "job_setoptions()" function
*/
static void
***************
*** 14375,14387 ****
f_job_status(typval_T *argvars, typval_T *rettv)
{
job_T *job = get_job_arg(&argvars[0]);
- char *result;
if (job != NULL)
{
- result = job_status(job);
rettv->v_type = VAR_STRING;
! rettv->vval.v_string = vim_strsave((char_u *)result);
}
}
--- 14389,14399 ----
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));
}
}
*** ../vim-7.4.1540/src/channel.c 2016-03-12 13:43:28.860478230 +0100
--- src/channel.c 2016-03-12 15:10:49.234061035 +0100
***************
*** 3725,3730 ****
--- 3725,3764 ----
return result;
}
+ /*
+ * Implementation of job_info().
+ */
+ void
+ job_info(job_T *job, dict_T *dict)
+ {
+ dictitem_T *item;
+ varnumber_T nr;
+
+ dict_add_nr_str(dict, "status", 0L, (char_u *)job_status(job));
+
+ item = dictitem_alloc((char_u *)"channel");
+ if (item == NULL)
+ return;
+ item->di_tv.v_lock = 0;
+ item->di_tv.v_type = VAR_CHANNEL;
+ item->di_tv.vval.v_channel = job->jv_channel;
+ if (job->jv_channel != NULL)
+ ++job->jv_channel->ch_refcount;
+ if (dict_add(dict, item) == FAIL)
+ dictitem_free(item);
+
+ #ifdef UNIX
+ nr = job->jv_pid;
+ #else
+ nr = job->jv_proc_info.dwProcessId;
+ #endif
+ dict_add_nr_str(dict, "process", nr, NULL);
+
+ dict_add_nr_str(dict, "exitval", job->jv_exitval, NULL);
+ dict_add_nr_str(dict, "exit-cb", 0L, job->jv_exit_cb);
+ dict_add_nr_str(dict, "stoponexit", 0L, job->jv_stoponexit);
+ }
+
int
job_stop(job_T *job, typval_T *argvars)
{
*** ../vim-7.4.1540/src/proto/channel.pro 2016-03-12 13:43:28.860478230
+0100
--- src/proto/channel.pro 2016-03-12 15:08:01.699810351 +0100
***************
*** 54,58 ****
--- 54,59 ----
void job_check_ended(void);
job_T *job_start(typval_T *argvars);
char *job_status(job_T *job);
+ void job_info(job_T *job, dict_T *dict);
int job_stop(job_T *job, typval_T *argvars);
/* vim: set ft=c : */
*** ../vim-7.4.1540/src/testdir/test_channel.vim 2016-03-12
13:48:45.505207726 +0100
--- src/testdir/test_channel.vim 2016-03-12 15:20:25.472047227 +0100
***************
*** 479,484 ****
--- 479,490 ----
finally
call job_stop(job)
endtry
+
+ let s:job = job
+ call s:waitFor('"dead" == job_status(s:job)')
+ let info = job_info(job)
+ call assert_equal("dead", info.status)
+ call assert_equal("term", info.stoponexit)
endfunc
func Test_nl_pipe()
***************
*** 1051,1056 ****
--- 1057,1063 ----
function s:test_exit_callback(port)
call job_setoptions(s:job, {'exit-cb': 'MyExitCb'})
let s:exit_job = s:job
+ call assert_equal('MyExitCb', job_info(s:job)['exit-cb'])
endfunc
func Test_exit_callback()
***************
*** 1069,1074 ****
--- 1076,1082 ----
endfor
call assert_equal('done', s:job_exit_ret)
+ call assert_equal('dead', job_info(s:exit_job).status)
unlet s:exit_job
endif
endfunc
*** ../vim-7.4.1540/runtime/doc/eval.txt 2016-03-08 17:08:38.562223096
+0100
--- runtime/doc/eval.txt 2016-03-12 15:19:22.084708543 +0100
***************
*** 1956,1963 ****
--- 1966,1975 ----
invert( {expr}) Number bitwise invert
isdirectory( {directory}) Number TRUE if {directory} is a directory
islocked( {expr}) Number TRUE if {expr} is locked
+ isnan( {expr}) Number TRUE if {expr} is NaN
items( {dict}) List key-value pairs in {dict}
job_getchannel( {job}) Channel get the channel handle for {job}
+ job_info( {job}) Dict get information about {job}
job_setoptions( {job}, {options}) none set options for {job}
job_start( {command} [, {options}]) Job start a job
job_status( {job}) String get the status of {job}
***************
*** 4375,4386 ****
job_getchannel({job}) *job_getchannel()*
Get the channel handle that {job} is using.
{only available when compiled with the |+job| feature}
job_setoptions({job}, {options}) *job_setoptions()*
Change options for {job}. Supported are:
! "stoponexit" |job-stoponexit|
! "exit-cb" |job-exit-cb|
job_start({command} [, {options}]) *job_start()*
Start a job and return a Job object. Unlike |system()| and
--- 4469,4491 ----
job_getchannel({job}) *job_getchannel()*
Get the channel handle that {job} is using.
+ To check if the job has no channel: >
+ if string(job_getchannel()) == 'channel fail'
+ <
{only available when compiled with the |+job| feature}
+ job_info({job}) *job_info()*
+ Returns a Dictionary with information about {job}:
+ "status" what |job_status()| returns
+ "channel" what |job_getchannel()| returns
+ "exitval" only valid when "status" is "dead"
+ "exit-cb" function to be called on exit
+ "stoponexit" |job-stoponexit|
+
job_setoptions({job}, {options}) *job_setoptions()*
Change options for {job}. Supported are:
! "stoponexit" |job-stoponexit|
! "exit-cb" |job-exit-cb|
job_start({command} [, {options}]) *job_start()*
Start a job and return a Job object. Unlike |system()| and
***************
*** 4431,4436 ****
--- 4536,4543 ----
If an exit callback was set with the "exit-cb" option and the
job is now detected to be "dead" the callback will be invoked.
+ For more information see |job_info()|.
+
{only available when compiled with the |+job| feature}
job_stop({job} [, {how}]) *job_stop()*
*** ../vim-7.4.1540/src/version.c 2016-03-12 13:48:45.505207726 +0100
--- src/version.c 2016-03-12 15:21:04.363641498 +0100
***************
*** 745,746 ****
--- 745,748 ----
{ /* Add new patch number below this line */
+ /**/
+ 1541,
/**/
--
"So this is it," said Arthur, "we are going to die."
"Yes," said Ford, "except...no! Wait a minute!" He suddenly lunged across
the chamber at something behind Arthur's line of vision. "What's this
switch?" he cried.
"What? Where?" cried Arthur, twisting around.
"No, I was only fooling," said Ford, "we are going to die after all."
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.