refactor(api): make cstr_as_string accept "const char*"

In the context a String inside an Object/Dictionary etc is consumed,
it is considered to be read-only.
This commit is contained in:
bfredl
2024-02-09 11:42:40 +01:00
parent 4788abf2da
commit e0e5b7f0ba
16 changed files with 29 additions and 30 deletions

View File

@@ -977,12 +977,12 @@ void decor_to_dict_legacy(Dictionary *dict, DecorInline decor, bool hl_name, Are
}
if (sh_hl.url != NULL) {
PUT_C(*dict, "url", STRING_OBJ(cstr_as_string((char *)sh_hl.url)));
PUT_C(*dict, "url", STRING_OBJ(cstr_as_string(sh_hl.url)));
}
if (virt_text) {
if (virt_text->hl_mode) {
PUT_C(*dict, "hl_mode", CSTR_AS_OBJ((char *)hl_mode_str[virt_text->hl_mode]));
PUT_C(*dict, "hl_mode", CSTR_AS_OBJ(hl_mode_str[virt_text->hl_mode]));
}
Array chunks = virt_text_to_array(virt_text->data.virt_text, hl_name, arena);
@@ -992,7 +992,7 @@ void decor_to_dict_legacy(Dictionary *dict, DecorInline decor, bool hl_name, Are
if (virt_text->pos == kVPosWinCol) {
PUT_C(*dict, "virt_text_win_col", INTEGER_OBJ(virt_text->col));
}
PUT_C(*dict, "virt_text_pos", CSTR_AS_OBJ((char *)virt_text_pos_str[virt_text->pos]));
PUT_C(*dict, "virt_text_pos", CSTR_AS_OBJ(virt_text_pos_str[virt_text->pos]));
priority = virt_text->priority;
}