diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-07-18 19:43:12 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-07-18 19:43:12 +0000 |
commit | 059a7ea5928d49d81ed1d884e59c60f152983539 (patch) | |
tree | 8d4065bfa11f5cba5714d131842108c6a1286922 /plugins/MirLua/src/mlua.cpp | |
parent | 952154728cfc9a390f9f7b2e3326ea32d76e0003 (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/mlua.cpp')
-rw-r--r-- | plugins/MirLua/src/mlua.cpp | 70 |
1 files changed, 12 insertions, 58 deletions
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;
|