mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 22:36:09 +00:00
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.
This commit is contained in:
@@ -207,7 +207,7 @@ int ns_get_hl(NS *ns_hl, int hl_id, bool link, bool nodefault)
|
||||
if (!valid_item && p->hl_def != LUA_NOREF && !recursive) {
|
||||
MAXSIZE_TEMP_ARRAY(args, 3);
|
||||
ADD_C(args, INTEGER_OBJ((Integer)ns_id));
|
||||
ADD_C(args, STRING_OBJ(cstr_to_string(syn_id2name(hl_id))));
|
||||
ADD_C(args, CSTR_TO_OBJ(syn_id2name(hl_id)));
|
||||
ADD_C(args, BOOLEAN_OBJ(link));
|
||||
// TODO(bfredl): preload the "global" attr dict?
|
||||
|
||||
@@ -1141,21 +1141,21 @@ static void hl_inspect_impl(Array *arr, int attr)
|
||||
HlEntry e = kv_A(attr_entries, attr);
|
||||
switch (e.kind) {
|
||||
case kHlSyntax:
|
||||
PUT(item, "kind", STRING_OBJ(cstr_to_string("syntax")));
|
||||
PUT(item, "kind", CSTR_TO_OBJ("syntax"));
|
||||
PUT(item, "hi_name",
|
||||
STRING_OBJ(cstr_to_string(syn_id2name(e.id1))));
|
||||
CSTR_TO_OBJ(syn_id2name(e.id1)));
|
||||
break;
|
||||
|
||||
case kHlUI:
|
||||
PUT(item, "kind", STRING_OBJ(cstr_to_string("ui")));
|
||||
PUT(item, "kind", CSTR_TO_OBJ("ui"));
|
||||
const char *ui_name = (e.id1 == -1) ? "Normal" : hlf_names[e.id1];
|
||||
PUT(item, "ui_name", STRING_OBJ(cstr_to_string(ui_name)));
|
||||
PUT(item, "ui_name", CSTR_TO_OBJ(ui_name));
|
||||
PUT(item, "hi_name",
|
||||
STRING_OBJ(cstr_to_string(syn_id2name(e.id2))));
|
||||
CSTR_TO_OBJ(syn_id2name(e.id2)));
|
||||
break;
|
||||
|
||||
case kHlTerminal:
|
||||
PUT(item, "kind", STRING_OBJ(cstr_to_string("term")));
|
||||
PUT(item, "kind", CSTR_TO_OBJ("term"));
|
||||
break;
|
||||
|
||||
case kHlCombine:
|
||||
|
Reference in New Issue
Block a user