scope enums

This commit is contained in:
Ramen2X 2024-03-09 20:43:58 -05:00
parent da386b765e
commit 0aacb74ca3

View file

@ -94,11 +94,15 @@ bool HeaderGenerator::WriteHeader(char *p_interleafName, std::map<size_t, std::s
// insert include guard
m_fout << guardBuffer << "\n\n";
// we need to scope this enum to avoid conflicts
m_fout << "class " << m_normalizedInlfName << "Script {\n";
m_fout << "public:\n";
// declare enum
m_fout << "enum " << m_normalizedInlfName << "Script {\n";
m_fout << " enum Script {\n";
// add generic "none" state to the enum
m_fout << " c_none" << m_normalizedInlfName << " = -1,\n\n";
m_fout << " c_none" << m_normalizedInlfName << " = -1,\n\n";
// iterate through the action map and insert each action into enum
bool isLast = false;
@ -113,7 +117,7 @@ bool HeaderGenerator::WriteHeader(char *p_interleafName, std::map<size_t, std::s
}
// actually write the enum entry
m_fout << " " << g_enumEntryPrefix << it->second << " = " << it->first;
m_fout << " " << g_enumEntryPrefix << it->second << " = " << it->first;
if (!isLast) {
// if there are still more entries, we need write a comma
m_fout << ",";
@ -123,8 +127,8 @@ bool HeaderGenerator::WriteHeader(char *p_interleafName, std::map<size_t, std::s
i++;
}
// all done with actions, so lets close the enum
m_fout << "};\n\n";
// all done with actions, so lets close the enum and class
m_fout << " };\n};\n\n";
// finally, close the include guard
m_fout << "#endif // " << guardName << "\n";