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