summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-06-11 23:58:14 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-06-11 23:58:14 +0000
commit6d73d5c2980507e6823bb629aa2ce8d410989b8a (patch)
tree1b15e0c75428aae45b66e822e91990ce0130e561
parentc5ea3df8b269339e1f6ff91fc6bb0c838e0e10bb (diff)
MirLua: fast fix for CallService and NotifyEventHooks
git-svn-id: http://svn.miranda-ng.org/main/trunk@14131 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/MirLua/src/m_core.cpp92
-rw-r--r--plugins/MirLua/src/m_database.cpp3
2 files changed, 89 insertions, 6 deletions
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp
index 892d66dc2a..24ce45f13b 100644
--- a/plugins/MirLua/src/m_core.cpp
+++ b/plugins/MirLua/src/m_core.cpp
@@ -23,8 +23,50 @@ static int lua_DestroyHookableEvent(lua_State *L)
static int lua_NotifyEventHooks(lua_State *L)
{
HANDLE hEvent = (HANDLE)lua_touserdata(L, 1);
- WPARAM wParam = (WPARAM)lua_topointer(L, 2);
- LPARAM lParam = (LPARAM)lua_topointer(L, 3);
+
+ WPARAM wParam = NULL;
+ int type = lua_type(L, 2);
+ switch (type)
+ {
+ case LUA_TBOOLEAN:
+ wParam = lua_toboolean(L, 2);
+ break;
+ case LUA_TNUMBER:
+ wParam = lua_tonumber(L, 2);
+ break;
+ case LUA_TSTRING:
+ wParam = (WPARAM)lua_tostring(L, 2);
+ break;
+ case LUA_TUSERDATA:
+ wParam = (WPARAM)lua_touserdata(L, 2);
+ break;
+
+ default:
+ lua_pushinteger(L, 1);
+ return 1;
+ }
+
+ LPARAM lParam = NULL;
+ type = lua_type(L, 3);
+ switch (type)
+ {
+ case LUA_TBOOLEAN:
+ lParam = lua_toboolean(L, 3);
+ break;
+ case LUA_TNUMBER:
+ lParam = lua_tonumber(L, 3);
+ break;
+ case LUA_TSTRING:
+ lParam = (LPARAM)lua_tostring(L, 3);
+ break;
+ case LUA_TUSERDATA:
+ lParam = (LPARAM)lua_touserdata(L, 3);
+ break;
+
+ default:
+ lua_pushinteger(L, 1);
+ return 1;
+ }
int res = ::NotifyEventHooks(hEvent, wParam, lParam);
lua_pushinteger(L, res);
@@ -175,8 +217,50 @@ static int lua_ServiceExists(lua_State *L)
static int lua_CallService(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
- WPARAM wParam = (WPARAM)lua_topointer(L, 2);
- LPARAM lParam = (LPARAM)lua_topointer(L, 3);
+
+ WPARAM wParam = NULL;
+ int type = lua_type(L, 2);
+ switch (type)
+ {
+ case LUA_TBOOLEAN:
+ wParam = lua_toboolean(L, 2);
+ break;
+ case LUA_TNUMBER:
+ wParam = lua_tonumber(L, 2);
+ break;
+ case LUA_TSTRING:
+ wParam = (WPARAM)lua_tostring(L, 2);
+ break;
+ case LUA_TUSERDATA:
+ wParam = (WPARAM)lua_touserdata(L, 2);
+ break;
+
+ default:
+ lua_pushinteger(L, 1);
+ return 1;
+ }
+
+ LPARAM lParam = NULL;
+ type = lua_type(L, 3);
+ switch (type)
+ {
+ case LUA_TBOOLEAN:
+ lParam = lua_toboolean(L, 3);
+ break;
+ case LUA_TNUMBER:
+ lParam = lua_tonumber(L, 3);
+ break;
+ case LUA_TSTRING:
+ lParam = (LPARAM)lua_tostring(L, 3);
+ break;
+ case LUA_TUSERDATA:
+ lParam = (LPARAM)lua_touserdata(L, 3);
+ break;
+
+ default:
+ lua_pushinteger(L, 1);
+ return 1;
+ }
INT_PTR res = ::CallService(name, wParam, lParam);
lua_pushinteger(L, res);
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp
index e786eb86d3..91f7361e88 100644
--- a/plugins/MirLua/src/m_database.cpp
+++ b/plugins/MirLua/src/m_database.cpp
@@ -40,7 +40,7 @@ static int lua_WriteContactSetting(lua_State *L)
break;
default:
- lua_pushinteger(L, hContact);
+ lua_pushinteger(L, 1);
return 1;
}
@@ -62,7 +62,6 @@ static int lua_GetContactSetting(lua_State *L)
lua_pushnil(L);
return 1;
}
-
switch (dbv.type)
{