diff options
author | bfredl <bjorn.linse@gmail.com> | 2024-02-12 20:40:27 +0100 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2024-02-15 10:42:06 +0100 |
commit | d60412b18e4e21f301baa2ac3f3fb7be89655e4b (patch) | |
tree | 2459531b83b937b6678ee7141badc27d0a331c29 /src/nvim/api/window.c | |
parent | 0a51e7626a95a068c7bb00d0da28a701fed758da (diff) | |
download | rneovim-d60412b18e4e21f301baa2ac3f3fb7be89655e4b.tar.gz rneovim-d60412b18e4e21f301baa2ac3f3fb7be89655e4b.tar.bz2 rneovim-d60412b18e4e21f301baa2ac3f3fb7be89655e4b.zip |
refactor(eval): use arena when converting typvals to Object
Note: this contains two _temporary_ changes which can be reverted
once the Arena vs no-Arena distinction in API wrappers has been removed.
Both nlua_push_Object and object_to_vim_take_luaref() has been changed
to take the object argument as a pointer. This is not going to be
necessary once these are only used with arena (or not at all) allocated
Objects.
The object_to_vim() variant which leaves luaref untouched might need to
stay for a little longer.
Diffstat (limited to 'src/nvim/api/window.c')
-rw-r--r-- | src/nvim/api/window.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 93c9dfa049..ed1ad5b583 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -237,7 +237,7 @@ void nvim_win_set_width(Window window, Integer width, Error *err) /// @param name Variable name /// @param[out] err Error details, if any /// @return Variable value -Object nvim_win_get_var(Window window, String name, Error *err) +Object nvim_win_get_var(Window window, String name, Arena *arena, Error *err) FUNC_API_SINCE(1) { win_T *win = find_window_by_handle(window, err); @@ -246,7 +246,7 @@ Object nvim_win_get_var(Window window, String name, Error *err) return (Object)OBJECT_INIT; } - return dict_get_value(win->w_vars, name, err); + return dict_get_value(win->w_vars, name, arena, err); } /// Sets a window-scoped (w:) variable @@ -264,7 +264,7 @@ void nvim_win_set_var(Window window, String name, Object value, Error *err) return; } - dict_set_var(win->w_vars, name, value, false, false, err); + dict_set_var(win->w_vars, name, value, false, false, NULL, err); } /// Removes a window-scoped (w:) variable @@ -281,7 +281,7 @@ void nvim_win_del_var(Window window, String name, Error *err) return; } - dict_set_var(win->w_vars, name, NIL, true, false, err); + dict_set_var(win->w_vars, name, NIL, true, false, NULL, err); } /// Gets the window position in display cells. First position is zero. @@ -289,15 +289,16 @@ void nvim_win_del_var(Window window, String name, Error *err) /// @param window Window handle, or 0 for current window /// @param[out] err Error details, if any /// @return (row, col) tuple with the window position -ArrayOf(Integer, 2) nvim_win_get_position(Window window, Error *err) +ArrayOf(Integer, 2) nvim_win_get_position(Window window, Arena *arena, Error *err) FUNC_API_SINCE(1) { Array rv = ARRAY_DICT_INIT; win_T *win = find_window_by_handle(window, err); if (win) { - ADD(rv, INTEGER_OBJ(win->w_winrow)); - ADD(rv, INTEGER_OBJ(win->w_wincol)); + rv = arena_array(arena, 2); + ADD_C(rv, INTEGER_OBJ(win->w_winrow)); + ADD_C(rv, INTEGER_OBJ(win->w_wincol)); } return rv; |