refatoring: splitting lua hooks into multiple files

This commit is contained in:
Andrey 2021-11-02 23:27:48 -04:00
parent 0678690515
commit e4a872c251
4 changed files with 40 additions and 9 deletions

View File

@ -3,6 +3,7 @@ LUA_EXT=$(PROJECT_DIR)/ext/lua
ALLCPPSRC += $(LUA_DIR)/lua.cpp \
$(LUA_DIR)/lua_hooks.cpp \
$(LUA_DIR)/lua_hooks_util.cpp \
$(LUA_DIR)/system_lua.cpp \
$(LUA_DIR)/lua_can_rx.cpp \

View File

@ -10,19 +10,12 @@
#include "settings.h"
#include <new>
#include "luaaa.hpp"
#include "lua_hooks_util.h"
using namespace luaaa;
// Some functions lean on existing FSIO implementation
#include "fsio_impl.h"
static int lua_efi_print(lua_State* l) {
auto msg = luaL_checkstring(l, 1);
efiPrintf("LUA: %s", msg);
return 0;
}
static int lua_readpin(lua_State* l) {
auto msg = luaL_checkstring(l, 1);
#if EFI_PROD_CODE
@ -388,7 +381,8 @@ void configureRusefiLuaHooks(lua_State* l) {
.fun("set", &LuaSensor::set)
.fun("invalidate", &LuaSensor::invalidate);
lua_register(l, "print", lua_efi_print);
configureRusefiLuaUtilHooks(l);
lua_register(l, "readPin", lua_readpin);
lua_register(l, "getAuxAnalog", lua_getAuxAnalog);
lua_register(l, "getSensorByIndex", lua_getSensorByIndex);

View File

@ -0,0 +1,23 @@
/*
* lua_hooks_util.cpp
*
* Created on: Nov 2, 2021
* Author: rusefi
*/
#include "pch.h"
#include "lua_hooks_util.h"
static int lua_efi_print(lua_State* l) {
auto msg = luaL_checkstring(l, 1);
efiPrintf("LUA: %s", msg);
return 0;
}
void configureRusefiLuaUtilHooks(lua_State* l) {
lua_register(l, "print", lua_efi_print);
}

View File

@ -0,0 +1,13 @@
/*
* lua_hooks_util.h
*
* Created on: Nov 2, 2021
* Author: rusefi
*/
#pragma once
#include "rusefi_lua.h"
void configureRusefiLuaUtilHooks(lua_State* l);