mirror of https://github.com/rusefi/rusefi-1.git
Refactoring, technical debt: export more of trigger attributes into triggers.txt file #2077
This commit is contained in:
parent
5e66e8cb21
commit
73ca428217
|
@ -40,7 +40,7 @@ public class EnumToStringTest {
|
||||||
"\tGPIO_UNASSIGNED = 0,\n" +
|
"\tGPIO_UNASSIGNED = 0,\n" +
|
||||||
"\tGPIO_INVALID = 1,\n" +
|
"\tGPIO_INVALID = 1,\n" +
|
||||||
"\tGPIO_HEX = 0xA1,\n" +
|
"\tGPIO_HEX = 0xA1,\n" +
|
||||||
"}brain_pin_e;"));
|
"}brain_pin_e; // hello"));
|
||||||
|
|
||||||
List<Value> values = new ArrayList<>(enumsReader.getEnums().get("brain_pin_e").values());
|
List<Value> values = new ArrayList<>(enumsReader.getEnums().get("brain_pin_e").values());
|
||||||
assertEquals(3, values.size());
|
assertEquals(3, values.size());
|
||||||
|
|
|
@ -12,6 +12,10 @@ public class EnumsReader {
|
||||||
|
|
||||||
private final Map<String, Map<String, Value>> enums = new TreeMap<>();
|
private final Map<String, Map<String, Value>> enums = new TreeMap<>();
|
||||||
|
|
||||||
|
public Map<String /*enum name*/, Map<String/*enum member*/, Value>> getEnums() {
|
||||||
|
return enums;
|
||||||
|
}
|
||||||
|
|
||||||
public void process(String path, String fileName) throws IOException {
|
public void process(String path, String fileName) throws IOException {
|
||||||
process(new FileReader(path + File.separator + fileName));
|
process(new FileReader(path + File.separator + fileName));
|
||||||
}
|
}
|
||||||
|
@ -23,6 +27,7 @@ public class EnumsReader {
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
line = removeSpaces(line);
|
line = removeSpaces(line);
|
||||||
|
|
||||||
|
line = line.replaceAll("//.+", "");
|
||||||
if (line.startsWith("typedefenum{") || line.startsWith("typedefenum__attribute__")) {
|
if (line.startsWith("typedefenum{") || line.startsWith("typedefenum__attribute__")) {
|
||||||
SystemOut.println(" EnumsReader: Entering enum");
|
SystemOut.println(" EnumsReader: Entering enum");
|
||||||
currentValues.clear();
|
currentValues.clear();
|
||||||
|
@ -33,7 +38,6 @@ public class EnumsReader {
|
||||||
SystemOut.println(" EnumsReader: Ending enum " + line + " found " + currentValues.size() + " values");
|
SystemOut.println(" EnumsReader: Ending enum " + line + " found " + currentValues.size() + " values");
|
||||||
enums.put(line, new TreeMap<>(currentValues));
|
enums.put(line, new TreeMap<>(currentValues));
|
||||||
} else {
|
} else {
|
||||||
line = line.replaceAll("//.+", "");
|
|
||||||
if (isInsideEnum) {
|
if (isInsideEnum) {
|
||||||
if (isKeyValueLine(line)) {
|
if (isKeyValueLine(line)) {
|
||||||
line = line.replace(",", "");
|
line = line.replace(",", "");
|
||||||
|
@ -53,11 +57,7 @@ public class EnumsReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Map<String, Value>> getEnums() {
|
private static String removeSpaces(String line) {
|
||||||
return enums;
|
|
||||||
}
|
|
||||||
|
|
||||||
static String removeSpaces(String line) {
|
|
||||||
return line.replaceAll("\\s+", "");
|
return line.replaceAll("\\s+", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue