probably progress
This commit is contained in:
parent
3e2ae23166
commit
ed799501a8
|
@ -14,10 +14,10 @@ import java.util.regex.Pattern;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class ParseState extends RusefiConfigGrammarBaseListener {
|
||||
Map<String, Definition> definitions = new HashMap<>();
|
||||
Map<String, Struct> structs = new HashMap<>();
|
||||
List<Struct> structList = new ArrayList<>();
|
||||
Map<String, Typedef> typedefs = new HashMap<>();
|
||||
private final Map<String, Definition> definitions = new HashMap<>();
|
||||
private final Map<String, Struct> structs = new HashMap<>();
|
||||
private final List<Struct> structList = new ArrayList<>();
|
||||
private final Map<String, Typedef> typedefs = new HashMap<>();
|
||||
|
||||
private final EnumsReader enumsReader;
|
||||
|
||||
|
@ -176,7 +176,7 @@ public class ParseState extends RusefiConfigGrammarBaseListener {
|
|||
FieldOptions options = new FieldOptions();
|
||||
handleFieldOptionsList(options, ctx.fieldOptionsList());
|
||||
|
||||
this.typedefs.put(this.typedefName, new ScalarTypedef(this.typedefName, datatype, options));
|
||||
typedefs.put(this.typedefName, new ScalarTypedef(this.typedefName, datatype, options));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -219,7 +219,7 @@ public class ParseState extends RusefiConfigGrammarBaseListener {
|
|||
.toArray(n -> new String[n]); // Convert back to array
|
||||
}
|
||||
|
||||
this.typedefs.put(this.typedefName, new EnumTypedef(this.typedefName, datatype, endBit, values));
|
||||
typedefs.put(this.typedefName, new EnumTypedef(this.typedefName, datatype, endBit, values));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -229,7 +229,7 @@ public class ParseState extends RusefiConfigGrammarBaseListener {
|
|||
FieldOptions options = new FieldOptions();
|
||||
handleFieldOptionsList(options, ctx.fieldOptionsList());
|
||||
|
||||
this.typedefs.put(this.typedefName, new ArrayTypedef(this.typedefName, this.arrayDim, datatype, options));
|
||||
typedefs.put(this.typedefName, new ArrayTypedef(this.typedefName, this.arrayDim, datatype, options));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -328,7 +328,7 @@ public class ParseState extends RusefiConfigGrammarBaseListener {
|
|||
}
|
||||
|
||||
// Check first if we have a typedef for this type
|
||||
Typedef typedef = this.typedefs.get(type);
|
||||
Typedef typedef = typedefs.get(type);
|
||||
|
||||
FieldOptions options = null;
|
||||
if (typedef != null) {
|
||||
|
|
|
@ -27,7 +27,8 @@ public enum Type {
|
|||
}
|
||||
|
||||
public static Optional<Type> findByCtype(String cType) {
|
||||
return Arrays.stream(Type.values()).filter(t -> t.cType.equals(cType)).findFirst();
|
||||
String cTypeWithAlas = "floatms_t".equals(cType) ? "float" : cType;
|
||||
return Arrays.stream(Type.values()).filter(t -> t.cType.equals(cTypeWithAlas)).findFirst();
|
||||
}
|
||||
|
||||
public static Type findByTsType(String tsType) {
|
||||
|
|
|
@ -31,6 +31,23 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFloatMsAlias() throws IOException {
|
||||
String test = "struct pid_s\n" +
|
||||
"floatms_t afr_type;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
"percent_t afr_typet;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
"end_struct\n";
|
||||
ReaderState state = new ReaderState();
|
||||
BufferedReader reader = new BufferedReader(new StringReader(test));
|
||||
|
||||
CharArrayWriter writer = new CharArrayWriter();
|
||||
TestTSProjectConsumer javaFieldsConsumer = new TestTSProjectConsumer(writer, "", state);
|
||||
state.readBufferedReader(reader, Arrays.asList(javaFieldsConsumer));
|
||||
assertEquals("afr_type = scalar, F32, 0, \"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
"afr_typet = scalar, F32, 4, \"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
"; total TS size = 8\n", new String(writer.toCharArray()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEnum() throws IOException {
|
||||
String test = "struct pid_s\n" +
|
||||
|
|
Loading…
Reference in New Issue