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.cpp | 60 +++++---------------------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) (limited to 'plugins/MirLua/src/mlua.cpp') diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index bf83c8f2c0..ccd843d5be 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -22,13 +22,10 @@ void CMLua::Load() lua_setfield(L, -2, "cpath"); lua_pop(L, 1); - LoadMirandaModules(); + hScriptsLangpack = GetPluginLangId(MIID_LAST, 0); - MUUID last = MIID_LAST; - hScriptsLangpack = GetPluginLangId(last, 0); - - CLuaLoader loader(this); - loader.LoadScripts(); + CLuaModuleLoader::Load(L); + CLuaScriptLoader::Load(L); } void CMLua::Unload() @@ -36,6 +33,9 @@ void CMLua::Unload() if (L) lua_close(L); KillModuleMenus(hScriptsLangpack); + //KillModuleSubclassing + //KillModuleServices + //KillModuleEventHooks } void CMLua::Reload() @@ -44,54 +44,6 @@ void CMLua::Reload() Load(); } -void CMLua::LoadModule(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 CMLua::LoadCoreModule() -{ - luaL_newlib(L, coreLib); - lua_pushlightuserdata(L, NULL); - lua_setfield(L, -2, "NULL"); - lua_setglobal(L, "m"); -} - -void CMLua::LoadMirandaModules() -{ - LoadCoreModule(); - - LoadModule(MLUA_DATABASE, luaopen_m_database); - LoadModule(MLUA_ICOLIB, luaopen_m_icolib); - LoadModule(MLUA_GENMENU, luaopen_m_genmenu); - LoadModule(MLUA_MSGBUTTONSBAR, luaopen_m_msg_buttonsbar); - LoadModule(MLUA_POPUP, luaopen_m_popup); - LoadModule(MLUA_TOPTOOLBAR, luaopen_m_toptoolbar); - LoadModule(MLUA_VARIABLES, luaopen_m_variables); -} - -void CMLua::AddScriptsPath(const char *path) -{ - lua_getglobal(L, "package"); - lua_getfield(L, -1, "path"); - const char *oldPath = luaL_checkstring(L, -1); - lua_pop(L, 1); - lua_pushfstring(L, "%s;%s\\?.lua", oldPath, path); - lua_setfield(L, -2, "path"); - lua_pop(L, 1); -} - -void CMLua::LoadScript(const char *path) -{ - if (luaL_dofile(L, path)) - printf("%s\n", lua_tostring(L, -1)); -} - - - int CMLua::HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param) { lua_State *L = (lua_State*)obj; -- cgit v1.2.3