From 8be4814cca3be42be785da6a366f3da978a4ab72 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Mon, 22 Jun 2015 09:01:42 +0000 Subject: MirLua: refactoring git-svn-id: http://svn.miranda-ng.org/main/trunk@14321 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua_module_loader.cpp | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 plugins/MirLua/src/mlua_module_loader.cpp (limited to 'plugins/MirLua/src/mlua_module_loader.cpp') diff --git a/plugins/MirLua/src/mlua_module_loader.cpp b/plugins/MirLua/src/mlua_module_loader.cpp new file mode 100644 index 0000000000..f25b69abde --- /dev/null +++ b/plugins/MirLua/src/mlua_module_loader.cpp @@ -0,0 +1,33 @@ +#include "stdafx.h" + +CLuaModuleLoader::CLuaModuleLoader(lua_State *L) : L(L) +{ +} + +void CLuaModuleLoader::PreloadModule(const char *name, lua_CFunction loader) +{ + luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); + lua_pushcfunction(L, loader); + lua_setfield(L, -2, name); + lua_pop(L, 1); +} + +void CLuaModuleLoader::LoadModules() +{ + // load core module + luaopen_m(L); + // regirter delay loading of miranda modules + PreloadModule(MLUA_DATABASE, luaopen_m_database); + PreloadModule(MLUA_ICOLIB, luaopen_m_icolib); + PreloadModule(MLUA_GENMENU, luaopen_m_genmenu); + PreloadModule(MLUA_MSGBUTTONSBAR, luaopen_m_msg_buttonsbar); + PreloadModule(MLUA_POPUP, luaopen_m_popup); + PreloadModule(MLUA_TOPTOOLBAR, luaopen_m_toptoolbar); + PreloadModule(MLUA_VARIABLES, luaopen_m_variables); +} + +void CLuaModuleLoader::Load(lua_State *L) +{ + CLuaModuleLoader loader(L); + loader.LoadModules(); +} \ No newline at end of file -- cgit v1.2.3