use 'sufficient suffixes' when generating enum expansions

This commit is contained in:
Ryan Fleury
2025-05-07 15:24:23 -07:00
parent 1929bcac0a
commit e7a4f407bb
3 changed files with 10 additions and 43 deletions
+10 -1
View File
@@ -2202,7 +2202,16 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(default)
{
U64 member_idx = idx + read_range.min;
String8 member_name = type->enum_vals[member_idx].name;
evals_out[idx] = e_eval_wrapf(eval, "$.%S", member_name);
String8 sufficient_suffix = member_name;
if(str8_match(sufficient_suffix, type->name, StringMatchFlag_RightSideSloppy))
{
sufficient_suffix = str8_skip(sufficient_suffix, type->name.size);
if(str8_match(sufficient_suffix, str8_lit("_"), StringMatchFlag_RightSideSloppy))
{
sufficient_suffix = str8_skip(sufficient_suffix, 1);
}
}
evals_out[idx] = e_eval_wrapf(eval, "$.%S", sufficient_suffix);
}
}