generate java enum from C enum? generate both C and java from yaml? #2102

This commit is contained in:
rusefillc 2021-10-23 23:00:04 -04:00
parent 94bfeec588
commit c45003060c
7 changed files with 167 additions and 7 deletions

View File

@ -1,6 +1,6 @@
#include "global.h"
#include "engine_types.h"
// was generated automatically by rusEFI tool from engine_types.h // by enum2string.jar tool on Sat Oct 23 22:03:36 EDT 2021
// was generated automatically by rusEFI tool from engine_types.h // by enum2string.jar tool on Sat Oct 23 22:57:34 EDT 2021
// see also gen_config_and_enums.bat
@ -49,6 +49,10 @@ case HELLEN_121_NISSAN_4_CYL:
return "HELLEN_121_NISSAN_4_CYL";
case HELLEN_121_NISSAN_6_CYL:
return "HELLEN_121_NISSAN_6_CYL";
case HELLEN_121_NISSAN_8_CYL:
return "HELLEN_121_NISSAN_8_CYL";
case HELLEN_121_NISSAN_ALMERA_N16:
return "HELLEN_121_NISSAN_ALMERA_N16";
case HELLEN_121_VAG:
return "HELLEN_121_VAG";
case HELLEN_121_VAG_5_CYL:
@ -83,6 +87,8 @@ case HELLEN_NA94:
return "HELLEN_NA94";
case HELLEN_NB1:
return "HELLEN_NB1";
case HELLEN_NB1_36:
return "HELLEN_NB1_36";
case HELLEN_NB2:
return "HELLEN_NB2";
case HELLEN_NB2_36:
@ -199,6 +205,20 @@ case TOYOTA_2JZ_GTE_VVTi:
return "TOYOTA_2JZ_GTE_VVTi";
case TOYOTA_JZS147:
return "TOYOTA_JZS147";
case UNUSED10:
return "UNUSED10";
case UNUSED25:
return "UNUSED25";
case UNUSED5:
return "UNUSED5";
case UNUSED96:
return "UNUSED96";
case UNUSED97:
return "UNUSED97";
case UNUSED98:
return "UNUSED98";
case UNUSED99:
return "UNUSED99";
case UNUSED_48:
return "UNUSED_48";
case UNUSED_50:

View File

@ -25,6 +25,7 @@ typedef enum {
* http://rusefi.com/forum/viewtopic.php?t=375
*/
FORD_ASPIRE_1996 = ET_FORD_ASPIRE,
UNUSED5 = 4,
NISSAN_PRIMERA = ET_NISSAN_PRIMERA,
UNUSED_6 = 6,
@ -38,6 +39,7 @@ typedef enum {
MIATA_PROTEUS_TCU = ET_MIATA_TCU_PROTEUS,
MAZDA_MIATA_NB1 = 9,
UNUSED10 = 10,
MRE_MIATA_NB2_MAP = ET_MRE_MIATA_NB2_MAP,
MRE_MIATA_NA6_VAF = ET_MRE_MIATA_NA6_VAF,
MRE_MIATA_NB2_ETB = 13,
@ -72,6 +74,7 @@ typedef enum {
MRE_BODY_CONTROL = ET_MRE_BODY_CONTROL,
BMW_M73_M = 24,
UNUSED25 = 25,
TEST_ENGINE = 26,
// used by unit test
@ -191,8 +194,12 @@ typedef enum {
// 84
HELLEN_121_NISSAN_4_CYL = ET_HELLEN_121_NISSAN_4_CYL,
HELLEN_121_NISSAN_8_CYL = 85,
HELLEN_NB2_36 = ET_HELLEN_NB2_36,
HELLEN_121_NISSAN_ALMERA_N16 = 87,
HELLEN_128_MERCEDES_6_CYL = ET_HELLEN_128_MERCEDES_6_CYL,
HELLEN_128_MERCEDES_8_CYL = ET_HELLEN_128_MERCEDES_8_CYL,
@ -205,8 +212,14 @@ typedef enum {
PROTEUS_N73 = ET_PROTEUS_N73,
HELLEN_NB1_36 = 94,
HELLEN_154_HYUNDAI_COUPE_BK2 = ET_HELLEN_154_HYUNDAI_COUPE_BK2,
UNUSED96 = 96,
UNUSED97 = 97,
UNUSED98 = 98,
UNUSED99 = 99,
/**
* this configuration has as few pins configured as possible

View File

@ -17,11 +17,6 @@ extern "C"
{
#endif /* __cplusplus */
// Back in the day we wanted enums to be 32 bit integers.
// as of 2020 preference is with ' __attribute__ ((__packed__))' allowing one-byte enums
#define ENUM_16_BITS 60000
#define ENUM_32_BITS 2000000000
typedef enum {
//P0001 Fuel Volume Regulator Control Circuit/Open
//P0002 Fuel Volume Regulator Control Circuit Range/Performance
@ -2127,8 +2122,10 @@ typedef enum {
// Back in the day we wanted enums to be 32 bit integers.
// as of 2020 preference is with ' __attribute__ ((__packed__))' allowing one-byte enums
// this is needed for proper enum size, this matters for malfunction_central
Internal_ForceMyEnumIntSize_cranking_obd_code = ENUM_32_BITS,
Internal_ForceMyEnumIntSize_cranking_obd_code = 2000000000,
} obd_code_e;
#ifdef __cplusplus

View File

@ -75,6 +75,11 @@ struct_no_prefix engine_configuration_s
! see 'blockingFactor' in rusefi.ini
#define BLOCKING_FACTOR 256
// Back in the day we wanted enums to be 32 bit integers.
// as of 2020 preference is with ' __attribute__ ((__packed__))' allowing one-byte enums
#define ENUM_16_BITS 60000
#define ENUM_32_BITS 2000000000
#define AUX_ANALOG_INPUT_COUNT 8
#define FSIO_ANALOG_INPUT_COUNT 4

View File

@ -0,0 +1,119 @@
package com.rusefi.enums;
//auto-generated by ToJavaEnum.java
public enum engine_type_e {
DEFAULT_FRANKENSO,
MIATA_PROTEUS_TCU,
DODGE_NEON_1995,
FORD_ASPIRE_1996,
UNUSED5,
NISSAN_PRIMERA,
UNUSED_6,
FORD_INLINE_6_1995,
GY6_139QMB,
MAZDA_MIATA_NB1,
UNUSED10,
MRE_MIATA_NB2_MAP,
MRE_MIATA_NA6_VAF,
MRE_MIATA_NB2_ETB,
FORD_ESCORT_GT,
MRE_MIATA_NB2_MAF,
MITSU_4G93,
HONDA_ACCORD_CD_TWO_WIRES,
HONDA_ACCORD_CD_DIP,
MIATA_1990,
MRE_MIATA_94_MAP,
MIATA_1996,
SUBARU_2003_WRX,
MRE_BODY_CONTROL,
BMW_M73_M,
UNUSED25,
TEST_ENGINE,
TEST_ISSUE_898,
MAZDA_626,
SACHS,
MRE_BOARD_OLD_TEST,
MRE_BOARD_NEW_TEST,
VW_ABA,
HELLEN72_ETB,
HELLEN_NA6,
CAMARO_4,
HELLEN_128_MERCEDES_4_CYL,
MRE_SUBARU_EJ18,
TOYOTA_JZS147,
LADA_KALINA,
BMW_M73_F,
MIATA_NA6_MAP,
PROTEUS_QC_TEST_BOARD,
HONDA_600,
TOYOTA_2JZ_GTE_VVTi,
TEST_ENGINE_VVT,
DODGE_NEON_2003_CRANK,
MAZDA_MIATA_2003,
UNUSED_48,
FRANKENSO_QA_ENGINE,
UNUSED_50,
UNUSED_51,
TEST_ISSUE_366_BOTH,
TEST_ISSUE_366_RISE,
MAZDA_MIATA_2003_NA_RAIL,
MAZDA_MIATA_2003_BOARD_TEST,
MAZDA_MIATA_NA8,
MIATA_NA6_VAF,
ETB_BENCH_ENGINE,
TLE8888_BENCH_ENGINE,
MICRO_RUS_EFI,
PROTEUS_DEFAULTS,
VW_B6,
BMW_M73_PROTEUS,
DODGE_RAM,
CITROEN_TU3JP,
MRE_MIATA_NA6_MAP,
PROTEUS_MIATA_NB2,
MRE_M111,
HELLEN_NB2,
SUBARUEG33_DEFAULTS,
HELLEN_121_VAG,
HELLEN_121_NISSAN_6_CYL,
HELLEN_55_BMW,
HELLEN_88_BMW,
HELLEN_134_BMW,
HELLEN_154_VAG,
HELLEN_121_VAG_5_CYL,
HELLEN_121_VAG_V6_CYL,
HELLEN_121_VAG_VR6_CYL,
HELLEN_NA94,
HELLEN_121_VAG_8_CYL,
HELLEN_154_HYUNDAI_COUPE_BK1,
HELLEN_NB1,
HELLEN_121_NISSAN_4_CYL,
HELLEN_121_NISSAN_8_CYL,
HELLEN_NB2_36,
HELLEN_121_NISSAN_ALMERA_N16,
HELLEN_128_MERCEDES_6_CYL,
HELLEN_128_MERCEDES_8_CYL,
PROTEUS_HONDA_ELEMENT_2003,
PROTEUS_HONDA_OBD2A,
PROTEUS_VAG_80_18T,
PROTEUS_N73,
HELLEN_NB1_36,
HELLEN_154_HYUNDAI_COUPE_BK2,
UNUSED96,
UNUSED97,
UNUSED98,
MINIMAL_PINS,
PROMETHEUS_DEFAULTS,
SUBARUEJ20G_DEFAULTS,
VAG_18_TURBO,
TEST_33816,
BMW_M73_MRE,
BMW_M73_MRE_SLAVE,
PROTEUS_ANALOG_PWM_TEST,
TEST_ROTARY,
TEST_108,
TEST_109,
TEST_110,
Force_4_bytes_size_engine_type,
}

View File

@ -13,6 +13,9 @@ public class EnumsReader {
protected final Map<String, EnumState> enums = new TreeMap<>();
/**
* core implementation sorts by name, we need special considerations to sort by value
*/
@NotNull
static List<Value> getSortedByOrder(VariableRegistry registry, Map<String, Value> brain_pin_e) {
Set<Value> byOrdinal = new TreeSet<>(Comparator.comparingInt(value -> value.getIntValueMaybeResolve(registry)));

View File

@ -2,6 +2,8 @@ package com.rusefi.enum_reader;
import com.rusefi.VariableRegistry;
import java.util.Objects;
public class Value implements Comparable<Value> {
private final String name;
private final String value;
@ -41,6 +43,7 @@ public class Value implements Comparable<Value> {
return getIntValue();
} catch (NumberFormatException e) {
String resolvedValue = registry.get(value);
Objects.requireNonNull(resolvedValue, value);
return Integer.parseInt(resolvedValue);
}
}