enum reader progress
This commit is contained in:
parent
6bbabbf1fe
commit
abadef0e96
Binary file not shown.
|
@ -476,7 +476,7 @@ public class ConfigDefinition {
|
|||
}
|
||||
PinType listPinType = PinType.find((String) listPins.get(i).get("class"));
|
||||
String pinType = listPinType.getPinType();
|
||||
Map<String, Value> enumList = state.enumsReader.getEnums().get(pinType);
|
||||
EnumsReader.EnumState enumList = state.enumsReader.getEnums().get(pinType);
|
||||
for (Map.Entry<String, Value> kv : enumList.entrySet()) {
|
||||
if (kv.getKey().equals(id)) {
|
||||
int index = kv.getValue().getIntValue();
|
||||
|
@ -494,7 +494,7 @@ public class ConfigDefinition {
|
|||
String outputEnumName = namePinType.getOutputEnumName();
|
||||
String pinType = namePinType.getPinType();
|
||||
String nothingName = namePinType.getNothingName();
|
||||
Map<String, Value> enumList = state.enumsReader.getEnums().get(pinType);
|
||||
EnumsReader.EnumState enumList = state.enumsReader.getEnums().get(pinType);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < kv.getValue().size(); i++) {
|
||||
if (sb.length() > 0)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.rusefi.enum_reader.Value;
|
||||
import com.rusefi.models.trigger.WheelMetaReader;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -10,9 +9,9 @@ import java.util.TreeMap;
|
|||
public class TriggerProcessor {
|
||||
|
||||
public void run(EnumsReader enumsReader, VariableRegistry instance) {
|
||||
Map<String, Map<String, Value>> enums = enumsReader.getEnums();
|
||||
Map<String, EnumsReader.EnumState> enums = enumsReader.getEnums();
|
||||
|
||||
Map<String/*enum member*/, Value> triggers = enums.get("trigger_type_e");
|
||||
EnumsReader.EnumState triggers = enums.get("trigger_type_e");
|
||||
System.out.println("triggers2: " + triggers);
|
||||
|
||||
System.out.println(instance.intValues);
|
||||
|
|
|
@ -40,7 +40,7 @@ public class VariableRegistry {
|
|||
public TreeMap<Integer, String> resolveEnumValues(EnumsReader enumsReader, String enumName) {
|
||||
TreeMap<Integer, String> valueNameById = new TreeMap<>();
|
||||
|
||||
Map<String, Value> stringValueMap = enumsReader.getEnums().get(enumName);
|
||||
EnumsReader.EnumState stringValueMap = enumsReader.getEnums().get(enumName);
|
||||
if (stringValueMap == null)
|
||||
return null;
|
||||
for (Value value : stringValueMap.values()) {
|
||||
|
|
|
@ -5,14 +5,10 @@ import com.rusefi.enum_reader.Value;
|
|||
import com.rusefi.generated.RusefiConfigGrammarBaseListener;
|
||||
import com.rusefi.generated.RusefiConfigGrammarParser;
|
||||
import com.rusefi.newparse.parsing.*;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.constants.StringType;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ParseState {
|
||||
private final Map<String, Definition> definitions = new HashMap<>();
|
||||
|
@ -51,7 +47,7 @@ public class ParseState {
|
|||
private String[] resolveEnumValues(String enumName) {
|
||||
TreeMap<Integer, String> valueNameById = new TreeMap<>();
|
||||
|
||||
Map<String, Value> stringValueMap = this.enumsReader.getEnums().get(enumName);
|
||||
EnumsReader.EnumState stringValueMap = this.enumsReader.getEnums().get(enumName);
|
||||
if (stringValueMap == null)
|
||||
return null;
|
||||
for (Value value : stringValueMap.values()) {
|
||||
|
@ -223,9 +219,9 @@ public class ParseState {
|
|||
|
||||
if (values == null) {
|
||||
values = Arrays.stream(rhs.split(",")) // Split on commas
|
||||
.map(s -> s.trim()) // trim whitespace
|
||||
.map(String::trim) // trim whitespace
|
||||
.map(s -> s.replaceAll("\"", "")) // Remove quotes
|
||||
.toArray(n -> new String[n]); // Convert back to array
|
||||
.toArray(String[]::new); // Convert back to array
|
||||
}
|
||||
|
||||
typedefs.put(typedefName, new EnumTypedef(typedefName, datatype, endBit, values));
|
||||
|
|
|
@ -118,5 +118,13 @@ public class EnumsReader {
|
|||
this.enumName = enumName;
|
||||
this.isEnumClass = isEnumClass;
|
||||
}
|
||||
|
||||
public Collection<Value> values() {
|
||||
return values.values();
|
||||
}
|
||||
|
||||
public Iterable<? extends Map.Entry<String, Value>> entrySet() {
|
||||
return values.entrySet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue