mirror of https://github.com/rusefi/rusefi-1.git
reduce flash footprint by smarter code generation #4163
This commit is contained in:
parent
4d3ed9bc59
commit
a1b6be5452
Binary file not shown.
|
@ -18,7 +18,8 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
||||||
private static final String CONFIG_ENGINE_CONFIGURATION = "config->engineConfiguration.";
|
private static final String CONFIG_ENGINE_CONFIGURATION = "config->engineConfiguration.";
|
||||||
private static final String ENGINE_CONFIGURATION = "engineConfiguration.";
|
private static final String ENGINE_CONFIGURATION = "engineConfiguration.";
|
||||||
static final String FILE_HEADER = "#include \"pch.h\"\n" +
|
static final String FILE_HEADER = "#include \"pch.h\"\n" +
|
||||||
"#include \"value_lookup.h\"\n" +
|
"#include \"value_lookup.h\"\n";
|
||||||
|
private static final String FIND_METHOD =
|
||||||
"plain_get_float_s * findFloat(const char *name) {\n" +
|
"plain_get_float_s * findFloat(const char *name) {\n" +
|
||||||
"\tplain_get_float_s *currentF = &getF_plain[0];\n" +
|
"\tplain_get_float_s *currentF = &getF_plain[0];\n" +
|
||||||
"\twhile (currentF < getF_plain + sizeof(getF_plain)/sizeof(getF_plain[0])) {\n" +
|
"\twhile (currentF < getF_plain + sizeof(getF_plain)/sizeof(getF_plain[0])) {\n" +
|
||||||
|
@ -127,6 +128,7 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
||||||
public String getHeaderAndGetter() {
|
public String getHeaderAndGetter() {
|
||||||
return FILE_HEADER +
|
return FILE_HEADER +
|
||||||
getFloatsSections() +
|
getFloatsSections() +
|
||||||
|
FIND_METHOD +
|
||||||
getComleteGetterBody();
|
getComleteGetterBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,14 @@ public class GetConfigValueConsumerTest {
|
||||||
|
|
||||||
assertEquals("#include \"pch.h\"\n" +
|
assertEquals("#include \"pch.h\"\n" +
|
||||||
"#include \"value_lookup.h\"\n" +
|
"#include \"value_lookup.h\"\n" +
|
||||||
|
"static plain_get_float_s getF_plain[] = {\n" +
|
||||||
|
"\t{\"clt.config.tempC_1\", &engineConfiguration->clt.config.tempC_1},\n" +
|
||||||
|
"\t{\"clt.config.map.sensor.highValue\", &engineConfiguration->clt.config.map.sensor.highValue},\n" +
|
||||||
|
"\t{\"clt.config.injector.flow\", &engineConfiguration->clt.config.injector.flow},\n" +
|
||||||
|
"\t{\"clt.config.bias_resistor\", &engineConfiguration->clt.config.bias_resistor},\n" +
|
||||||
|
"\t{\"afr_type\", &engineConfiguration->afr_type},\n" +
|
||||||
|
"};\n" +
|
||||||
|
"\n" +
|
||||||
"plain_get_float_s * findFloat(const char *name) {\n" +
|
"plain_get_float_s * findFloat(const char *name) {\n" +
|
||||||
"\tplain_get_float_s *currentF = &getF_plain[0];\n" +
|
"\tplain_get_float_s *currentF = &getF_plain[0];\n" +
|
||||||
"\twhile (currentF < getF_plain + sizeof(getF_plain)/sizeof(getF_plain[0])) {\n" +
|
"\twhile (currentF < getF_plain + sizeof(getF_plain)/sizeof(getF_plain[0])) {\n" +
|
||||||
|
@ -155,14 +163,6 @@ public class GetConfigValueConsumerTest {
|
||||||
"\t}\n" +
|
"\t}\n" +
|
||||||
"\treturn nullptr;\n" +
|
"\treturn nullptr;\n" +
|
||||||
"}\n" +
|
"}\n" +
|
||||||
"static plain_get_float_s getF_plain[] = {\n" +
|
|
||||||
"\t{\"clt.config.tempC_1\", &engineConfiguration->clt.config.tempC_1},\n" +
|
|
||||||
"\t{\"clt.config.map.sensor.highValue\", &engineConfiguration->clt.config.map.sensor.highValue},\n" +
|
|
||||||
"\t{\"clt.config.injector.flow\", &engineConfiguration->clt.config.injector.flow},\n" +
|
|
||||||
"\t{\"clt.config.bias_resistor\", &engineConfiguration->clt.config.bias_resistor},\n" +
|
|
||||||
"\t{\"afr_type\", &engineConfiguration->afr_type},\n" +
|
|
||||||
"};\n" +
|
|
||||||
"\n" +
|
|
||||||
"float getConfigValueByName(const char *name) {\n" +
|
"float getConfigValueByName(const char *name) {\n" +
|
||||||
"\t{\n" +
|
"\t{\n" +
|
||||||
"\t\tplain_get_float_s * known = findFloat(name);\n" +
|
"\t\tplain_get_float_s * known = findFloat(name);\n" +
|
||||||
|
|
Loading…
Reference in New Issue