diff options
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 |