diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 0e01ad71ae..58de08573c 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -2104,4 +2104,5 @@ end_struct #define show_test_presets true #define show_Frankenso_presets true + ! poke \ No newline at end of file diff --git a/java_tools/ConfigDefinition.jar b/java_tools/ConfigDefinition.jar index 9ef370e145..f7172700cd 100644 Binary files a/java_tools/ConfigDefinition.jar and b/java_tools/ConfigDefinition.jar differ diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/ConfigStructure.java b/java_tools/configuration_definition/src/main/java/com/rusefi/ConfigStructure.java index 9049cfceda..c612fde4c9 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/ConfigStructure.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/ConfigStructure.java @@ -1,7 +1,11 @@ package com.rusefi; +import com.fathzer.soft.javaluator.Parameters; + import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import static com.rusefi.ConfigField.BOOLEAN_T; @@ -30,6 +34,7 @@ public class ConfigStructure { public final BitState readingBitState = new BitState(); private ConfigField cPrevField = ConfigField.VOID; + private final Set names = new HashSet<>(); public ConfigStructure(String name, String comment, boolean withPrefix, boolean withConstructor) { this.name = name; @@ -82,10 +87,14 @@ public class ConfigStructure { } public void addC(ConfigField cf) { - // skip duplicate names + // skip duplicate names - that's the weird use-case of conditional project definition like lambdaTable if (cf.getName().equals(cPrevField.getName())) return; + boolean isNew = names.add(cf.getName()); + if (!isNew) + throw new IllegalStateException(cf.getName() + " name already used"); + cFields.add(cf); cPrevField = cf; diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/ReaderState.java b/java_tools/configuration_definition/src/main/java/com/rusefi/ReaderState.java index 801c311e5a..4cf7e42388 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/ReaderState.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/ReaderState.java @@ -33,7 +33,6 @@ public class ReaderState { public EnumsReader enumsReader = new EnumsReader(); - private static void handleBitLine(ReaderState state, String line) { line = line.substring(BIT.length() + 1).trim(); diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/test/ConfigFieldParserTest.java b/java_tools/configuration_definition/src/main/java/com/rusefi/test/ConfigFieldParserTest.java index b66e74b324..4a14db81a5 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/test/ConfigFieldParserTest.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/test/ConfigFieldParserTest.java @@ -48,6 +48,24 @@ public class ConfigFieldParserTest { "; total TS size = 8\n", new String(writer.toCharArray())); } + @Test(expected = IllegalStateException.class) + public void testSameFieldTwice() throws IOException { + String test = "struct pid_s\n" + + "int afr_type1;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" + + "int afr_type2;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" + + "int afr_type1;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" + + "end_struct\n"; + ReaderState state = new ReaderState(); + BufferedReader reader = new BufferedReader(new StringReader(test)); + + BaseCHeaderConsumer consumer = new BaseCHeaderConsumer() { + @Override + public void endFile() { + } + }; + state.readBufferedReader(reader, Arrays.asList(consumer)); + } + @Test public void testCustomEnum() throws IOException { String test = "struct pid_s\n" +