diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-06-22 09:01:42 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-06-22 09:01:42 +0000 |
commit | 8be4814cca3be42be785da6a366f3da978a4ab72 (patch) | |
tree | 2f21fb9ec763c8e7ca6eb16e09aaf7191868a0b1 /plugins/MirLua/src/mlua_module_loader.cpp | |
parent | 655ac8423ddf001b8d3021e41e7297d7e3e20510 (diff) |
MirLua: refactoring
git-svn-id: http://svn.miranda-ng.org/main/trunk@14321 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/mlua_module_loader.cpp')
-rw-r--r-- | plugins/MirLua/src/mlua_module_loader.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
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 |