diff --git a/java_console/.idea/runConfigurations/Launcher_Auto.xml b/java_console/.idea/runConfigurations/Launcher_Auto.xml
index 574292fc6c..980b95f894 100644
--- a/java_console/.idea/runConfigurations/Launcher_Auto.xml
+++ b/java_console/.idea/runConfigurations/Launcher_Auto.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/java_tools/configuration_definition/src/com/rusefi/board_generator/BoardReader.java b/java_tools/configuration_definition/src/com/rusefi/board_generator/BoardReader.java
index 835ce8eb85..35452107e0 100644
--- a/java_tools/configuration_definition/src/com/rusefi/board_generator/BoardReader.java
+++ b/java_tools/configuration_definition/src/com/rusefi/board_generator/BoardReader.java
@@ -37,14 +37,14 @@ public class BoardReader {
);
return;
}
- String boardName = null;
String firmwarePath = "firmware";
String yamlInputFile = null;
String outputFileName = null;
+ EnumsReader enumsReader = new EnumsReader();
for (int i = 0; i < args.length - 1; i += 2) {
String key = args[i];
if (key.equals(KEY_BOARD_NAME)) {
- boardName = args[i + 1];
+ String boardName = args[i + 1];
yamlInputFile = firmwarePath + "/config/boards/" + boardName + "/" + MAPPING_YAML;
} else if (key.equals(OUTPUT_FILE_NAME)) {
outputFileName = args[i + 1];
@@ -54,7 +54,7 @@ public class BoardReader {
firmwarePath = args[i + 1];
} else if (key.equals(KEY_ENUM_INPUT_FILE)) {
String inputFile = args[i + 1];
- EnumsReader.process(new FileReader(firmwarePath + File.separator + inputFile));
+ enumsReader.process(new FileReader(firmwarePath + File.separator + inputFile));
}
}
@@ -67,25 +67,25 @@ public class BoardReader {
Output bw = new LazyFile(outputFileName);
- bw.write(processSection(data, "brain_pin_e", "output_pin_e", "outputs", "GPIO_UNASSIGNED"));
- bw.write(processSection(data, "adc_channel_e", "adc_channel_e", "analog_inputs", "EFI_ADC_NONE"));
+ bw.write(processSection(enumsReader, data, "brain_pin_e", "output_pin_e", "outputs", "GPIO_UNASSIGNED"));
+ bw.write(processSection(enumsReader, data, "adc_channel_e", "adc_channel_e", "analog_inputs", "EFI_ADC_NONE"));
- bw.write(processSection(data, "brain_pin_e", "brain_input_pin_e", "event_inputs", "GPIO_UNASSIGNED"));
- bw.write(processSection(data, "brain_pin_e", "switch_input_pin_e", "switch_inputs", "GPIO_UNASSIGNED"));
+ bw.write(processSection(enumsReader, data, "brain_pin_e", "brain_input_pin_e", "event_inputs", "GPIO_UNASSIGNED"));
+ bw.write(processSection(enumsReader, data, "brain_pin_e", "switch_input_pin_e", "switch_inputs", "GPIO_UNASSIGNED"));
bw.close();
}
SystemOut.close();
}
- private static String processSection(Map data, String headerEnumName, String outputEnumName, String sectionName, String NOTHING_NAME) {
+ private static String processSection(EnumsReader enumsReader, Map data, String headerEnumName, String outputEnumName, String sectionName, String NOTHING_NAME) {
Objects.requireNonNull(data, "data");
Map outputs = (Map) data.get(sectionName);
if (outputs == null)
return "";
Objects.requireNonNull(data, "enums");
- Map enumMap = EnumsReader.enums.get(headerEnumName);
+ Map enumMap = enumsReader.getEnums().get(headerEnumName);
Objects.requireNonNull(enumMap, "enum for " + headerEnumName);
SystemOut.println(enumMap.size());
diff --git a/java_tools/enum_to_string/src/com/rusefi/EnumToString.java b/java_tools/enum_to_string/src/com/rusefi/EnumToString.java
index 446c86a4f6..0dd77f29ed 100644
--- a/java_tools/enum_to_string/src/com/rusefi/EnumToString.java
+++ b/java_tools/enum_to_string/src/com/rusefi/EnumToString.java
@@ -26,29 +26,29 @@ public class EnumToString {
private final static StringBuilder headerFileContent = new StringBuilder();
- private final static String KEY_INPUT_PATH = "-inputPath";
+ private final static String KEY_INPUT_PATH = "-enumInputPath";
private final static String KEY_ENUM_INPUT_FILE = "-enumInputFile";
private final static String KEY_OUTPUT = "-outputPath";
public static void main(String[] args) throws IOException {
if (args.length < 4) {
SystemOut.println("Please specify at least\n\n" +
- KEY_INPUT_PATH + "XXX\n" +
-// KEY_INPUT_FILE + "XXX" +
+ KEY_ENUM_INPUT_FILE + "XXX\n" +
KEY_OUTPUT + "XXX\n"
);
return;
}
- String inputPath = null;
+ String inputPath = ".";
String outputPath = null;
+ EnumsReader enumsReader = new EnumsReader();
for (int i = 0; i < args.length - 1; i += 2) {
String key = args[i];
if (key.equals(KEY_INPUT_PATH)) {
inputPath = args[i + 1];
} else if (key.equals(KEY_ENUM_INPUT_FILE)) {
- String inputFile = args[i + 1];
- consumeFile(inputPath, inputFile);
+ String headerInputFile = args[i + 1];
+ consumeFile(enumsReader, inputPath, headerInputFile);
} else if (key.equals(KEY_OUTPUT)) {
outputPath = args[i + 1];
}
@@ -57,7 +57,7 @@ public class EnumToString {
headerFileContent.append("#pragma once\n");
- outputData();
+ outputData(enumsReader);
cppFileContent.insert(0, bothFilesHeader.toString());
@@ -84,21 +84,21 @@ public class EnumToString {
bw.close();
}
- private static void consumeFile(String inputPath, String inFileName) throws IOException {
- File f = new File(inputPath + File.separator + inFileName);
- SystemOut.println("Reading enums from " + inFileName);
+ private static void consumeFile(EnumsReader enumsReader, String inputPath, String headerInputFileName) throws IOException {
+ File f = new File(inputPath + File.separator + headerInputFileName);
+ SystemOut.println("Reading enums from " + headerInputFileName);
String simpleFileName = f.getName();
bothFilesHeader.insert(0, "// " + LazyFile.LAZY_FILE_TAG + " from " + simpleFileName + " ");
includesSection.append("#include \"" + simpleFileName + "\"\n");
- EnumsReader.process(new FileReader(f));
+ enumsReader.process(new FileReader(f));
}
- public static void outputData() {
- SystemOut.println("Preparing output for " + EnumsReader.enums.size() + " enums\n");
+ public static void outputData(EnumsReader enumsReader) {
+ SystemOut.println("Preparing output for " + enumsReader.getEnums().size() + " enums\n");
- for (Map.Entry> e : EnumsReader.enums.entrySet()) {
+ for (Map.Entry> e : enumsReader.getEnums().entrySet()) {
String enumName = e.getKey();
cppFileContent.append(makeCode(enumName, e.getValue().values()));
headerFileContent.append(getMethodSignature(enumName) + ";\n");
diff --git a/java_tools/enum_to_string/src/com/rusefi/EnumToStringTest.java b/java_tools/enum_to_string/src/com/rusefi/EnumToStringTest.java
index e0074362fe..aa05f92284 100644
--- a/java_tools/enum_to_string/src/com/rusefi/EnumToStringTest.java
+++ b/java_tools/enum_to_string/src/com/rusefi/EnumToStringTest.java
@@ -14,9 +14,11 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class EnumToStringTest {
- public static void process(Reader reader) throws IOException {
- EnumsReader.process(reader);
- EnumToString.outputData();
+ public static EnumsReader process(Reader reader) throws IOException {
+ EnumsReader enumsReader = new EnumsReader();
+ enumsReader.process(reader);
+ EnumToString.outputData(enumsReader);
+ return enumsReader;
}
@Test
@@ -33,14 +35,14 @@ public class EnumToStringTest {
@Test
public void parseEnum() throws IOException {
EnumToString.clear();
- process(new StringReader(
+ EnumsReader enumsReader = process(new StringReader(
"typedef enum {\n" +
"\tGPIO_UNASSIGNED = 0,\n" +
"\tGPIO_INVALID = 1,\n" +
"\tGPIO_HEX = 0xA1,\n" +
"}brain_pin_e;"));
- List values = new ArrayList<>(EnumsReader.enums.get("brain_pin_e").values());
+ List values = new ArrayList<>(enumsReader.getEnums().get("brain_pin_e").values());
assertEquals(3, values.size());
Value first = values.get(0);
assertEquals("GPIO_HEX", first.getName());
diff --git a/java_tools/enum_to_string/src/com/rusefi/EnumsReader.java b/java_tools/enum_to_string/src/com/rusefi/EnumsReader.java
index 52826f2f2a..ca90f3de6e 100644
--- a/java_tools/enum_to_string/src/com/rusefi/EnumsReader.java
+++ b/java_tools/enum_to_string/src/com/rusefi/EnumsReader.java
@@ -10,11 +10,11 @@ import java.util.Map;
import java.util.TreeMap;
public class EnumsReader {
- private final static Map currentValues = new TreeMap<>();
+ private final Map currentValues = new TreeMap<>();
- public final static Map> enums = new TreeMap<>();
+ private final Map> enums = new TreeMap<>();
- public static void process(Reader in) throws IOException {
+ public void process(Reader in) throws IOException {
boolean isInsideEnum = false;
BufferedReader reader = new BufferedReader(in);
String line;
@@ -51,6 +51,10 @@ public class EnumsReader {
}
}
+ public Map> getEnums() {
+ return enums;
+ }
+
static String removeSpaces(String line) {
return line.replaceAll("\\s+", "");
}