From aa87eb681c4856aa55fe02d9f8532b3f66cf831e Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 15 May 2022 17:47:14 -0400 Subject: [PATCH] reduce flash footprint by smarter code generation #4163 a bit of unit tests drama --- firmware/controllers/lua/lua_hooks_util.cpp | 11 ++++++++++- firmware/controllers/lua/value_lookup.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/firmware/controllers/lua/lua_hooks_util.cpp b/firmware/controllers/lua/lua_hooks_util.cpp index 55b49a01b1..c70bdc9136 100644 --- a/firmware/controllers/lua/lua_hooks_util.cpp +++ b/firmware/controllers/lua/lua_hooks_util.cpp @@ -51,4 +51,13 @@ void configureRusefiLuaUtilHooks(lua_State* l) { */ } - +void * hackEngineConfigurationPointer(void *ptr) { + // we know that 'engineConfiguration' was null at the time of initialization in unit tests +#if EFI_UNIT_TEST + intptr_t offset = (intptr_t)ptr; + void * valuePtr = (void *)engineConfiguration + offset; + return valuePtr; +#else + return ptr; +#endif +} diff --git a/firmware/controllers/lua/value_lookup.h b/firmware/controllers/lua/value_lookup.h index 0b50cd3ca5..94fd5152c6 100644 --- a/firmware/controllers/lua/value_lookup.h +++ b/firmware/controllers/lua/value_lookup.h @@ -27,3 +27,5 @@ plain_get_float_s * findFloat(const char *name); float getConfigValueByName(const char *name); void setConfigValueByName(const char *name, float value); float getOutputValueByName(const char *name); + +void * hackEngineConfigurationPointer(void *ptr);