diff options
author | bfredl <bjorn.linse@gmail.com> | 2024-02-11 15:46:14 +0100 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2024-02-13 11:54:44 +0100 |
commit | 0353dd3029f9ce31c3894530385443a90f6677ee (patch) | |
tree | fa288427461ee2c1ce1c271d01a760977a161bf5 /src/nvim/main.c | |
parent | 89135cff030b06f60cd596a9ae81cd9583987517 (diff) | |
download | rneovim-0353dd3029f9ce31c3894530385443a90f6677ee.tar.gz rneovim-0353dd3029f9ce31c3894530385443a90f6677ee.tar.bz2 rneovim-0353dd3029f9ce31c3894530385443a90f6677ee.zip |
refactor(lua): use Arena when converting from lua stack to API args
and for return value of nlua_exec/nlua_call_ref, as this uses
the same family of functions.
NB: the handling of luaref:s is a bit of a mess.
add api_luarefs_free_XX functions as a stop-gap as refactoring
luarefs is a can of worms for another PR:s.
as a minor feature/bug-fix, nvim_buf_call and nvim_win_call now preserves
arbitrary return values.
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r-- | src/nvim/main.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index f2893dc9e3..d712a45b81 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -940,20 +940,20 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr, } Array args = ARRAY_DICT_INIT; + kv_resize(args, (size_t)(argc - remote_args)); for (int t_argc = remote_args; t_argc < argc; t_argc++) { - String arg_s = cstr_to_string(argv[t_argc]); - ADD(args, STRING_OBJ(arg_s)); + ADD_C(args, CSTR_AS_OBJ(argv[t_argc])); } Error err = ERROR_INIT; - Array a = ARRAY_DICT_INIT; + MAXSIZE_TEMP_ARRAY(a, 4); ADD(a, INTEGER_OBJ((int)chan)); - ADD(a, CSTR_TO_OBJ(server_addr)); - ADD(a, CSTR_TO_OBJ(connect_error)); + ADD(a, CSTR_AS_OBJ(server_addr)); + ADD(a, CSTR_AS_OBJ(connect_error)); ADD(a, ARRAY_OBJ(args)); String s = STATIC_CSTR_AS_STRING("return vim._cs_remote(...)"); - Object o = nlua_exec(s, a, &err); - api_free_array(a); + Object o = nlua_exec(s, a, kRetObject, NULL, &err); + kv_destroy(args); if (ERROR_SET(&err)) { fprintf(stderr, "%s\n", err.msg); os_exit(2); @@ -2085,7 +2085,7 @@ static void do_exrc_initialization(void) str = nlua_read_secure(VIMRC_LUA_FILE); if (str != NULL) { Error err = ERROR_INIT; - nlua_exec(cstr_as_string(str), (Array)ARRAY_DICT_INIT, &err); + nlua_exec(cstr_as_string(str), (Array)ARRAY_DICT_INIT, kRetNilBool, NULL, &err); xfree(str); if (ERROR_SET(&err)) { semsg("Error detected while processing %s:", VIMRC_LUA_FILE); |