mirror of https://github.com/FOME-Tech/fome-fw.git
TS enum key-value form #4232
This commit is contained in:
parent
d44068746a
commit
9afad189cd
|
@ -134,6 +134,7 @@ public class ReaderState {
|
|||
tsCustomSize.put(name, size);
|
||||
|
||||
RawIniFile.Line rawLine = new RawIniFile.Line(tunerStudioLine);
|
||||
//boolean isKeyValueForm = tunerStudioLine.contains("=\"");
|
||||
if (rawLine.getTokens()[0].equals("bits")) {
|
||||
EnumIniField.ParseBitRange bitRange = new EnumIniField.ParseBitRange().invoke(rawLine.getTokens()[3]);
|
||||
int totalCount = 1 << (bitRange.getBitSize0() + 1);
|
||||
|
@ -146,6 +147,7 @@ public class ReaderState {
|
|||
if (enums.size() <= totalCount / 2)
|
||||
throw new IllegalStateException("Too many bits allocated for " + enums + " capacity=" + totalCount + "/size=" + enums.size());
|
||||
*/
|
||||
// todo: TS enum key-value form #4232?
|
||||
// this is needed to avoid 'bit Constant engineType, contains fewer options (103) that expected(128)' TS warning
|
||||
for (int i = enums.size(); i < totalCount; i++)
|
||||
tunerStudioLine += ", " + PinoutLogic.QUOTED_INVALID;
|
||||
|
|
|
@ -94,6 +94,25 @@ public class ConfigFieldParserTest {
|
|||
"; total TS size = 4\n", tsProjectConsumer.getContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShortForm() throws IOException {
|
||||
String test = "struct pid_s\n" +
|
||||
"#define ego_sensor_e_enum \"BPSX\"\n" +
|
||||
"custom ego_sensor_e 1 bits, S08, @OFFSET@, [0:1], @@ego_sensor_e_enum@@\n" +
|
||||
"ego_sensor_e afr_type1;\n" +
|
||||
"ego_sensor_e afr_type2;\n" +
|
||||
"int8_t int\n" +
|
||||
"end_struct\n";
|
||||
ReaderState state = new ReaderState();
|
||||
|
||||
TestTSProjectConsumer tsProjectConsumer = new TestTSProjectConsumer("", state);
|
||||
state.readBufferedReader(test, tsProjectConsumer);
|
||||
assertEquals("afr_type1 = bits, S08, 0, [0:1], \"BPSX\", \"INVALID\", \"INVALID\", \"INVALID\"\n" +
|
||||
"afr_type2 = bits, S08, 1, [0:1], \"BPSX\", \"INVALID\", \"INVALID\", \"INVALID\"\n" +
|
||||
"int = scalar, S08, 2, \"\", 1, 0, 0, 100, 0\n" +
|
||||
"; total TS size = 4\n", tsProjectConsumer.getContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2byteCustomEnum() throws IOException {
|
||||
String test = "struct pid_s\n" +
|
||||
|
|
|
@ -121,6 +121,7 @@ public class VariableRegistry {
|
|||
int maxValue = valueNameById.lastKey();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// todo: TS enum key-value form #4232
|
||||
for (int i = 0; i <= maxValue; i++) {
|
||||
if (sb.length() > 0)
|
||||
sb.append(", ");
|
||||
|
|
Loading…
Reference in New Issue