0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'

Problem:    Cannot use a lambda for 'completefunc' and 'omnifunc'.
Solution:   Implement lambda support. (Yegappan Lakshmanan, closes #9257)
This commit is contained in:
Yegappan Lakshmanan
2021-12-03 11:09:29 +00:00
committed by Bram Moolenaar
parent 021ef351c2
commit 8658c759f0
14 changed files with 740 additions and 17 deletions

View File

@@ -3168,6 +3168,29 @@ call_callback(
return ret;
}
/*
* call the 'callback' function and return the result as a number.
* Returns -1 when calling the function fails. Uses argv[0] to argv[argc - 1]
* for the function arguments. argv[argc] should have type VAR_UNKNOWN.
*/
varnumber_T
call_callback_retnr(
callback_T *callback,
int argcount, // number of "argvars"
typval_T *argvars) // vars for arguments, must have "argcount"
// PLUS ONE elements!
{
typval_T rettv;
varnumber_T retval;
if (call_callback(callback, 0, &rettv, argcount, argvars) == FAIL)
return -1;
retval = tv_get_number_chk(&rettv, NULL);
clear_tv(&rettv);
return retval;
}
/*
* Give an error message for the result of a function.
* Nothing if "error" is FCERR_NONE.