libcmo21/CodeGen/EnumsMigration/ErrorsWriter.java

27 lines
782 B
Java
Raw Normal View History

2023-08-20 16:10:22 +08:00
import java.io.OutputStreamWriter;
2023-08-20 12:13:40 +08:00
/**
2023-08-20 21:38:16 +08:00
* The nameof values writer for CKERROR
2023-08-20 12:13:40 +08:00
*/
public class ErrorsWriter {
2023-10-10 10:39:27 +08:00
public static void writeAccVal(String filename, EnumsHelper.Enum_t errors) throws Exception {
OutputStreamWriter writer = CommonHelper.openOutputFile(filename);
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.CPP);
2023-08-20 16:10:22 +08:00
indent.puts("const CkErrorReflectionArray CKERROR {");
indent.inc();
for (EnumsHelper.EnumEntry_t entry : errors.mEntries) {
String comment = CommonHelper.escapeString(entry.mEntryComment);
if (comment == null)
comment = "";
indent.printf("{ LibCmo::CK2::CKERROR::%s, { \"%s\", \"%s\" } },", entry.mEntryName, entry.mEntryName,
comment);
}
indent.dec();
indent.puts("};");
2023-10-10 10:39:27 +08:00
writer.close();
2023-08-20 16:10:22 +08:00
}
2023-08-20 12:13:40 +08:00
}