Trigger setup in TS is highly confusing #3401
rabbit hole: integrating enums with TS templating
This commit is contained in:
parent
6e4c241d50
commit
5d5b4f0d56
Binary file not shown.
|
@ -2,6 +2,7 @@ package com.rusefi;
|
|||
|
||||
import com.opensr5.ini.RawIniFile;
|
||||
import com.opensr5.ini.field.EnumIniField;
|
||||
import com.rusefi.enum_reader.Value;
|
||||
import com.rusefi.output.ConfigurationConsumer;
|
||||
import com.rusefi.util.SystemOut;
|
||||
|
||||
|
@ -68,8 +69,19 @@ public class ReaderState {
|
|||
return line.length() == 0 || line.startsWith("!") || line.startsWith("//");
|
||||
}
|
||||
|
||||
void read(Reader reader) throws IOException {
|
||||
public void read(Reader reader) throws IOException {
|
||||
Map<String, EnumsReader.EnumState> newEnums = EnumsReader.readStatic(reader);
|
||||
|
||||
for (Map.Entry<String, EnumsReader.EnumState> enumFamily : newEnums.entrySet()) {
|
||||
|
||||
for (Map.Entry<String, Value> enumValue : enumFamily.getValue().entrySet()) {
|
||||
|
||||
String key = enumFamily.getKey() + "_" + enumValue.getKey();
|
||||
String value = enumValue.getValue().getValue();
|
||||
variableRegistry.register(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
enumsReader.enums.putAll(newEnums);
|
||||
}
|
||||
|
||||
|
@ -82,7 +94,7 @@ public class ReaderState {
|
|||
if (autoEnumOptions != null) {
|
||||
variableRegistry.register(name + "_auto_enum", autoEnumOptions);
|
||||
}
|
||||
|
||||
|
||||
line = line.substring(index).trim();
|
||||
index = line.indexOf(' ');
|
||||
String customSize = line.substring(0, index);
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.rusefi.test;
|
||||
|
||||
import com.rusefi.ReaderState;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class EnumAsTsVariable {
|
||||
@Test
|
||||
public void testUseEnumAsVariable() throws IOException {
|
||||
ReaderState readerState = new ReaderState();
|
||||
readerState.read(new BufferedReader(new StringReader("" +
|
||||
"typedef enum {\n" +
|
||||
"\tFO_1 = 0,\n" +
|
||||
"\n" +
|
||||
"\t// 2 cylinder\n" +
|
||||
"\tFO_1_2 = 8,\n" +
|
||||
"Force_4b_firing_order = ENUM_32_BITS,\n" +
|
||||
"} firing_order_e;")));
|
||||
|
||||
|
||||
|
||||
assertEquals("0", readerState.variableRegistry.applyVariables("@@firing_order_e_FO_1@@"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue