header generator: fix bitsets in odin 5

This commit is contained in:
nakst 2022-02-13 21:17:16 +00:00
parent 8be749ce31
commit 7aad347fe5
1 changed files with 4 additions and 3 deletions

View File

@ -923,7 +923,7 @@ void OutputOdinFunction(Entry *entry, Entry *root) {
const char *initialValue = TrimPrefix(variable->variable.initialValue);
bool needLeadingDot = false;
const char *leadingTypeName = "";
bool needBraces = false;
if (0 == strcmp(initialValue, "NULL")) {
initialValue = "nil";
@ -947,8 +947,8 @@ void OutputOdinFunction(Entry *entry, Entry *root) {
if (entry->type == ENTRY_BITSET && 0 == strcmp(variable->variable.type, entry->name)) {
if (0 == memcmp(initialValue, entry->bitset.definePrefix + 3, strlen(entry->bitset.definePrefix) - 3)) {
needLeadingDot = true;
needBraces = true;
initialValue += strlen(entry->bitset.definePrefix) - 3;
leadingTypeName = TrimPrefix(entry->name);
}
break;
@ -956,7 +956,8 @@ void OutputOdinFunction(Entry *entry, Entry *root) {
}
}
FilePrintFormat(output, " = %s%c%s", leadingTypeName, needLeadingDot ? '.' : ' ', initialValue);
FilePrintFormat(output, " = %c%c%s%c", needBraces ? '{' : ' ',
needLeadingDot ? '.' : ' ', initialValue, needBraces ? '}' : ' ');
}
}