summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-07-18 19:43:12 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-07-18 19:43:12 +0000
commit059a7ea5928d49d81ed1d884e59c60f152983539 (patch)
tree8d4065bfa11f5cba5714d131842108c6a1286922 /plugins/MirLua/src
parent952154728cfc9a390f9f7b2e3326ea32d76e0003 (diff)
MirLua:
- removed OnScriptLoaded/OnScriptUnload - removed second script path - module loading and options refactoring - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@14587 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src')
-rw-r--r--plugins/MirLua/src/m_core.cpp3
-rw-r--r--plugins/MirLua/src/main.cpp11
-rw-r--r--plugins/MirLua/src/mlua.cpp70
-rw-r--r--plugins/MirLua/src/mlua.h16
-rw-r--r--plugins/MirLua/src/mlua_options.cpp83
-rw-r--r--plugins/MirLua/src/mlua_options.h1
-rw-r--r--plugins/MirLua/src/mlua_script.cpp98
-rw-r--r--plugins/MirLua/src/mlua_script.h30
-rw-r--r--plugins/MirLua/src/mlua_script_loader.cpp71
-rw-r--r--plugins/MirLua/src/mlua_script_loader.h9
-rw-r--r--plugins/MirLua/src/stdafx.h9
-rw-r--r--plugins/MirLua/src/version.h4
12 files changed, 200 insertions, 205 deletions
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp
index 7fcbe1c2f5..e3972df3d4 100644
--- a/plugins/MirLua/src/m_core.cpp
+++ b/plugins/MirLua/src/m_core.cpp
@@ -225,9 +225,6 @@ luaL_Reg coreApi[] =
{ "Translate", lua_Translate },
{ "ReplaceVariables", lua_ReplaceVariables },
- { "OnScriptLoaded", CMLua::OnScriptLoaded },
- { "OnScriptUnload", CMLua::OnScriptUnload },
-
{ "NULL", NULL },
{ "INVALID_HANDLE_VALUE", NULL },
diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp
index b90eeb97b2..2ec8920988 100644
--- a/plugins/MirLua/src/main.cpp
+++ b/plugins/MirLua/src/main.cpp
@@ -5,12 +5,11 @@ int hScriptsLangpack;
HINSTANCE g_hInstance;
-HANDLE g_hCommonFolderPath;
-HANDLE g_hCustomFolderPath;
+CMLua *g_mLua;
-HANDLE hNetlib = NULL;
+HANDLE g_hCommonScriptFolder;
-CMLua *g_mLua;
+HANDLE hNetlib = NULL;
PLUGININFOEX pluginInfo =
{
@@ -42,10 +41,10 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
int OnModulesLoaded(WPARAM, LPARAM)
{
- g_hCommonFolderPath = FoldersRegisterCustomPathT(MODULE, Translate("Common scripts folder"), COMMON_SCRIPTS_PATHT);
- g_hCustomFolderPath = FoldersRegisterCustomPathT(MODULE, Translate("Custom scripts folder"), CUSTOM_SCRIPTS_PATHT);
+ g_hCommonScriptFolder = FoldersRegisterCustomPathT(MODULE, Translate("Common scripts folder"), COMMON_SCRIPTS_PATHT);
g_mLua = new CMLua();
+ g_mLua->Load();
HookEvent(ME_OPT_INITIALISE, CLuaOptions::OnOptionsInit);
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp
index c1dd847be4..21a24e055c 100644
--- a/plugins/MirLua/src/mlua.cpp
+++ b/plugins/MirLua/src/mlua.cpp
@@ -6,12 +6,13 @@ LIST<void> CMLua::Services(1, PtrKeySortT);
LIST<void> CMLua::HookRefs(1, HandleKeySortT);
LIST<void> CMLua::ServiceRefs(1, HandleKeySortT);
-CMLua::CMLua() : L(NULL)
+static int CompareScripts(const CMLuaScript* p1, const CMLuaScript* p2)
{
- hLoadedEvent = CreateHookableEvent("Lua/Script/Loaded");
- hUnloadEvent = CreateHookableEvent("Lua/Script/Unload");
+ return mir_strcmpi(p1->GetModuleName(), p2->GetModuleName());
+}
- Load();
+CMLua::CMLua() : L(NULL), Scripts(10, CompareScripts)
+{
}
CMLua::~CMLua()
@@ -50,15 +51,19 @@ void CMLua::Load()
CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)"Loading miranda modules");
CLuaModuleLoader::Load(L);
CLuaScriptLoader::Load(L);
-
- NotifyEventHooks(hLoadedEvent);
}
void CMLua::Unload()
{
CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)"Unloading lua engine");
- NotifyEventHooks(hUnloadEvent);
+ while (int last = Scripts.getCount())
+ {
+ CMLuaScript* script = g_mLua->Scripts[last - 1];
+ Scripts.remove(script);
+ script->Unload();
+ delete script;
+ }
::KillModuleIcons(hScriptsLangpack);
::KillModuleMenus(hScriptsLangpack);
@@ -70,17 +75,6 @@ void CMLua::Unload()
lua_close(L);
}
-void CMLua::Reload()
-{
- Unload();
- Load();
-}
-
-void CMLua::Reload(const TCHAR* path)
-{
- CLuaScriptLoader::Reload(g_mLua->L, path);
-}
-
void CMLua::KillModuleEventHooks()
{
while (Hooks.getCount())
@@ -130,46 +124,6 @@ void CMLua::KillModuleServices()
}
}
-int CMLua::OnScriptLoaded(lua_State *L)
-{
- if (!lua_isfunction(L, 1))
- {
- lua_pushlightuserdata(L, NULL);
- return 1;
- }
-
- lua_pushvalue(L, 1);
- int ref = luaL_ref(L, LUA_REGISTRYINDEX);
-
- HANDLE res = ::HookEventObjParam("Lua/Script/Loaded", CMLua::HookEventObjParam, L, ref);
- lua_pushlightuserdata(L, res);
-
- Hooks.insert(res);
- HookRefs.insert(new HandleRefParam(L, res, ref));
-
- return 1;
-}
-
-int CMLua::OnScriptUnload(lua_State *L)
-{
- if (!lua_isfunction(L, 1))
- {
- lua_pushlightuserdata(L, NULL);
- return 1;
- }
-
- lua_pushvalue(L, 1);
- int ref = luaL_ref(L, LUA_REGISTRYINDEX);
-
- HANDLE res = ::HookEventObjParam("Lua/Script/Unload", CMLua::HookEventObjParam, L, ref);
- lua_pushlightuserdata(L, res);
-
- Hooks.insert(res);
- HookRefs.insert(new HandleRefParam(L, res, ref));
-
- return 1;
-}
-
int CMLua::HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param)
{
lua_State *L = (lua_State*)obj;
diff --git a/plugins/MirLua/src/mlua.h b/plugins/MirLua/src/mlua.h
index 28fcff5b45..d73d88f7e0 100644
--- a/plugins/MirLua/src/mlua.h
+++ b/plugins/MirLua/src/mlua.h
@@ -14,14 +14,11 @@ class CMLua
{
private:
lua_State *L;
- HANDLE hLoadedEvent;
- HANDLE hUnloadEvent;
static void KillModuleEventHooks();
static void KillModuleServices();
-
- void Load();
- void Unload();
+
+
public:
static LIST<void> Hooks;
@@ -30,14 +27,13 @@ public:
static LIST<void> HookRefs;
static LIST<void> ServiceRefs;
+ LIST<CMLuaScript> Scripts;
+
CMLua();
~CMLua();
- void Reload();
- void Reload(const TCHAR* path);
-
- static int OnScriptLoaded(lua_State *L);
- static int OnScriptUnload(lua_State *L);
+ void Load();
+ void Unload();
static int HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param);
};
diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp
index caca892e48..5a08fedd7f 100644
--- a/plugins/MirLua/src/mlua_options.cpp
+++ b/plugins/MirLua/src/mlua_options.cpp
@@ -48,60 +48,41 @@ int CLuaOptions::OnOptionsInit(WPARAM wParam, LPARAM)
return 0;
}
-void CLuaOptions::LoadScripts(const TCHAR *scriptDir, int iGroup)
+void CLuaOptions::LoadScripts()
{
- TCHAR searchMask[MAX_PATH];
- mir_sntprintf(searchMask, _T("%s\\%s"), scriptDir, _T("*.lua"));
-
- WIN32_FIND_DATA fd;
- HANDLE hFind = FindFirstFile(searchMask, &fd);
- if (hFind != INVALID_HANDLE_VALUE)
+ for (int i = 0; i < g_mLua->Scripts.getCount(); i++)
{
- do
- {
- if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- int iItem = m_scripts.AddItem(fd.cFileName, -1, NULL, iGroup);
- if (db_get_b(NULL, MODULE, _T2A(fd.cFileName), 1))
- m_scripts.SetCheckState(iItem, TRUE);
- m_scripts.SetItem(iItem, 1, _T(""), 0);
- m_scripts.SetItem(iItem, 2, _T(""), 1);
- }
- } while (FindNextFile(hFind, &fd));
- FindClose(hFind);
+ CMLuaScript* script = g_mLua->Scripts[i];
+ TCHAR* fileName = NEWTSTR_ALLOCA(script->GetFileName());
+ int iItem = m_scripts.AddItem(fileName, -1, (LPARAM)script, script->GetGroup());
+ if (db_get_b(NULL, MODULE, _T2A(fileName), 1))
+ m_scripts.SetCheckState(iItem, TRUE);
+ m_scripts.SetItem(iItem, 1, _T(""), 0);
+ m_scripts.SetItem(iItem, 2, _T(""), 1);
}
}
-void CLuaOptions::LoadScripts()
-{
- TCHAR scriptDir[MAX_PATH], relativeScriptDir[MAX_PATH], header[MAX_PATH + 100];
- FoldersGetCustomPathT(g_hCommonFolderPath, scriptDir, _countof(scriptDir), VARST(COMMON_SCRIPTS_PATHT));
- PathToRelativeT(scriptDir, relativeScriptDir, NULL);
- mir_sntprintf(header, _T("%s (%s)"), TranslateT("Common scripts"), relativeScriptDir);
- m_scripts.AddGroup(0, header);
- LoadScripts(scriptDir, 0);
-
- FoldersGetCustomPathT(g_hCustomFolderPath, scriptDir, _countof(scriptDir), VARST(CUSTOM_SCRIPTS_PATHT));
- PathToRelativeT(scriptDir, relativeScriptDir, NULL);
- mir_sntprintf(header, _T("%s (%s)"), TranslateT("Custom scripts"), relativeScriptDir);
- m_scripts.AddGroup(1, header);
- LoadScripts(scriptDir, 1);
-}
-
void CLuaOptions::OnInitDialog()
{
CDlgBase::OnInitDialog();
m_scripts.SetExtendedListViewStyle(LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_INFOTIP);
- m_scripts.EnableGroupView(TRUE);
- m_scripts.AddColumn(0, _T("Script"), 420);
- m_scripts.AddColumn(1, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL));
- m_scripts.AddColumn(2, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL));
HIMAGELIST hImageList = m_scripts.CreateImageList(LVSIL_SMALL);
ImageList_AddIcon(hImageList, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_OPEN)));
ImageList_AddIcon(hImageList, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_RELOAD)));
+ TCHAR scriptDir[MAX_PATH], relativeScriptDir[MAX_PATH], header[MAX_PATH + 100];
+ FoldersGetCustomPathT(g_hCommonScriptFolder, scriptDir, _countof(scriptDir), VARST(COMMON_SCRIPTS_PATHT));
+ PathToRelativeT(scriptDir, relativeScriptDir, NULL);
+ mir_sntprintf(header, _T("%s (%s)"), TranslateT("Common scripts"), relativeScriptDir);
+ m_scripts.AddGroup(0, header);
+ m_scripts.EnableGroupView(TRUE);
+
+ m_scripts.AddColumn(0, _T("Script"), 420);
+ m_scripts.AddColumn(1, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL));
+ m_scripts.AddColumn(2, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL));
+
LoadScripts();
isScriptListInit = true;
@@ -151,27 +132,20 @@ void CLuaOptions::OnScriptListClick(CCtrlListView::TEventInfo *evt)
if (lvi.iItem == -1) return;
lvi.pszText = (LPTSTR)mir_calloc(MAX_PATH * sizeof(TCHAR));
lvi.cchTextMax = MAX_PATH;
- lvi.mask = LVIF_GROUPID | LVIF_TEXT;
+ lvi.mask = LVIF_GROUPID | LVIF_TEXT | LVIF_PARAM;
evt->treeviewctrl->GetItem(&lvi);
lvi.iSubItem = evt->nmlvia->iSubItem;
+
+ CMLuaScript* script = (CMLuaScript*)lvi.lParam;
+
if (lvi.iSubItem == 1)
{
- TCHAR path[MAX_PATH];
- if (lvi.iGroupId == 0)
- FoldersGetCustomPathT(g_hCommonFolderPath, path, _countof(path), VARST(COMMON_SCRIPTS_PATHT));
- else
- FoldersGetCustomPathT(g_hCustomFolderPath, path, _countof(path), VARST(CUSTOM_SCRIPTS_PATHT));
- ShellExecute(m_hwnd, NULL, lvi.pszText, NULL, path, SW_SHOWNORMAL);
+ ShellExecute(m_hwnd, NULL, lvi.pszText, NULL, script->GetFilePath(), SW_SHOWNORMAL);
}
else if (lvi.iSubItem == 2)
{
- TCHAR path[MAX_PATH];
- if (lvi.iGroupId == 0)
- FoldersGetCustomPathT(g_hCommonFolderPath, path, _countof(path), VARST(COMMON_SCRIPTS_PATHT));
- else
- FoldersGetCustomPathT(g_hCustomFolderPath, path, _countof(path), VARST(CUSTOM_SCRIPTS_PATHT));
- mir_sntprintf(path, _T("%s\\%s"), path, lvi.pszText);
- g_mLua->Reload(path);
+ script->Unload();
+ script->Load();
}
mir_free(lvi.pszText);
}
@@ -180,7 +154,8 @@ void CLuaOptions::OnReload(CCtrlBase*)
{
isScriptListInit = false;
m_scripts.DeleteAllItems();
+ g_mLua->Unload();
+ g_mLua->Load();
LoadScripts();
isScriptListInit = true;
- g_mLua->Reload();
} \ No newline at end of file
diff --git a/plugins/MirLua/src/mlua_options.h b/plugins/MirLua/src/mlua_options.h
index f6fd0db164..25bf442ed1 100644
--- a/plugins/MirLua/src/mlua_options.h
+++ b/plugins/MirLua/src/mlua_options.h
@@ -23,7 +23,6 @@ private:
CCtrlScriptList m_scripts;
CCtrlButton m_reload;
- void LoadScripts(const TCHAR *scriptDir, int iGroup = -1);
void LoadScripts();
protected:
diff --git a/plugins/MirLua/src/mlua_script.cpp b/plugins/MirLua/src/mlua_script.cpp
new file mode 100644
index 0000000000..aa181a3a22
--- /dev/null
+++ b/plugins/MirLua/src/mlua_script.cpp
@@ -0,0 +1,98 @@
+#include "stdafx.h"
+
+CMLuaScript::CMLuaScript(lua_State *L, const TCHAR* path, int iGroup) : L(L)
+{
+ mir_tstrcpy(filePath, path);
+
+ group = iGroup;
+
+ fileName = _tcsrchr(filePath, '\\') + 1;
+ size_t length = mir_tstrlen(fileName) - 3;
+
+ ptrT name((TCHAR*)mir_calloc(sizeof(TCHAR) * length));
+ mir_tstrncpy(name, fileName, mir_tstrlen(fileName) - 3);
+
+ moduleName = mir_utf8encodeT(name);
+}
+
+CMLuaScript::~CMLuaScript()
+{
+ mir_free(this->moduleName);
+}
+
+const char* CMLuaScript::GetModuleName() const
+{
+ return moduleName;
+}
+
+const TCHAR* CMLuaScript::GetFilePath() const
+{
+ return filePath;
+}
+
+const TCHAR* CMLuaScript::GetFileName() const
+{
+ return fileName;
+}
+
+const int CMLuaScript::GetGroup() const
+{
+ return group;
+}
+
+bool CMLuaScript::Load()
+{
+ if (luaL_loadfile(L, T2Utf(filePath)))
+ {
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ return false;
+ }
+
+ if (lua_pcall(L, 0, 1, 0))
+ {
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ return false;
+ }
+
+ isLoaded = true;
+
+ if (!lua_istable(L, -1))
+ return true;
+
+ lua_pushliteral(L, "Load");
+ lua_gettable(L, -2);
+ if (lua_isfunction(L, -1) && lua_pcall(L, 0, 0, 0))
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ lua_pop(L, 1);
+
+ lua_pushliteral(L, "Unload");
+ lua_gettable(L, -2);
+ if (lua_isfunction(L, -1))
+ {
+ lua_pushvalue(L, -1);
+ unloadRef = luaL_ref(L, LUA_REGISTRYINDEX);
+ }
+ lua_pop(L, 1);
+
+ return true;
+}
+
+void CMLuaScript::Unload()
+{
+ if (isLoaded)
+ {
+ lua_rawgeti(L, LUA_REGISTRYINDEX, unloadRef);
+ if (lua_pcall(L, 0, 0, 0))
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ luaL_unref(L, LUA_REGISTRYINDEX, unloadRef);
+ isLoaded = false;
+ }
+
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
+ lua_pushnil(L);
+ lua_setfield(L, -2, moduleName);
+ lua_pop(L, 1);
+
+ lua_pushnil(L);
+ lua_setglobal(L, moduleName);
+} \ No newline at end of file
diff --git a/plugins/MirLua/src/mlua_script.h b/plugins/MirLua/src/mlua_script.h
new file mode 100644
index 0000000000..0b299112b7
--- /dev/null
+++ b/plugins/MirLua/src/mlua_script.h
@@ -0,0 +1,30 @@
+#ifndef _LUA_SCRIPT_H_
+#define _LUA_SCRIPT_H_
+
+class CMLuaScript
+{
+private:
+ lua_State *L;
+
+ char* moduleName;
+ TCHAR* fileName;
+ TCHAR filePath[MAX_PATH];
+ bool isLoaded;
+ int group;
+ int unloadRef;
+
+public:
+ CMLuaScript(lua_State *L, const TCHAR* path, int iGroup = 0);
+ ~CMLuaScript();
+
+ const char* GetModuleName() const;
+
+ const TCHAR* GetFilePath() const;
+ const TCHAR* GetFileName() const;
+ const int GetGroup() const;
+
+ bool Load();
+ void Unload();
+};
+
+#endif //_LUA_SCRIPT_H_
diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp
index 3a25345c93..bdcca3c9f4 100644
--- a/plugins/MirLua/src/mlua_script_loader.cpp
+++ b/plugins/MirLua/src/mlua_script_loader.cpp
@@ -18,35 +18,20 @@ void CLuaScriptLoader::RegisterScriptsFolder(const char *path)
lua_pop(L, 1);
}
-void CLuaScriptLoader::LoadScript(const TCHAR *path)
+void CLuaScriptLoader::LoadScript(const TCHAR *path, int iGroup)
{
-
- if (luaL_loadfile(L, T2Utf(path)))
- {
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
- return;
- }
-
- if (lua_pcall(L, 0, 1, 0))
- {
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
- return;
- }
-
- TCHAR buf[4096];
- mir_sntprintf(buf, _T("%s:OK"), path);
- CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)buf);
+ CMLuaScript *script = new CMLuaScript(L, path, 0);
+ g_mLua->Scripts.insert(script);
- if (lua_istable(L, -1))
+ if (script->Load())
{
- lua_pushliteral(L, "Load");
- lua_gettable(L, -2);
- if (lua_isfunction(L, -1) && lua_pcall(L, 0, 0, 0))
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ TCHAR buf[4096];
+ mir_sntprintf(buf, _T("%s:OK"), path);
+ CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)buf);
}
}
-void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir)
+void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir, int iGroup)
{
TCHAR buf[4096];
mir_sntprintf(buf, _T("Loading scripts from %s"), scriptDir);
@@ -70,52 +55,18 @@ void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir)
mir_sntprintf(fullPath, _T("%s\\%s"), scriptDir, fd.cFileName);
PathToRelativeT(fullPath, path);
if (db_get_b(NULL, MODULE, _T2A(fd.cFileName), 1))
- LoadScript(fullPath);
+ LoadScript(fullPath, iGroup);
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
}
-void CLuaScriptLoader::UnloadScript(const TCHAR *path)
-{
- const TCHAR* p = _tcsrchr(path, '\\') + 1;
- size_t length = mir_tstrlen(p) - 3;
-
- ptrT name((TCHAR*)mir_alloc(sizeof(TCHAR) * length));
- mir_tstrncpy(name, p, length);
-
- T2Utf moduleName(name);
-
- luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
- lua_pushnil(L);
- lua_setfield(L, -2, moduleName);
- lua_pop(L, 1);
-
- lua_pushnil(L);
- lua_setglobal(L, moduleName);
-}
-
-void CLuaScriptLoader::ReloadScript(const TCHAR *path)
-{
- UnloadScript(path);
- LoadScript(path);
-}
-
void CLuaScriptLoader::Load(lua_State *L)
{
TCHAR scriptDir[MAX_PATH];
CLuaScriptLoader loader(L);
- FoldersGetCustomPathT(g_hCommonFolderPath, scriptDir, _countof(scriptDir), VARST(COMMON_SCRIPTS_PATHT));
- loader.LoadScripts(scriptDir);
-
- FoldersGetCustomPathT(g_hCustomFolderPath, scriptDir, _countof(scriptDir), VARST(CUSTOM_SCRIPTS_PATHT));
- loader.LoadScripts(scriptDir);
-}
-
-void CLuaScriptLoader::Reload(lua_State *L, const TCHAR *path)
-{
- CLuaScriptLoader loader(L);
- loader.ReloadScript(path);
+ FoldersGetCustomPathT(g_hCommonScriptFolder, scriptDir, _countof(scriptDir), VARST(COMMON_SCRIPTS_PATHT));
+ loader.LoadScripts(scriptDir, 0);
} \ No newline at end of file
diff --git a/plugins/MirLua/src/mlua_script_loader.h b/plugins/MirLua/src/mlua_script_loader.h
index 0d229053d3..7088706387 100644
--- a/plugins/MirLua/src/mlua_script_loader.h
+++ b/plugins/MirLua/src/mlua_script_loader.h
@@ -11,16 +11,11 @@ private:
void RegisterScriptsFolder(const char *path);
- void LoadScript(const TCHAR *path);
- void LoadScripts(const TCHAR *scriptDir);
-
- void UnloadScript(const TCHAR *path);
-
- void ReloadScript(const TCHAR *path);
+ void LoadScript(const TCHAR *path, int iGroup);
+ void LoadScripts(const TCHAR *scriptDir, int iGroup);
public:
static void Load(lua_State *L);
- static void Reload(lua_State *L, const TCHAR* path);
};
#endif //_LUA_SCRIPT_LOADER_H_ \ No newline at end of file
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h
index d43437e64c..96175e0ff0 100644
--- a/plugins/MirLua/src/stdafx.h
+++ b/plugins/MirLua/src/stdafx.h
@@ -3,6 +3,7 @@
#include <windows.h>
#include <commctrl.h>
+#include <malloc.h>
#include <newpluginapi.h>
#include <m_core.h>
@@ -35,7 +36,10 @@ extern "C"
#include "version.h"
#include "resource.h"
+class CMLuaScript;
+
#include "mlua.h"
+#include "mlua_script.h"
#include "mlua_module_loader.h"
#include "mlua_script_loader.h"
#include "mlua_options.h"
@@ -48,17 +52,14 @@ extern int hScriptsLangpack;
extern HINSTANCE g_hInstance;
-extern HANDLE g_hCommonFolderPath;
-extern HANDLE g_hCustomFolderPath;
+extern HANDLE g_hCommonScriptFolder;
extern HANDLE hNetlib;
#ifdef _UNICODE
#define COMMON_SCRIPTS_PATHT MIRANDA_PATHW L"\\Scripts"
- #define CUSTOM_SCRIPTS_PATHT MIRANDA_USERDATAW L"\\Scripts"
#else
#define COMMON_SCRIPTS_PATHT MIRANDA_PATH "\\Scripts"
- #define CUSTOM_SCRIPTS_PATHT MIRANDA_USERDATA "\\Scripts"
#endif
#define MLUA_CORE "m"
diff --git a/plugins/MirLua/src/version.h b/plugins/MirLua/src/version.h
index 6dd15f8c9f..48f4e6cac3 100644
--- a/plugins/MirLua/src/version.h
+++ b/plugins/MirLua/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
-#define __RELEASE_NUM 3
-#define __BUILD_NUM 6
+#define __RELEASE_NUM 4
+#define __BUILD_NUM 0
#include <stdver.h>