reduce flash footprint by smarter code generation #4163
This commit is contained in:
parent
854baf09ea
commit
990d5f5d86
|
@ -36,12 +36,8 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
||||||
|
|
||||||
private static final String GET_METHOD_HEADER =
|
private static final String GET_METHOD_HEADER =
|
||||||
"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\tif (known != nullptr) {\n" +
|
|
||||||
"\t\t\treturn *(float*)hackEngineConfigurationPointer(known->value);\n" +
|
|
||||||
"\t\t}\n" +
|
|
||||||
"\t}\n"
|
|
||||||
;
|
;
|
||||||
|
|
||||||
static final String GET_METHOD_FOOTER = "\treturn EFI_ERROR_CODE;\n" + "}\n";
|
static final String GET_METHOD_FOOTER = "\treturn EFI_ERROR_CODE;\n" + "}\n";
|
||||||
|
@ -105,10 +101,11 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
||||||
javaName = "engineConfiguration->" + javaName.substring(CONFIG_ENGINE_CONFIGURATION.length());
|
javaName = "engineConfiguration->" + javaName.substring(CONFIG_ENGINE_CONFIGURATION.length());
|
||||||
|
|
||||||
|
|
||||||
|
getterPairs.add(new Pair<>(userName, javaName + cf.getName()));
|
||||||
|
|
||||||
if (TypesHelper.isFloat(cf.getType())) {
|
if (TypesHelper.isFloat(cf.getType())) {
|
||||||
allFloatAddresses.append("\t{" + quote(userName) + ", &engineConfiguration->" + userName + "},\n");
|
allFloatAddresses.append("\t{" + quote(userName) + ", &engineConfiguration->" + userName + "},\n");
|
||||||
} else {
|
} else {
|
||||||
getterPairs.add(new Pair<>(userName, javaName + cf.getName()));
|
|
||||||
|
|
||||||
setterBody.append(getCompareName(userName));
|
setterBody.append(getCompareName(userName));
|
||||||
String str = getAssignment(cf, javaName, "(int)");
|
String str = getAssignment(cf, javaName, "(int)");
|
||||||
|
|
|
@ -31,11 +31,6 @@ public class GetConfigValueConsumerTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"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\tif (known != nullptr) {\n" +
|
|
||||||
"\t\t\treturn *(float*)hackEngineConfigurationPointer(known->value);\n" +
|
|
||||||
"\t\t}\n" +
|
|
||||||
"\t}\n" +
|
|
||||||
"\treturn EFI_ERROR_CODE;\n" +
|
"\treturn EFI_ERROR_CODE;\n" +
|
||||||
"}\n", getConfigValueConsumer.getComleteGetterBody());
|
"}\n", getConfigValueConsumer.getComleteGetterBody());
|
||||||
}
|
}
|
||||||
|
@ -71,13 +66,10 @@ public class GetConfigValueConsumerTest {
|
||||||
|
|
||||||
assertEquals("float getConfigValueByName(const char *name) {\n" +
|
assertEquals("float getConfigValueByName(const char *name) {\n" +
|
||||||
"\t{\n" +
|
"\t{\n" +
|
||||||
"\t\tplain_get_float_s * known = findFloat(name);\n" +
|
|
||||||
"\t\tif (known != nullptr) {\n" +
|
|
||||||
"\t\t\treturn *(float*)hackEngineConfigurationPointer(known->value);\n" +
|
|
||||||
"\t\t}\n" +
|
|
||||||
"\t}\n" +
|
|
||||||
"\tint hash = djb2lowerCase(name);\n" +
|
"\tint hash = djb2lowerCase(name);\n" +
|
||||||
"\tswitch(hash) {\n" +
|
"\tswitch(hash) {\n" +
|
||||||
|
"\t\tcase -672272162:\n" +
|
||||||
|
"\t\t\treturn config->iat.config.tempC_1;\n" +
|
||||||
"\t\tcase -1237776078:\n" +
|
"\t\tcase -1237776078:\n" +
|
||||||
"\t\t\treturn config->iat.adcChannel;\n" +
|
"\t\t\treturn config->iat.adcChannel;\n" +
|
||||||
"\t}\n" +
|
"\t}\n" +
|
||||||
|
@ -162,21 +154,26 @@ public class GetConfigValueConsumerTest {
|
||||||
"}\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\tif (known != nullptr) {\n" +
|
|
||||||
"\t\t\treturn *(float*)hackEngineConfigurationPointer(known->value);\n" +
|
|
||||||
"\t\t}\n" +
|
|
||||||
"\t}\n" +
|
|
||||||
"\tint hash = djb2lowerCase(name);\n" +
|
"\tint hash = djb2lowerCase(name);\n" +
|
||||||
"\tswitch(hash) {\n" +
|
"\tswitch(hash) {\n" +
|
||||||
|
"\t\tcase -1832527325:\n" +
|
||||||
|
"\t\t\treturn config->clt.config.tempC_1;\n" +
|
||||||
|
"\t\tcase 1819278123:\n" +
|
||||||
|
"\t\t\treturn config->clt.config.map.sensor.highValue;\n" +
|
||||||
"\t\tcase 581685574:\n" +
|
"\t\tcase 581685574:\n" +
|
||||||
"\t\t\treturn config->clt.config.map.sensor.hwChannel;\n" +
|
"\t\t\treturn config->clt.config.map.sensor.hwChannel;\n" +
|
||||||
|
"\t\tcase 382574846:\n" +
|
||||||
|
"\t\t\treturn config->clt.config.injector.flow;\n" +
|
||||||
|
"\t\tcase -653172717:\n" +
|
||||||
|
"\t\t\treturn config->clt.config.bias_resistor;\n" +
|
||||||
"\t\tcase -1144186889:\n" +
|
"\t\tcase -1144186889:\n" +
|
||||||
"\t\t\treturn config->clt.adcChannel;\n" +
|
"\t\t\treturn config->clt.adcChannel;\n" +
|
||||||
"\t\tcase -1571463185:\n" +
|
"\t\tcase -1571463185:\n" +
|
||||||
"\t\t\treturn config->issue_294_31;\n" +
|
"\t\t\treturn config->issue_294_31;\n" +
|
||||||
"\t\tcase 727098956:\n" +
|
"\t\tcase 727098956:\n" +
|
||||||
"\t\t\treturn config->baseFuel;\n" +
|
"\t\t\treturn config->baseFuel;\n" +
|
||||||
|
"\t\tcase -1120008897:\n" +
|
||||||
|
"\t\t\treturn config->afr_type;\n" +
|
||||||
"\t\tcase -685727673:\n" +
|
"\t\tcase -685727673:\n" +
|
||||||
"\t\t\treturn config->speedToRpmRatio;\n" +
|
"\t\t\treturn config->speedToRpmRatio;\n" +
|
||||||
"\t\tcase 1694412179:\n" +
|
"\t\tcase 1694412179:\n" +
|
||||||
|
|
Loading…
Reference in New Issue