diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-12-03 11:09:29 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-03 11:09:29 +0000 |
commit | 8658c759f05b317707d56e3b65a5ef63930c7498 (patch) | |
tree | 124fcda187b5515dfaeba4c86aa7a5e0f0888686 /src/userfunc.c | |
parent | 021ef351c2127cf8aa5668a881435a0a12774644 (diff) |
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'v8.2.3725
Problem: Cannot use a lambda for 'completefunc' and 'omnifunc'.
Solution: Implement lambda support. (Yegappan Lakshmanan, closes #9257)
Diffstat (limited to 'src/userfunc.c')
-rw-r--r-- | src/userfunc.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/userfunc.c b/src/userfunc.c index 3edbf891ef..18af66c6e7 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -3169,6 +3169,29 @@ call_callback( } /* + * 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. */ |