refactor(lua): rename nlua_call_typval

This commit is contained in:
Justin M. Keyes
2026-07-06 21:32:53 +02:00
parent b5f500263b
commit a6d7193f07
9 changed files with 12 additions and 12 deletions

View File

@@ -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`

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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"

View File

@@ -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++) {

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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.

View File

@@ -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);