EOL for generated files

This commit is contained in:
rusefi 2017-03-27 22:24:52 -04:00
parent d67e66f732
commit 4270b11209
5 changed files with 28 additions and 24 deletions

Binary file not shown.

View File

@ -68,7 +68,7 @@ public class ConfigDefinition {
javaFields.write("public class Fields {" + EOL);
javaFields.write(VariableRegistry.INSTANCE.getJavaConstants());
javaFields.write(javaFieldsWriter.toString());
javaFields.write("}\r\n");
javaFields.write("}" + EOL);
javaFields.close();
@ -181,9 +181,9 @@ public class ConfigDefinition {
private static void processFile(BufferedReader br, BufferedWriter cHeader, Writer tsHeader, CharArrayWriter javaFieldsWriter) throws IOException {
String line;
String message = "// this section " + MESSAGE + "\r\n";
String message = "// this section " + MESSAGE + EOL;
cHeader.write(message);
cHeader.write("// begin\r\n");
cHeader.write("// begin" + EOL);
cHeader.write("#ifndef ENGINE_CONFIGURATION_GENERATED_H_" + EOL);
cHeader.write("#define ENGINE_CONFIGURATION_GENERATED_H_" + EOL);
cHeader.write("#include \"rusefi_types.h\"" + EOL);
@ -243,8 +243,8 @@ public class ConfigDefinition {
processLine(line);
}
}
cHeader.write("#endif\r\n");
cHeader.write("// end\r\n");
cHeader.write("#endif" + EOL);
cHeader.write("// end" + EOL);
cHeader.write(message);
}
@ -281,7 +281,7 @@ public class ConfigDefinition {
if (stack.isEmpty()) {
totalTsSize = structure.writeTunerStudio("", tsHeader, 0);
tsHeader.write("; total TS size = " + totalTsSize + "\r\n");
tsHeader.write("; total TS size = " + totalTsSize + EOL);
VariableRegistry.INSTANCE.register("TOTAL_CONFIG_SIZE", totalTsSize);
structure.writeJavaFields("", javaFieldsWriter, 0);
@ -319,7 +319,7 @@ public class ConfigDefinition {
}
public static String getComment(String comment, int currentOffset) {
return "\t/**\r\n" + packComment(comment, "\t") + "\t * offset " + currentOffset + "\r\n\t */\r\n";
return "\t/**" + EOL + packComment(comment, "\t") + "\t * offset " + currentOffset + EOL + "\t */" + EOL;
}
public static String packComment(String comment, String linePrefix) {
@ -329,7 +329,7 @@ public class ConfigDefinition {
return "";
String result = "";
for (String line : comment.split("\\\\n")) {
result += linePrefix + " * " + line + "\r\n";
result += linePrefix + " * " + line + EOL;
}
return result;
}

View File

@ -9,6 +9,8 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.rusefi.ConfigDefinition.EOL;
/**
* This is an immutable model of an individual field
* (c) Andrey Belomutskiy
@ -105,17 +107,17 @@ public class ConfigField {
String getHeaderText(int currentOffset, int bitIndex) {
if (isBit) {
String comment = "\t/**\r\n" + ConfigDefinition.packComment(getCommentContent(), "\t") + "\toffset " + currentOffset + " bit " + bitIndex + " */\r\n";
return comment + "\t" + BOOLEAN_TYPE + " " + name + " : 1;\r\n";
String comment = "\t/**" + EOL + ConfigDefinition.packComment(getCommentContent(), "\t") + "\toffset " + currentOffset + " bit " + bitIndex + " */" + EOL;
return comment + "\t" + BOOLEAN_TYPE + " " + name + " : 1;" + EOL;
}
String cEntry = ConfigDefinition.getComment(getCommentContent(), currentOffset);
if (arraySize == 1) {
// not an array
cEntry += "\t" + type + " " + name + ";\r\n";
cEntry += "\t" + type + " " + name + ";" + EOL;
} else {
cEntry += "\t" + type + " " + name + "[" + arraySizeAsText + "];\n";
cEntry += "\t" + type + " " + name + "[" + arraySizeAsText + "];" + EOL;
}
return cEntry;
}
@ -147,7 +149,7 @@ public class ConfigField {
tsHeader.write("\t" + tsPosition + ", [");
tsHeader.write(bitIndex + ":" + bitIndex);
tsHeader.write("], \"false\", \"true\"");
tsHeader.write("\r\n");
tsHeader.write(EOL);
tsPosition += getSize(next);
return tsPosition;
@ -181,7 +183,7 @@ public class ConfigField {
tsHeader.write("\t" + tsInfo);
tsPosition += arraySize * elementSize;
}
tsHeader.write("\r\n");
tsHeader.write(EOL);
return tsPosition;
}
@ -205,12 +207,12 @@ public class ConfigField {
String nameWithPrefix = prefix + name;
if (comment != null && comment.startsWith(TS_COMMENT_TAG + "")) {
ConfigDefinition.settingContextHelp.append("\t" + nameWithPrefix + " = \"" + getCommentContent() + "\"\r\n");
ConfigDefinition.settingContextHelp.append("\t" + nameWithPrefix + " = \"" + getCommentContent() + "\"" + EOL);
}
if (isBit) {
writeJavaFieldName(javaFieldsWriter, nameWithPrefix, tsPosition);
javaFieldsWriter.append("FieldType.BIT, " + bitIndex + ");\r\n");
javaFieldsWriter.append("FieldType.BIT, " + bitIndex + ");" + EOL);
tsPosition += getSize(next);
return tsPosition;
}
@ -220,13 +222,13 @@ public class ConfigField {
// todo: array support
} else if (TypesHelper.isFloat(type)) {
writeJavaFieldName(javaFieldsWriter, nameWithPrefix, tsPosition);
javaFieldsWriter.write("FieldType.FLOAT);\r\n");
javaFieldsWriter.write("FieldType.FLOAT);" + EOL);
} else {
String enumOptions = VariableRegistry.INSTANCE.get(type + "_enum");
if (enumOptions != null && !javaEnums.contains(type)) {
javaEnums.add(type);
javaFieldsWriter.write("\tpublic static final String[] " + type + " = {" + enumOptions + "};\r\n");
javaFieldsWriter.write("\tpublic static final String[] " + type + " = {" + enumOptions + "};" + EOL);
}
writeJavaFieldName(javaFieldsWriter, nameWithPrefix, tsPosition);
@ -234,7 +236,7 @@ public class ConfigField {
if (enumOptions != null) {
javaFieldsWriter.write(", " + type);
}
javaFieldsWriter.write(");\r\n");
javaFieldsWriter.write(");" + EOL);
}
tsPosition += arraySize * elementSize;

View File

@ -10,6 +10,8 @@ import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.rusefi.ConfigDefinition.EOL;
/**
* 3/30/2015
*/
@ -47,7 +49,7 @@ public class VariableRegistry extends TreeMap<String, String> {
System.out.println("Registering " + var + " as " + value);
put(var, value);
cAllDefinitions.append("#define " + var + " " + value + "\r\n");
cAllDefinitions.append("#define " + var + " " + value + EOL);
tryToRegisterAsInteger(var, value);
}
@ -59,7 +61,7 @@ public class VariableRegistry extends TreeMap<String, String> {
if (intValues.containsKey(var))
throw new IllegalStateException("Not allowed to redefine: " + var);
intValues.put(var, intValue);
javaNumbericDefinitions.append("\tpublic static final int " + var + " = " + intValue + ";" + ConfigDefinition.EOL);
javaNumbericDefinitions.append("\tpublic static final int " + var + " = " + intValue + ";" + EOL);
} catch (NumberFormatException e) {
System.out.println("Not an integer: " + value);
}

View File

@ -16,9 +16,9 @@ public class ConfigDefinitionTest {
@Test
public void testComment() {
assertEquals("", ConfigDefinition.packComment("", "\t"));
assertEquals("\t * abc\r\n", ConfigDefinition.packComment("abc", "\t"));
assertEquals("\t * abc\r\n" +
"\t * vbn\r\n", ConfigDefinition.packComment("abc\\nvbn", "\t"));
assertEquals("\t * abc\n", ConfigDefinition.packComment("abc", "\t"));
assertEquals("\t * abc\n" +
"\t * vbn\n", ConfigDefinition.packComment("abc\\nvbn", "\t"));
}
@Test