mirror of https://github.com/rusefi/rusefi-1.git
fixing EnumToString in light of __packed__
This commit is contained in:
parent
d3a9860da9
commit
b5bd4f646e
|
@ -1,6 +1,6 @@
|
||||||
// auto-generated from.\controllers/algo/rusefi_enums.h
|
// auto-generated from.\controllers/algo/rusefi_enums.h
|
||||||
// by enum2string.jar tool
|
// by enum2string.jar tool
|
||||||
// on Thu Nov 22 20:05:41 EST 2018
|
// on Wed Apr 10 18:38:13 EDT 2019
|
||||||
// see also gen_config_and_enums.bat
|
// see also gen_config_and_enums.bat
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@ case DODGE_RAM:
|
||||||
return "DODGE_RAM";
|
return "DODGE_RAM";
|
||||||
case DODGE_STRATUS:
|
case DODGE_STRATUS:
|
||||||
return "DODGE_STRATUS";
|
return "DODGE_STRATUS";
|
||||||
|
case ETB_BENCH_ENGINE:
|
||||||
|
return "ETB_BENCH_ENGINE";
|
||||||
case FORD_ASPIRE_1996:
|
case FORD_ASPIRE_1996:
|
||||||
return "FORD_ASPIRE_1996";
|
return "FORD_ASPIRE_1996";
|
||||||
case FORD_ESCORT_GT:
|
case FORD_ESCORT_GT:
|
||||||
|
@ -91,10 +93,6 @@ case MIATA_NA6_MAP:
|
||||||
return "MIATA_NA6_MAP";
|
return "MIATA_NA6_MAP";
|
||||||
case MIATA_NA6_VAF:
|
case MIATA_NA6_VAF:
|
||||||
return "MIATA_NA6_VAF";
|
return "MIATA_NA6_VAF";
|
||||||
case ETB_BENCH_ENGINE:
|
|
||||||
return "ETB_BENCH_ENGINE";
|
|
||||||
case TLE8888_BENCH_ENGINE:
|
|
||||||
return "TLE8888_BENCH_ENGINE";
|
|
||||||
case MINIMAL_PINS:
|
case MINIMAL_PINS:
|
||||||
return "MINIMAL_PINS";
|
return "MINIMAL_PINS";
|
||||||
case MINI_COOPER_R50:
|
case MINI_COOPER_R50:
|
||||||
|
@ -127,6 +125,8 @@ case TEST_ISSUE_366_BOTH:
|
||||||
return "TEST_ISSUE_366_BOTH";
|
return "TEST_ISSUE_366_BOTH";
|
||||||
case TEST_ISSUE_366_RISE:
|
case TEST_ISSUE_366_RISE:
|
||||||
return "TEST_ISSUE_366_RISE";
|
return "TEST_ISSUE_366_RISE";
|
||||||
|
case TLE8888_BENCH_ENGINE:
|
||||||
|
return "TLE8888_BENCH_ENGINE";
|
||||||
case TOYOTA_2JZ_GTE_VVTi:
|
case TOYOTA_2JZ_GTE_VVTi:
|
||||||
return "TOYOTA_2JZ_GTE_VVTi";
|
return "TOYOTA_2JZ_GTE_VVTi";
|
||||||
case TOYOTA_JZS147:
|
case TOYOTA_JZS147:
|
||||||
|
@ -365,6 +365,19 @@ case OM_OPENDRAIN_INVERTED:
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
const char *getPin_mode_e(pin_mode_e value){
|
||||||
|
switch(value) {
|
||||||
|
case PO_DEFAULT:
|
||||||
|
return "PO_DEFAULT";
|
||||||
|
case PO_OPENDRAIN:
|
||||||
|
return "PO_OPENDRAIN";
|
||||||
|
case PO_PULLDOWN:
|
||||||
|
return "PO_PULLDOWN";
|
||||||
|
case PO_PULLUP:
|
||||||
|
return "PO_PULLUP";
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
const char *getPin_input_mode_e(pin_input_mode_e value){
|
const char *getPin_input_mode_e(pin_input_mode_e value){
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case PI_DEFAULT:
|
case PI_DEFAULT:
|
||||||
|
@ -401,10 +414,10 @@ case IM_INDIVIDUAL_COILS:
|
||||||
return "IM_INDIVIDUAL_COILS";
|
return "IM_INDIVIDUAL_COILS";
|
||||||
case IM_ONE_COIL:
|
case IM_ONE_COIL:
|
||||||
return "IM_ONE_COIL";
|
return "IM_ONE_COIL";
|
||||||
|
case IM_TWO_COILS:
|
||||||
|
return "IM_TWO_COILS";
|
||||||
case IM_WASTED_SPARK:
|
case IM_WASTED_SPARK:
|
||||||
return "IM_WASTED_SPARK";
|
return "IM_WASTED_SPARK";
|
||||||
case IM_TWO_COILS:
|
|
||||||
return "IM_TWO_COILS";
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -451,6 +464,19 @@ case UART_NONE:
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
const char *getSpi_speed_e(spi_speed_e value){
|
||||||
|
switch(value) {
|
||||||
|
case _150KHz:
|
||||||
|
return "_150KHz";
|
||||||
|
case _1_25MHz:
|
||||||
|
return "_1_25MHz";
|
||||||
|
case _2_5MHz:
|
||||||
|
return "_2_5MHz";
|
||||||
|
case _5MHz:
|
||||||
|
return "_5MHz";
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
const char *getSpi_device_e(spi_device_e value){
|
const char *getSpi_device_e(spi_device_e value){
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case Force_4_bytes_size_spi_device:
|
case Force_4_bytes_size_spi_device:
|
||||||
|
@ -526,6 +552,8 @@ const char *getEgo_sensor_e(ego_sensor_e value){
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case ES_14Point7_Free:
|
case ES_14Point7_Free:
|
||||||
return "ES_14Point7_Free";
|
return "ES_14Point7_Free";
|
||||||
|
case ES_AEM:
|
||||||
|
return "ES_AEM";
|
||||||
case ES_BPSX_D1:
|
case ES_BPSX_D1:
|
||||||
return "ES_BPSX_D1";
|
return "ES_BPSX_D1";
|
||||||
case ES_Custom:
|
case ES_Custom:
|
||||||
|
@ -534,8 +562,6 @@ case ES_Innovate_MTX_L:
|
||||||
return "ES_Innovate_MTX_L";
|
return "ES_Innovate_MTX_L";
|
||||||
case ES_NarrowBand:
|
case ES_NarrowBand:
|
||||||
return "ES_NarrowBand";
|
return "ES_NarrowBand";
|
||||||
case ES_AEM:
|
|
||||||
return "ES_AEM";
|
|
||||||
case ES_PLX:
|
case ES_PLX:
|
||||||
return "ES_PLX";
|
return "ES_PLX";
|
||||||
case Force_4_bytes_size_ego_sensor:
|
case Force_4_bytes_size_ego_sensor:
|
||||||
|
@ -705,10 +731,6 @@ case GPIOE_8:
|
||||||
return "GPIOE_8";
|
return "GPIOE_8";
|
||||||
case GPIOE_9:
|
case GPIOE_9:
|
||||||
return "GPIOE_9";
|
return "GPIOE_9";
|
||||||
case GPIO_INVALID:
|
|
||||||
return "GPIO_INVALID";
|
|
||||||
case GPIO_UNASSIGNED:
|
|
||||||
return "GPIO_UNASSIGNED";
|
|
||||||
case GPIOF_0:
|
case GPIOF_0:
|
||||||
return "GPIOF_0";
|
return "GPIOF_0";
|
||||||
case GPIOF_1:
|
case GPIOF_1:
|
||||||
|
@ -770,7 +792,7 @@ case GPIOG_6:
|
||||||
case GPIOG_7:
|
case GPIOG_7:
|
||||||
return "GPIOG_7";
|
return "GPIOG_7";
|
||||||
case GPIOG_8:
|
case GPIOG_8:
|
||||||
return "GPIOA_G";
|
return "GPIOG_8";
|
||||||
case GPIOG_9:
|
case GPIOG_9:
|
||||||
return "GPIOG_9";
|
return "GPIOG_9";
|
||||||
case GPIOH_0:
|
case GPIOH_0:
|
||||||
|
@ -805,13 +827,15 @@ case GPIOH_8:
|
||||||
return "GPIOH_8";
|
return "GPIOH_8";
|
||||||
case GPIOH_9:
|
case GPIOH_9:
|
||||||
return "GPIOH_9";
|
return "GPIOH_9";
|
||||||
|
case GPIO_INVALID:
|
||||||
|
return "GPIO_INVALID";
|
||||||
|
case GPIO_UNASSIGNED:
|
||||||
|
return "GPIO_UNASSIGNED";
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
const char *getDebug_mode_e(debug_mode_e value){
|
const char *getDebug_mode_e(debug_mode_e value){
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case DBG_TLE8888:
|
|
||||||
return "DBG_TLE8888";
|
|
||||||
case DBG_32:
|
case DBG_32:
|
||||||
return "DBG_32";
|
return "DBG_32";
|
||||||
case DBG_33:
|
case DBG_33:
|
||||||
|
@ -854,6 +878,8 @@ case DBG_IGNITION_TIMING:
|
||||||
return "DBG_IGNITION_TIMING";
|
return "DBG_IGNITION_TIMING";
|
||||||
case DBG_INSTANT_RPM:
|
case DBG_INSTANT_RPM:
|
||||||
return "DBG_INSTANT_RPM";
|
return "DBG_INSTANT_RPM";
|
||||||
|
case DBG_ION:
|
||||||
|
return "DBG_ION";
|
||||||
case DBG_KNOCK:
|
case DBG_KNOCK:
|
||||||
return "DBG_KNOCK";
|
return "DBG_KNOCK";
|
||||||
case DBG_MAP:
|
case DBG_MAP:
|
||||||
|
@ -866,6 +892,8 @@ case DBG_SR5_PROTOCOL:
|
||||||
return "DBG_SR5_PROTOCOL";
|
return "DBG_SR5_PROTOCOL";
|
||||||
case DBG_STATUS:
|
case DBG_STATUS:
|
||||||
return "DBG_STATUS";
|
return "DBG_STATUS";
|
||||||
|
case DBG_TLE8888:
|
||||||
|
return "DBG_TLE8888";
|
||||||
case DBG_TPS_ACCEL:
|
case DBG_TPS_ACCEL:
|
||||||
return "DBG_TPS_ACCEL";
|
return "DBG_TPS_ACCEL";
|
||||||
case DBG_TRIGGER_INPUT:
|
case DBG_TRIGGER_INPUT:
|
||||||
|
@ -878,8 +906,6 @@ case DBG_VVT:
|
||||||
return "DBG_VVT";
|
return "DBG_VVT";
|
||||||
case DBG_WARMUP_ENRICH:
|
case DBG_WARMUP_ENRICH:
|
||||||
return "DBG_WARMUP_ENRICH";
|
return "DBG_WARMUP_ENRICH";
|
||||||
case DBG_ION:
|
|
||||||
return "DBG_ION";
|
|
||||||
case Force_4_bytes_size_debug_mode_e:
|
case Force_4_bytes_size_debug_mode_e:
|
||||||
return "Force_4_bytes_size_debug_mode_e";
|
return "Force_4_bytes_size_debug_mode_e";
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -1,9 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
<component name="SvnBranchConfigurationManager">
|
|
||||||
<option name="mySupportsUserInfoFilter" value="true" />
|
|
||||||
</component>
|
|
||||||
</project>
|
</project>
|
|
@ -2,6 +2,6 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="svn" />
|
<mapping directory="" vcs="svn" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.TreeSet;
|
||||||
public class EnumToString {
|
public class EnumToString {
|
||||||
private final static Set<String> currentValues = new TreeSet<>();
|
private final static Set<String> currentValues = new TreeSet<>();
|
||||||
|
|
||||||
private final static StringBuilder cppFileContent = new StringBuilder();
|
public final static StringBuilder cppFileContent = new StringBuilder();
|
||||||
private final static StringBuilder headerFileContent = new StringBuilder();
|
private final static StringBuilder headerFileContent = new StringBuilder();
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
|
@ -46,7 +46,6 @@ public class EnumToString {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void process(String inFileName) throws IOException {
|
private static void process(String inFileName) throws IOException {
|
||||||
BufferedReader reader;
|
|
||||||
|
|
||||||
String header = "// auto-generated from" + inFileName + "\r\n" +
|
String header = "// auto-generated from" + inFileName + "\r\n" +
|
||||||
"// by enum2string.jar tool\r\n" +
|
"// by enum2string.jar tool\r\n" +
|
||||||
|
@ -59,7 +58,6 @@ public class EnumToString {
|
||||||
cppFileContent.append(header);
|
cppFileContent.append(header);
|
||||||
EnumToString.headerFileContent.insert(0, header);
|
EnumToString.headerFileContent.insert(0, header);
|
||||||
|
|
||||||
boolean isInsideEnum = false;
|
|
||||||
|
|
||||||
File f = new File(inFileName);
|
File f = new File(inFileName);
|
||||||
System.out.println("Reading from " + inFileName);
|
System.out.println("Reading from " + inFileName);
|
||||||
|
@ -69,12 +67,21 @@ public class EnumToString {
|
||||||
cppFileContent.append("#include \"" + simpleFileName + "\"\r\n");
|
cppFileContent.append("#include \"" + simpleFileName + "\"\r\n");
|
||||||
EnumToString.headerFileContent.append("#include \"" + simpleFileName + "\"\r\n");
|
EnumToString.headerFileContent.append("#include \"" + simpleFileName + "\"\r\n");
|
||||||
|
|
||||||
reader = new BufferedReader(new FileReader(inFileName));
|
process(new FileReader(inFileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
cppFileContent.setLength(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void process(Reader in) throws IOException {
|
||||||
|
boolean isInsideEnum = false;
|
||||||
|
BufferedReader reader = new BufferedReader(in);
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
line = removeSpaces(line);
|
line = removeSpaces(line);
|
||||||
|
|
||||||
if (line.startsWith("typedefenum{")) {
|
if (line.startsWith("typedefenum{") || line.startsWith("typedefenum__attribute__")) {
|
||||||
System.out.println("Entering enum");
|
System.out.println("Entering enum");
|
||||||
currentValues.clear();
|
currentValues.clear();
|
||||||
isInsideEnum = true;
|
isInsideEnum = true;
|
||||||
|
|
|
@ -2,7 +2,11 @@ package com.rusefi;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
|
|
||||||
import static com.rusefi.EnumToString.isKeyValueLine;
|
import static com.rusefi.EnumToString.isKeyValueLine;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class EnumToStringTest {
|
public class EnumToStringTest {
|
||||||
|
@ -12,4 +16,42 @@ public class EnumToStringTest {
|
||||||
assertTrue(isKeyValueLine("MIN = 2,"));
|
assertTrue(isKeyValueLine("MIN = 2,"));
|
||||||
assertTrue(isKeyValueLine("MIN = -3,"));
|
assertTrue(isKeyValueLine("MIN = -3,"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parseEnum() throws IOException {
|
||||||
|
EnumToString.clear();
|
||||||
|
EnumToString.process(new StringReader(
|
||||||
|
"typedef enum {\n" +
|
||||||
|
"\tGPIO_UNASSIGNED = 0,\n" +
|
||||||
|
"\tGPIO_INVALID = 1,\n" +
|
||||||
|
"}brain_pin_e;"));
|
||||||
|
assertEquals("const char *getBrain_pin_e(brain_pin_e value){\r\n" +
|
||||||
|
"switch(value) {\r\n" +
|
||||||
|
"case GPIO_INVALID:\r\n" +
|
||||||
|
" return \"GPIO_INVALID\";\r\n" +
|
||||||
|
"case GPIO_UNASSIGNED:\r\n" +
|
||||||
|
" return \"GPIO_UNASSIGNED\";\r\n" +
|
||||||
|
" }\r\n" +
|
||||||
|
" return NULL;\r\n" +
|
||||||
|
"}\r\n", EnumToString.cppFileContent.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parsePackedEnum() throws IOException {
|
||||||
|
EnumToString.clear();
|
||||||
|
EnumToString.process(new StringReader(
|
||||||
|
"typedef enum __attribute__ ((__packed__)) {\n" +
|
||||||
|
"\tGPIO_UNASSIGNED = 0,\n" +
|
||||||
|
"\tGPIO_INVALID = 1,\n" +
|
||||||
|
"} brain_pin_e ;"));
|
||||||
|
assertEquals("const char *getBrain_pin_e(brain_pin_e value){\r\n" +
|
||||||
|
"switch(value) {\r\n" +
|
||||||
|
"case GPIO_INVALID:\r\n" +
|
||||||
|
" return \"GPIO_INVALID\";\r\n" +
|
||||||
|
"case GPIO_UNASSIGNED:\r\n" +
|
||||||
|
" return \"GPIO_UNASSIGNED\";\r\n" +
|
||||||
|
" }\r\n" +
|
||||||
|
" return NULL;\r\n" +
|
||||||
|
"}\r\n", EnumToString.cppFileContent.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue