From cfd4fdfea4d0e68ea50ad412b88b5289ded6fd6f Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Tue, 23 May 2023 14:25:10 +0600 Subject: refactor(api): new helper macros Adds new API helper macros `CSTR_AS_OBJ()`, `STATIC_CSTR_AS_OBJ()`, and `STATIC_CSTR_TO_OBJ()`, which cleans up a lot of the current code. These macros will also be used extensively in the upcoming option refactor PRs because then API Objects will be used to get/set options. This PR also modifies pre-existing code to use old API helper macros like `CSTR_TO_OBJ()` to make them cleaner. --- src/nvim/api/win_config.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/api/win_config.c') diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index c267fee39a..8e4fbb6779 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -267,7 +267,7 @@ Dictionary nvim_win_get_config(Window window, Error *err) PUT(rv, "bufpos", ARRAY_OBJ(pos)); } } - PUT(rv, "anchor", STRING_OBJ(cstr_to_string(float_anchor_str[config->anchor]))); + PUT(rv, "anchor", CSTR_TO_OBJ(float_anchor_str[config->anchor])); PUT(rv, "row", FLOAT_OBJ(config->row)); PUT(rv, "col", FLOAT_OBJ(config->col)); PUT(rv, "zindex", INTEGER_OBJ(config->zindex)); @@ -283,7 +283,7 @@ Dictionary nvim_win_get_config(Window window, Error *err) char *hi_name = syn_id2name(hi_id); if (hi_name[0]) { ADD(tuple, STRING_OBJ(s)); - ADD(tuple, STRING_OBJ(cstr_to_string(hi_name))); + ADD(tuple, CSTR_TO_OBJ(hi_name)); ADD(border, ARRAY_OBJ(tuple)); } else { ADD(border, STRING_OBJ(s)); @@ -297,7 +297,7 @@ Dictionary nvim_win_get_config(Window window, Error *err) Array tuple = ARRAY_DICT_INIT; ADD(tuple, CSTR_TO_OBJ(title_datas.items[i].text)); if (title_datas.items[i].hl_id > 0) { - ADD(tuple, STRING_OBJ(cstr_to_string(syn_id2name(title_datas.items[i].hl_id)))); + ADD(tuple, CSTR_TO_OBJ(syn_id2name(title_datas.items[i].hl_id))); } ADD(titles, ARRAY_OBJ(tuple)); } @@ -317,7 +317,7 @@ Dictionary nvim_win_get_config(Window window, Error *err) const char *rel = (wp->w_floating && !config->external ? float_relative_str[config->relative] : ""); - PUT(rv, "relative", STRING_OBJ(cstr_to_string(rel))); + PUT(rv, "relative", CSTR_TO_OBJ(rel)); return rv; } -- cgit