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"));
|
PinType listPinType = PinType.find((String) listPins.get(i).get("class"));
|
||||||
String pinType = listPinType.getPinType();
|
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()) {
|
for (Map.Entry<String, Value> kv : enumList.entrySet()) {
|
||||||
if (kv.getKey().equals(id)) {
|
if (kv.getKey().equals(id)) {
|
||||||
int index = kv.getValue().getIntValue();
|
int index = kv.getValue().getIntValue();
|
||||||
|
@ -494,7 +494,7 @@ public class ConfigDefinition {
|
||||||
String outputEnumName = namePinType.getOutputEnumName();
|
String outputEnumName = namePinType.getOutputEnumName();
|
||||||
String pinType = namePinType.getPinType();
|
String pinType = namePinType.getPinType();
|
||||||
String nothingName = namePinType.getNothingName();
|
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();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < kv.getValue().size(); i++) {
|
for (int i = 0; i < kv.getValue().size(); i++) {
|
||||||
if (sb.length() > 0)
|
if (sb.length() > 0)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
import com.rusefi.enum_reader.Value;
|
|
||||||
import com.rusefi.models.trigger.WheelMetaReader;
|
import com.rusefi.models.trigger.WheelMetaReader;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -10,9 +9,9 @@ import java.util.TreeMap;
|
||||||
public class TriggerProcessor {
|
public class TriggerProcessor {
|
||||||
|
|
||||||
public void run(EnumsReader enumsReader, VariableRegistry instance) {
|
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("triggers2: " + triggers);
|
||||||
|
|
||||||
System.out.println(instance.intValues);
|
System.out.println(instance.intValues);
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class VariableRegistry {
|
||||||
public TreeMap<Integer, String> resolveEnumValues(EnumsReader enumsReader, String enumName) {
|
public TreeMap<Integer, String> resolveEnumValues(EnumsReader enumsReader, String enumName) {
|
||||||
TreeMap<Integer, String> valueNameById = new TreeMap<>();
|
TreeMap<Integer, String> valueNameById = new TreeMap<>();
|
||||||
|
|
||||||
Map<String, Value> stringValueMap = enumsReader.getEnums().get(enumName);
|
EnumsReader.EnumState stringValueMap = enumsReader.getEnums().get(enumName);
|
||||||
if (stringValueMap == null)
|
if (stringValueMap == null)
|
||||||
return null;
|
return null;
|
||||||
for (Value value : stringValueMap.values()) {
|
for (Value value : stringValueMap.values()) {
|
||||||
|
|
|
@ -5,14 +5,10 @@ import com.rusefi.enum_reader.Value;
|
||||||
import com.rusefi.generated.RusefiConfigGrammarBaseListener;
|
import com.rusefi.generated.RusefiConfigGrammarBaseListener;
|
||||||
import com.rusefi.generated.RusefiConfigGrammarParser;
|
import com.rusefi.generated.RusefiConfigGrammarParser;
|
||||||
import com.rusefi.newparse.parsing.*;
|
import com.rusefi.newparse.parsing.*;
|
||||||
import jdk.nashorn.internal.runtime.regexp.joni.constants.StringType;
|
|
||||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ParseState {
|
public class ParseState {
|
||||||
private final Map<String, Definition> definitions = new HashMap<>();
|
private final Map<String, Definition> definitions = new HashMap<>();
|
||||||
|
@ -51,7 +47,7 @@ public class ParseState {
|
||||||
private String[] resolveEnumValues(String enumName) {
|
private String[] resolveEnumValues(String enumName) {
|
||||||
TreeMap<Integer, String> valueNameById = new TreeMap<>();
|
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)
|
if (stringValueMap == null)
|
||||||
return null;
|
return null;
|
||||||
for (Value value : stringValueMap.values()) {
|
for (Value value : stringValueMap.values()) {
|
||||||
|
@ -223,9 +219,9 @@ public class ParseState {
|
||||||
|
|
||||||
if (values == null) {
|
if (values == null) {
|
||||||
values = Arrays.stream(rhs.split(",")) // Split on commas
|
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
|
.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));
|
typedefs.put(typedefName, new EnumTypedef(typedefName, datatype, endBit, values));
|
||||||
|
|
|
@ -118,5 +118,13 @@ public class EnumsReader {
|
||||||
this.enumName = enumName;
|
this.enumName = enumName;
|
||||||
this.isEnumClass = isEnumClass;
|
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