libcmo21/CodeGen/ClassidWriter.java

29 lines
1.0 KiB
Java
Raw Normal View History

2023-08-20 16:10:22 +08:00
import java.io.OutputStreamWriter;
import java.util.stream.Collectors;
2023-08-20 12:13:40 +08:00
/**
2023-08-20 21:38:16 +08:00
* The nameof values writer for CK_CLASSID.
2023-08-20 12:13:40 +08:00
*/
public class ClassidWriter {
2023-08-20 21:38:16 +08:00
public static void writeNameofClassid(OutputStreamWriter writer, EnumsHelper.Enum_t classids) throws Exception {
2023-08-20 16:10:22 +08:00
IndentHelper indent = new IndentHelper(writer);
indent.puts("struct CkClassidReflection { std::vector<const char*> mHierarchy; };");
2023-08-20 21:38:16 +08:00
indent.puts(
"using CkClassidReflectionArray = std::vector<std::pair<LibCmo::CK2::CK_CLASSID, CkClassidReflection>>;");
indent.puts("");
2023-08-20 16:10:22 +08:00
indent.puts("const CkClassidReflectionArray CK_CLASSID {");
indent.inc();
for (EnumsHelper.EnumEntry_t entry : classids.mEntries) {
2023-08-20 21:38:16 +08:00
EnumsHelper.EnumEntryWithHierarchy_t specialized = (EnumsHelper.EnumEntryWithHierarchy_t) entry;
String hierarchy = specialized.mHierarchy.stream().map(value -> value.mEntryName)
.collect(Collectors.joining("\", \""));
2023-08-20 16:10:22 +08:00
indent.printf("{ LibCmo::CK2::CK_CLASSID::%s, { { \"%s\" } } },", entry.mEntryName, hierarchy);
}
indent.dec();
indent.puts("};");
}
2023-08-20 12:13:40 +08:00
}