diff --git a/runtime/doc/dev_arch.txt b/runtime/doc/dev_arch.txt index 68778dcdd9..8363e22d28 100644 --- a/runtime/doc/dev_arch.txt +++ b/runtime/doc/dev_arch.txt @@ -216,7 +216,7 @@ order of preference): a performance benefit: the Vimscript <=> Lua bridge is skipped when the `vim.fn.xx()` function is called from Lua. Examples: - `f_hostname` -2. Partial Lua: the C implementation calls `nlua_call_vimfn` or +2. Partial Lua: the C implementation calls `nlua_call_typval` or `nlua_call_excmd`. (Or in rare cases: `nlua_exec` / `NLUA_EXEC_STATIC`). Examples: - `ex_log` diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index dcd9122ac3..d8bf95105c 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -6373,7 +6373,7 @@ static void f_serverlist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) .vval.v_special = kSpecialVarNull }; typval_T lua_args[] = { opts, addrs_tv, { .v_type = VAR_UNKNOWN } }; - nlua_call_vimfn("vim._core.server", "serverlist", lua_args, rettv); + nlua_call_typval("vim._core.server", "serverlist", lua_args, rettv); tv_clear(&addrs_tv); } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index ccd0186ed0..04eb0ccbf5 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4587,7 +4587,7 @@ static void cmdwin_invoke(const char *action, int firstc, char *content, int pos { .v_type = VAR_NUMBER, .vval.v_number = pos + 1 }, { .v_type = VAR_UNKNOWN }, }; - nlua_call_vimfn("vim._core.cmdwin", action, firstc ? tv_args : tv_args + 3, NULL); + nlua_call_typval("vim._core.cmdwin", action, firstc ? tv_args : tv_args + 3, NULL); xfree(content); } diff --git a/src/nvim/help.c b/src/nvim/help.c index e728fac88a..546591ad13 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -108,7 +108,7 @@ void ex_help(exarg_T *eap) if (helpbang) { typval_T no_args[] = { { .v_type = VAR_UNKNOWN } }; typval_T rettv; - nlua_call_vimfn("vim._core.help", "resolve_tag", no_args, &rettv); + nlua_call_typval("vim._core.help", "resolve_tag", no_args, &rettv); if (rettv.v_type == VAR_STRING && rettv.vval.v_string != NULL && *rettv.vval.v_string != NUL) { allocated_arg = rettv.vval.v_string; // takes ownership arg = allocated_arg; @@ -339,7 +339,7 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep { .v_type = VAR_UNKNOWN }, }; typval_T rettv; - nlua_call_vimfn("vim._core.help", "escape_subject", tv_args, &rettv); + nlua_call_typval("vim._core.help", "escape_subject", tv_args, &rettv); if (rettv.v_type != VAR_STRING || rettv.vval.v_string == NULL) { tv_clear(&rettv); return FAIL; @@ -461,7 +461,7 @@ void prepare_help_buffer(void) void get_local_additions(void) { typval_T no_args[] = { { .v_type = VAR_UNKNOWN } }; - nlua_call_vimfn("vim._core.help", "local_additions", no_args, NULL); + nlua_call_typval("vim._core.help", "local_additions", no_args, NULL); } /// ":exusage" diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 1454baf59a..8a1487fe5a 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1667,7 +1667,7 @@ Object nlua_exec(const String str, const char *chunkname, const Array args, LuaR return nlua_call_pop_retval(lstate, mode, arena, top, err); } -/// Calls Lua to implement a "vimfn" ("f_xx"/"eval"/"builtin") function. +/// Calls a Lua function with typval args. /// /// Converts argvars directly to Lua values (no Object intermediate), calls the Lua function, and /// converts the result back to typval_T. @@ -1676,7 +1676,7 @@ Object nlua_exec(const String str, const char *chunkname, const Array args, LuaR /// @param func Function name in the module, e.g. "serverlist". /// @param argvars typval args (VAR_UNKNOWN-terminated). /// @param rettv Return value (caller must tv_clear), or NULL to discard. -void nlua_call_vimfn(const char *module, const char *func, typval_T *argvars, typval_T *rettv) +void nlua_call_typval(const char *module, const char *func, typval_T *argvars, typval_T *rettv) { int argcount = 0; for (typval_T *tv = argvars; tv->v_type != VAR_UNKNOWN; tv++) { diff --git a/src/nvim/main.c b/src/nvim/main.c index 39f986d86c..ae67da64d6 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -503,7 +503,7 @@ int main(int argc, char **argv) tv_list_alloc_ret(&items_tv, 0); recover_names(NULL, false, items_tv.vval.v_list); typval_T lua_args[] = { items_tv, { .v_type = VAR_UNKNOWN } }; - nlua_call_vimfn("vim._core.swapfile", "list_swaps", lua_args, NULL); + nlua_call_typval("vim._core.swapfile", "list_swaps", lua_args, NULL); tv_clear(&items_tv); os_exit(0); } diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 84d9d23323..28f8e4565c 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -803,7 +803,7 @@ void ml_recover(bool checkext) if (n_swaps > 1) { // Several swapfiles found: prompt (async) via vim.ui.select(). typval_T lua_args[] = { items_tv, { .v_type = VAR_UNKNOWN } }; - nlua_call_vimfn("vim._core.swapfile", "select_swap", lua_args, NULL); + nlua_call_typval("vim._core.swapfile", "select_swap", lua_args, NULL); tv_clear(&items_tv); goto theend; } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1e21114970..9ba80c88a8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6419,7 +6419,7 @@ static void nv_record(cmdarg_T *cap) { .v_type = VAR_STRING, .vval.v_string = fc }, { .v_type = VAR_UNKNOWN }, }; - nlua_call_vimfn("vim._core.cmdwin", "open", tv_args, NULL); + nlua_call_typval("vim._core.cmdwin", "open", tv_args, NULL); } else { // (stop) recording into a named register, unless executing a // register. diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index 7cf2e05810..34dd085891 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -479,7 +479,7 @@ static void select_spell_suggestion(suginfo_T *sug) typval_T bad_tv = { .v_type = VAR_STRING, .vval.v_string = xstrnsave(sug->su_badptr, (size_t)sug->su_badlen) }; typval_T lua_args[] = { items_tv, bad_tv, { .v_type = VAR_UNKNOWN } }; - nlua_call_vimfn("vim._core.spell", "select_suggest", lua_args, NULL); + nlua_call_typval("vim._core.spell", "select_suggest", lua_args, NULL); tv_clear(&items_tv); tv_clear(&bad_tv);