diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-06-30 21:37:39 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-06-30 21:37:39 +0000 |
commit | 5c89906040b2ea1f307f3e337655a9429b858207 (patch) | |
tree | bda0c674c82f26b154de6a063d0124d6c8906619 | |
parent | ce1c33a2c65a605929c5fcc7c075c76c3b27ea68 (diff) |
MirLua: common code moved to m_core.h
git-svn-id: http://svn.miranda-ng.org/main/trunk@14465 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/MirLua/src/m_core.cpp | 19 | ||||
-rw-r--r-- | plugins/MirLua/src/m_core.h | 26 | ||||
-rw-r--r-- | plugins/MirLua/src/m_genmenu.h | 2 | ||||
-rw-r--r-- | plugins/MirLua/src/m_msg_buttonsbar.cpp | 11 | ||||
-rw-r--r-- | plugins/MirLua/src/m_toptoolbar.cpp | 3 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua.cpp | 6 | ||||
-rw-r--r-- | plugins/MirLua/src/stdafx.h | 3 |
7 files changed, 42 insertions, 28 deletions
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp index b022c013d6..41adff71fc 100644 --- a/plugins/MirLua/src/m_core.cpp +++ b/plugins/MirLua/src/m_core.cpp @@ -1,21 +1,6 @@ #include "stdafx.h"
-static LIST<void> Hooks(1, PtrKeySortT);
-static LIST<void> Events(1, PtrKeySortT);
-static LIST<void> Services(1, PtrKeySortT);
-
-struct HandleRefParam
-{
- HANDLE h;
- int ref;
- lua_State *L;
- HandleRefParam(HANDLE h) : L(NULL), h(h), ref(0) { }
- HandleRefParam(lua_State *L, HANDLE h, int ref = 0) : L(L), h(h), ref(ref) { }
-};
-static LIST<void> HookRefs(1, HandleKeySortT);
-static LIST<void> ServiceRefs(1, HandleKeySortT);
-
-void CMLua::KillModuleEventHooks()
+void KillModuleEventHooks()
{
while (Hooks.getCount())
{
@@ -43,7 +28,7 @@ void CMLua::KillModuleEventHooks() }
}
-void CMLua::KillModuleServices()
+void KillModuleServices()
{
while (Services.getCount())
{
diff --git a/plugins/MirLua/src/m_core.h b/plugins/MirLua/src/m_core.h new file mode 100644 index 0000000000..8313c3383d --- /dev/null +++ b/plugins/MirLua/src/m_core.h @@ -0,0 +1,26 @@ +#ifndef _LUA_M_CORE_H_
+#define _LUA_M_CORE_H_
+
+#define MLUA_CORE "m"
+LUAMOD_API int (luaopen_m)(lua_State *L);
+
+static LIST<void> Hooks(1, PtrKeySortT);
+static LIST<void> Events(1, PtrKeySortT);
+static LIST<void> Services(1, PtrKeySortT);
+
+struct HandleRefParam
+{
+ HANDLE h;
+ int ref;
+ lua_State *L;
+ HandleRefParam(HANDLE h) : L(NULL), h(h), ref(0) { }
+ HandleRefParam(lua_State *L, HANDLE h, int ref = 0) : L(L), h(h), ref(ref) { }
+};
+
+static LIST<void> HookRefs(1, HandleKeySortT);
+static LIST<void> ServiceRefs(1, HandleKeySortT);
+
+void KillModuleEventHooks();
+void KillModuleServices();
+
+#endif //_LUA_M_CORE_H_
\ No newline at end of file diff --git a/plugins/MirLua/src/m_genmenu.h b/plugins/MirLua/src/m_genmenu.h index 69ddff6215..ecb04092e1 100644 --- a/plugins/MirLua/src/m_genmenu.h +++ b/plugins/MirLua/src/m_genmenu.h @@ -6,4 +6,4 @@ LUAMOD_API int (luaopen_m_genmenu)(lua_State *L); void MakeMenuItem(lua_State *L, CMenuItem &mi);
-#endif //_LUA_CONSOLE_H_
\ No newline at end of file +#endif //_LUA_M_GENMENU_H_
\ No newline at end of file diff --git a/plugins/MirLua/src/m_msg_buttonsbar.cpp b/plugins/MirLua/src/m_msg_buttonsbar.cpp index 4d969fdfa6..a570fdd620 100644 --- a/plugins/MirLua/src/m_msg_buttonsbar.cpp +++ b/plugins/MirLua/src/m_msg_buttonsbar.cpp @@ -67,9 +67,6 @@ static int lua_ModifyButton(lua_State *L) INT_PTR res = ::CallService(MS_BB_MODIFYBUTTON, 0, (LPARAM)bbb);
lua_pushinteger(L, res);
- mir_free(bbb->pszModuleName);
- mir_free(bbb->ptszTooltip);
-
return 1;
}
@@ -101,6 +98,9 @@ static int lua_OnMsgToolBarLoaded(lua_State *L) HANDLE res = ::HookEventObjParam(ME_MSG_TOOLBARLOADED, CMLua::HookEventObjParam, L, ref);
lua_pushlightuserdata(L, res);
+ Hooks.insert(res);
+ HookRefs.insert(new HandleRefParam(L, res, ref));
+
return 1;
}
@@ -134,8 +134,6 @@ int ButtonPressedHookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPAR int res = (int)lua_tointeger(L, 1);
- //luaL_unref(L, LUA_REGISTRYINDEX, ref);
-
return res;
}
@@ -153,6 +151,9 @@ static int lua_OnMsgToolBarButtonPressed(lua_State *L) HANDLE res = ::HookEventObjParam(ME_MSG_BUTTONPRESSED, ButtonPressedHookEventObjParam, L, ref);
lua_pushlightuserdata(L, res);
+ Hooks.insert(res);
+ HookRefs.insert(new HandleRefParam(L, res, ref));
+
return 1;
}
diff --git a/plugins/MirLua/src/m_toptoolbar.cpp b/plugins/MirLua/src/m_toptoolbar.cpp index 4e96f645e5..3e26f962dc 100644 --- a/plugins/MirLua/src/m_toptoolbar.cpp +++ b/plugins/MirLua/src/m_toptoolbar.cpp @@ -104,6 +104,9 @@ static int lua_OnTopToolBarLoaded(lua_State *L) HANDLE res = ::HookEventObjParam(ME_TTB_MODULELOADED, CMLua::HookEventObjParam, L, ref);
lua_pushlightuserdata(L, res);
+ Hooks.insert(res);
+ HookRefs.insert(new HandleRefParam(L, res, ref));
+
return 1;
}
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index 90c5e302c6..3d0d7f6106 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -41,9 +41,9 @@ void CMLua::Unload() {
mir_writeLogT(hLogger, _T("Unloading lua engine\n"));
- KillModuleMenus(hScriptsLangpack);
- KillModuleServices();
- KillModuleEventHooks();
+ ::KillModuleMenus(hScriptsLangpack);
+ ::KillModuleServices();
+ ::KillModuleEventHooks();
//KillModuleSubclassing
if (L)
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 6c1f2ad98e..5c2cedb63e 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -59,8 +59,7 @@ extern HANDLE g_hCustomFolderPath; #define CUSTOM_SCRIPTS_PATHT MIRANDA_USERDATA "\\Scripts"
#endif
-#define MLUA_CORE "m"
-LUAMOD_API int (luaopen_m)(lua_State *L);
+#include "m_core.h"
#define MLUA_CLIST "m_clist"
LUAMOD_API int (luaopen_m_clist)(lua_State *L);
|