mirror of https://github.com/rusefi/rusefi-1.git
enum2string cleanup
This commit is contained in:
parent
31771af929
commit
0c5f31f5e5
|
@ -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 Fri Jan 26 11:27:27 EST 2018
|
// on Wed Nov 21 20:48:18 EST 2018
|
||||||
// see also gen_config_and_enums.bat
|
// see also gen_config_and_enums.bat
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,6 +75,8 @@ case MAZDA_MIATA_2003_BOARD_TEST:
|
||||||
return "MAZDA_MIATA_2003_BOARD_TEST";
|
return "MAZDA_MIATA_2003_BOARD_TEST";
|
||||||
case MAZDA_MIATA_2003_NA_RAIL:
|
case MAZDA_MIATA_2003_NA_RAIL:
|
||||||
return "MAZDA_MIATA_2003_NA_RAIL";
|
return "MAZDA_MIATA_2003_NA_RAIL";
|
||||||
|
case MAZDA_MIATA_NA8:
|
||||||
|
return "MAZDA_MIATA_NA8";
|
||||||
case MAZDA_MIATA_NB1:
|
case MAZDA_MIATA_NB1:
|
||||||
return "MAZDA_MIATA_NB1";
|
return "MAZDA_MIATA_NB1";
|
||||||
case MIATA_1990:
|
case MIATA_1990:
|
||||||
|
@ -87,8 +89,6 @@ case MIATA_1996:
|
||||||
return "MIATA_1996";
|
return "MIATA_1996";
|
||||||
case MIATA_NA_1_6:
|
case MIATA_NA_1_6:
|
||||||
return "MIATA_NA_1_6";
|
return "MIATA_NA_1_6";
|
||||||
case MAZDA_MIATA_NA8:
|
|
||||||
return "MAZDA_MIATA_NA8";
|
|
||||||
case MINI_COOPER_R50:
|
case MINI_COOPER_R50:
|
||||||
return "MINI_COOPER_R50";
|
return "MINI_COOPER_R50";
|
||||||
case MITSU_4G93:
|
case MITSU_4G93:
|
||||||
|
@ -130,26 +130,7 @@ case ZIL_130:
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
const char *getTrigger_type_e(trigger_type_e value){
|
||||||
const char *getHip_state_e(hip_state_e value) {
|
|
||||||
switch (value) {
|
|
||||||
case NOT_READY:
|
|
||||||
return "NOT_READY";
|
|
||||||
case READY_TO_INTEGRATE:
|
|
||||||
return "READY_TO_INTEGRATE";
|
|
||||||
case IS_INTEGRATING:
|
|
||||||
return "IS_INTEGRATING";
|
|
||||||
case WAITING_FOR_ADC_TO_SKIP:
|
|
||||||
return "WAITING_FOR_ADC_TO_SKIP";
|
|
||||||
case WAITING_FOR_RESULT_ADC:
|
|
||||||
return "WAITING_FOR_RESULT_ADC";
|
|
||||||
case IS_SENDING_SPI_COMMAND:
|
|
||||||
return "IS_SENDING_SPI_COMMAND";
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *getTrigger_type_e(trigger_type_e value) {
|
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case Force_4_bytes_size_trigger_type:
|
case Force_4_bytes_size_trigger_type:
|
||||||
return "Force_4_bytes_size_trigger_type";
|
return "Force_4_bytes_size_trigger_type";
|
||||||
|
@ -175,12 +156,12 @@ case TT_DODGE_RAM:
|
||||||
return "TT_DODGE_RAM";
|
return "TT_DODGE_RAM";
|
||||||
case TT_DODGE_STRATUS:
|
case TT_DODGE_STRATUS:
|
||||||
return "TT_DODGE_STRATUS";
|
return "TT_DODGE_STRATUS";
|
||||||
|
case TT_FIAT_IAW_P8:
|
||||||
|
return "TT_FIAT_IAW_P8";
|
||||||
case TT_FORD_ASPIRE:
|
case TT_FORD_ASPIRE:
|
||||||
return "TT_FORD_ASPIRE";
|
return "TT_FORD_ASPIRE";
|
||||||
case TT_GM_7X:
|
case TT_GM_7X:
|
||||||
return "TT_GM_7X";
|
return "TT_GM_7X";
|
||||||
case TT_FIAT_IAW_P8:
|
|
||||||
return "TT_FIAT_IAW_P8";
|
|
||||||
case TT_GM_LS_24:
|
case TT_GM_LS_24:
|
||||||
return "TT_GM_LS_24";
|
return "TT_GM_LS_24";
|
||||||
case TT_HONDA_1_24:
|
case TT_HONDA_1_24:
|
||||||
|
@ -200,7 +181,7 @@ case TT_HONDA_CBR_600_CUSTOM:
|
||||||
case TT_JEEP_18_2_2_2:
|
case TT_JEEP_18_2_2_2:
|
||||||
return "TT_JEEP_18_2_2_2";
|
return "TT_JEEP_18_2_2_2";
|
||||||
case TT_JEEP_4_CYL:
|
case TT_JEEP_4_CYL:
|
||||||
return "TT_JEEP_4_CYL";
|
return "TT_JEEP_4_CYL";
|
||||||
case TT_MAZDA_DOHC_1_4:
|
case TT_MAZDA_DOHC_1_4:
|
||||||
return "TT_MAZDA_DOHC_1_4";
|
return "TT_MAZDA_DOHC_1_4";
|
||||||
case TT_MAZDA_MIATA_NA:
|
case TT_MAZDA_MIATA_NA:
|
||||||
|
@ -734,16 +715,16 @@ case GPIO_UNASSIGNED:
|
||||||
}
|
}
|
||||||
const char *getDebug_mode_e(debug_mode_e value){
|
const char *getDebug_mode_e(debug_mode_e value){
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case DBG_CJ125:
|
case DBG_30:
|
||||||
return "DBG_CJ125";
|
return "DBG_30";
|
||||||
case DBG_CAN:
|
case DBG_31:
|
||||||
return "DBG_CAN";
|
return "DBG_31";
|
||||||
case DBG_MAP:
|
case DBG_32:
|
||||||
return "DBG_MAP";
|
return "DBG_32";
|
||||||
case DBG_METRICS:
|
case DBG_33:
|
||||||
return "DBG_METRICS";
|
return "DBG_33";
|
||||||
case DBG_ELECTRONIC_THROTTLE_EXTRA:
|
case DBG_34:
|
||||||
return "DBG_ELECTRONIC_THROTTLE_EXTRA";
|
return "DBG_34";
|
||||||
case DBG_ADC:
|
case DBG_ADC:
|
||||||
return "DBG_ADC";
|
return "DBG_ADC";
|
||||||
case DBG_ALTERNATOR_PID:
|
case DBG_ALTERNATOR_PID:
|
||||||
|
@ -754,8 +735,14 @@ case DBG_AUX_VALVES:
|
||||||
return "DBG_AUX_VALVES";
|
return "DBG_AUX_VALVES";
|
||||||
case DBG_BENCH_TEST:
|
case DBG_BENCH_TEST:
|
||||||
return "DBG_BENCH_TEST";
|
return "DBG_BENCH_TEST";
|
||||||
|
case DBG_CAN:
|
||||||
|
return "DBG_CAN";
|
||||||
|
case DBG_CJ125:
|
||||||
|
return "DBG_CJ125";
|
||||||
case DBG_CRANKING_DETAILS:
|
case DBG_CRANKING_DETAILS:
|
||||||
return "DBG_CRANKING_DETAILS";
|
return "DBG_CRANKING_DETAILS";
|
||||||
|
case DBG_ELECTRONIC_THROTTLE_EXTRA:
|
||||||
|
return "DBG_ELECTRONIC_THROTTLE_EXTRA";
|
||||||
case DBG_ELECTRONIC_THROTTLE_PID:
|
case DBG_ELECTRONIC_THROTTLE_PID:
|
||||||
return "DBG_ELECTRONIC_THROTTLE_PID";
|
return "DBG_ELECTRONIC_THROTTLE_PID";
|
||||||
case DBG_EL_ACCEL:
|
case DBG_EL_ACCEL:
|
||||||
|
@ -776,6 +763,10 @@ case DBG_INSTANT_RPM:
|
||||||
return "DBG_INSTANT_RPM";
|
return "DBG_INSTANT_RPM";
|
||||||
case DBG_KNOCK:
|
case DBG_KNOCK:
|
||||||
return "DBG_KNOCK";
|
return "DBG_KNOCK";
|
||||||
|
case DBG_MAP:
|
||||||
|
return "DBG_MAP";
|
||||||
|
case DBG_METRICS:
|
||||||
|
return "DBG_METRICS";
|
||||||
case DBG_SD_CARD:
|
case DBG_SD_CARD:
|
||||||
return "DBG_SD_CARD";
|
return "DBG_SD_CARD";
|
||||||
case DBG_SR5_PROTOCOL:
|
case DBG_SR5_PROTOCOL:
|
||||||
|
@ -796,9 +787,7 @@ case DBG_WARMUP_ENRICH:
|
||||||
return "DBG_WARMUP_ENRICH";
|
return "DBG_WARMUP_ENRICH";
|
||||||
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";
|
||||||
default:
|
}
|
||||||
return "NA";
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
const char *getAir_pressure_sensor_type_e(air_pressure_sensor_type_e value){
|
const char *getAir_pressure_sensor_type_e(air_pressure_sensor_type_e value){
|
||||||
|
@ -927,3 +916,31 @@ case Internal_ForceMyEnumIntSize_can_nbc:
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
const char *getHip_state_e(hip_state_e value){
|
||||||
|
switch(value) {
|
||||||
|
case IS_INTEGRATING:
|
||||||
|
return "IS_INTEGRATING";
|
||||||
|
case IS_SENDING_SPI_COMMAND:
|
||||||
|
return "IS_SENDING_SPI_COMMAND";
|
||||||
|
case NOT_READY:
|
||||||
|
return "NOT_READY";
|
||||||
|
case READY_TO_INTEGRATE:
|
||||||
|
return "READY_TO_INTEGRATE";
|
||||||
|
case WAITING_FOR_ADC_TO_SKIP:
|
||||||
|
return "WAITING_FOR_ADC_TO_SKIP";
|
||||||
|
case WAITING_FOR_RESULT_ADC:
|
||||||
|
return "WAITING_FOR_RESULT_ADC";
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
const char *getTChargeMode_e(tChargeMode_e value){
|
||||||
|
switch(value) {
|
||||||
|
case Force_4bytes_size_tChargeMode_e:
|
||||||
|
return "Force_4bytes_size_tChargeMode_e";
|
||||||
|
case TCHARGE_MODE_AIR_INTERP:
|
||||||
|
return "TCHARGE_MODE_AIR_INTERP";
|
||||||
|
case TCHARGE_MODE_RPM_TPS:
|
||||||
|
return "TCHARGE_MODE_RPM_TPS";
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
#ifndef _A_H_HEADER_
|
|
||||||
#define _A_H_HEADER_
|
|
||||||
// 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 Fri Jan 26 11:27:27 EST 2018
|
// on Wed Nov 21 20:48:18 EST 2018
|
||||||
// see also gen_config_and_enums.bat
|
// see also gen_config_and_enums.bat
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _A_H_HEADER_
|
||||||
|
#define _A_H_HEADER_
|
||||||
#include "rusefi_enums.h"
|
#include "rusefi_enums.h"
|
||||||
const char *getEngine_type_e(engine_type_e value);
|
const char *getEngine_type_e(engine_type_e value);
|
||||||
const char *getHip_state_e(hip_state_e value);
|
|
||||||
const char *getTrigger_type_e(trigger_type_e value);
|
const char *getTrigger_type_e(trigger_type_e value);
|
||||||
const char *getAdc_channel_mode_e(adc_channel_mode_e value);
|
const char *getAdc_channel_mode_e(adc_channel_mode_e value);
|
||||||
const char *getTrigger_value_e(trigger_value_e value);
|
const char *getTrigger_value_e(trigger_value_e value);
|
||||||
|
@ -42,4 +41,6 @@ const char *getMaf_sensor_type_e(maf_sensor_type_e value);
|
||||||
const char *getTiming_mode_e(timing_mode_e value);
|
const char *getTiming_mode_e(timing_mode_e value);
|
||||||
const char *getChamber_style_e(chamber_style_e value);
|
const char *getChamber_style_e(chamber_style_e value);
|
||||||
const char *getCan_nbc_e(can_nbc_e value);
|
const char *getCan_nbc_e(can_nbc_e value);
|
||||||
|
const char *getHip_state_e(hip_state_e value);
|
||||||
|
const char *getTChargeMode_e(tChargeMode_e value);
|
||||||
#endif /*_A_H_HEADER_ */
|
#endif /*_A_H_HEADER_ */
|
||||||
|
|
Binary file not shown.
|
@ -12,10 +12,10 @@ import java.util.TreeSet;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
|
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
|
||||||
public class EnumToString {
|
public class EnumToString {
|
||||||
private final static Set<String> currentValues = new TreeSet<String>();
|
private final static Set<String> currentValues = new TreeSet<>();
|
||||||
|
|
||||||
private final static StringBuilder result = new StringBuilder();
|
private final static StringBuilder cppFileContent = new StringBuilder();
|
||||||
private final static StringBuilder header = 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 {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
|
@ -25,24 +25,23 @@ public class EnumToString {
|
||||||
String inputPath = args[0];
|
String inputPath = args[0];
|
||||||
String outputPath = args[1];
|
String outputPath = args[1];
|
||||||
|
|
||||||
header.append("#ifndef _A_H_HEADER_\r\n");
|
headerFileContent.append("#ifndef _A_H_HEADER_\r\n");
|
||||||
header.append("#define _A_H_HEADER_\r\n");
|
headerFileContent.append("#define _A_H_HEADER_\r\n");
|
||||||
|
|
||||||
// process(path + File.separator + "controllers/algo/io_pins.h");
|
|
||||||
process(inputPath + File.separator + "controllers/algo/rusefi_enums.h");
|
process(inputPath + File.separator + "controllers/algo/rusefi_enums.h");
|
||||||
|
|
||||||
header.append("#endif /*_A_H_HEADER_ */\r\n");
|
headerFileContent.append("#endif /*_A_H_HEADER_ */\r\n");
|
||||||
|
|
||||||
writeResult(outputPath + File.separator + "auto_generated_enums");
|
writeCppAndHeaderFiles(outputPath + File.separator + "auto_generated_enums");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeResult(String outFileName) throws IOException {
|
private static void writeCppAndHeaderFiles(String outFileName) throws IOException {
|
||||||
BufferedWriter bw = new BufferedWriter(new FileWriter(outFileName + ".cpp"));
|
BufferedWriter bw = new BufferedWriter(new FileWriter(outFileName + ".cpp"));
|
||||||
bw.write(result.toString());
|
bw.write(cppFileContent.toString());
|
||||||
bw.close();
|
bw.close();
|
||||||
|
|
||||||
bw = new BufferedWriter(new FileWriter(outFileName + ".h"));
|
bw = new BufferedWriter(new FileWriter(outFileName + ".h"));
|
||||||
bw.write(header.toString());
|
bw.write(headerFileContent.toString());
|
||||||
bw.close();
|
bw.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +55,9 @@ public class EnumToString {
|
||||||
"\r\n" +
|
"\r\n" +
|
||||||
"\r\n" +
|
"\r\n" +
|
||||||
"\r\n";
|
"\r\n";
|
||||||
result.append(header);
|
|
||||||
EnumToString.header.append(header);
|
cppFileContent.append(header);
|
||||||
|
EnumToString.headerFileContent.insert(0, header);
|
||||||
|
|
||||||
boolean isInsideEnum = false;
|
boolean isInsideEnum = false;
|
||||||
|
|
||||||
|
@ -65,9 +65,9 @@ public class EnumToString {
|
||||||
System.out.println("Reading from " + inFileName);
|
System.out.println("Reading from " + inFileName);
|
||||||
String simpleFileName = f.getName();
|
String simpleFileName = f.getName();
|
||||||
|
|
||||||
result.append("#include \"global.h\"\r\n");
|
cppFileContent.append("#include \"global.h\"\r\n");
|
||||||
result.append("#include \"" + simpleFileName + "\"\r\n");
|
cppFileContent.append("#include \"" + simpleFileName + "\"\r\n");
|
||||||
EnumToString.header.append("#include \"" + simpleFileName + "\"\r\n");
|
EnumToString.headerFileContent.append("#include \"" + simpleFileName + "\"\r\n");
|
||||||
|
|
||||||
reader = new BufferedReader(new FileReader(inFileName));
|
reader = new BufferedReader(new FileReader(inFileName));
|
||||||
String line;
|
String line;
|
||||||
|
@ -82,12 +82,12 @@ public class EnumToString {
|
||||||
isInsideEnum = false;
|
isInsideEnum = false;
|
||||||
line = line.substring(1, line.length() - 1);
|
line = line.substring(1, line.length() - 1);
|
||||||
System.out.println("Ending enum " + line);
|
System.out.println("Ending enum " + line);
|
||||||
result.append(makeCode(line));
|
cppFileContent.append(makeCode(line));
|
||||||
EnumToString.header.append(getMethodSignature(line) + ";\r\n");
|
EnumToString.headerFileContent.append(getMethodSignature(line) + ";\r\n");
|
||||||
} else {
|
} else {
|
||||||
line = line.replaceAll("//.+", "");
|
line = line.replaceAll("//.+", "");
|
||||||
if (isInsideEnum) {
|
if (isInsideEnum) {
|
||||||
if (line.matches("[a-zA-Z_$][a-zA-Z\\d_$]*[\\=a-zA-Z\\d_*]*,?")) {
|
if (line.matches("[a-zA-Z_$][a-zA-Z\\d_$]*[=a-zA-Z\\d_*]*,?")) {
|
||||||
line = line.replace(",", "");
|
line = line.replace(",", "");
|
||||||
int index = line.indexOf('=');
|
int index = line.indexOf('=');
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
package com.rusefi;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* (c) Andrey Belomutskiy
|
|
||||||
* 10/6/14
|
|
||||||
*/
|
|
||||||
public enum State {
|
|
||||||
ENUM
|
|
||||||
}
|
|
Loading…
Reference in New Issue