diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-10-21 18:29:50 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-10-21 18:29:50 +0000 |
commit | c99bbd2ef7f9fb2295ff2ec07bb690c4d7351a71 (patch) | |
tree | a760bc80000499732a80034d32bdd02cb3e9b885 /plugins/MirLua/src/m_core.cpp | |
parent | dd4878e302ae384f7b51b9ef60ff3a06dbd11a11 (diff) |
MirLua:
- added totable to cast userdata to metatable
- all modules hooks are marked as obsolete
- version bumb
git-svn-id: http://svn.miranda-ng.org/main/trunk@15586 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_core.cpp')
-rw-r--r-- | plugins/MirLua/src/m_core.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp index 6a5b4cb2d0..b2f6beda2a 100644 --- a/plugins/MirLua/src/m_core.cpp +++ b/plugins/MirLua/src/m_core.cpp @@ -36,6 +36,23 @@ static int lua_NotifyEventHooks(lua_State *L) return 1;
}
+int HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param)
+{
+ lua_State *L = (lua_State*)obj;
+
+ int ref = param;
+ lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
+
+ lua_pushlightuserdata(L, (void*)wParam);
+ lua_pushlightuserdata(L, (void*)lParam);
+ if (lua_pcall(L, 2, 1, 0))
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+
+ int res = (int)lua_tointeger(L, 1);
+
+ return res;
+}
+
static int lua_HookEvent(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
@@ -49,7 +66,7 @@ static int lua_HookEvent(lua_State *L) lua_pushvalue(L, 2);
int ref = luaL_ref(L, LUA_REGISTRYINDEX);
- HANDLE res = ::HookEventObjParam(name, CMLua::HookEventObjParam, L, ref);
+ HANDLE res = ::HookEventObjParam(name, HookEventObjParam, L, ref);
lua_pushlightuserdata(L, res);
CMLua::Hooks.insert(res);
@@ -78,15 +95,15 @@ static int lua_UnhookEvent(lua_State *L) return 1;
}
-static INT_PTR ServiceFunctionObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param)
+INT_PTR CreateServiceFunctionObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param)
{
lua_State *L = (lua_State*)obj;
int ref = param;
lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
- lua_pushnumber(L, wParam);
- lua_pushnumber(L, lParam);
+ lua_pushlightuserdata(L, (void*)wParam);
+ lua_pushlightuserdata(L, (void*)lParam);
if (lua_pcall(L, 2, 1, 0))
CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
@@ -109,7 +126,7 @@ static int lua_CreateServiceFunction(lua_State *L) lua_pushvalue(L, 2);
int ref = luaL_ref(L, LUA_REGISTRYINDEX);
- HANDLE res = ::CreateServiceFunctionObjParam(name, ServiceFunctionObjParam, L, ref);
+ HANDLE res = ::CreateServiceFunctionObjParam(name, CreateServiceFunctionObjParam, L, ref);
lua_pushlightuserdata(L, res);
CMLua::Services.insert(res);
|