summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/m_core.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-06-23 14:47:00 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-06-23 14:47:00 +0000
commit1a02247a7b6913b45bf81331c3e0ab9a374d04e8 (patch)
treecc23d6a8341c2af946fc4dd73b75d089e50c822b /plugins/MirLua/src/m_core.cpp
parent50b6a5ca2c5652fdf4e5fab69d9918c0f633cfb5 (diff)
MirLua: fix previous commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@17024 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_core.cpp')
-rw-r--r--plugins/MirLua/src/m_core.cpp26
1 files changed, 4 insertions, 22 deletions
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp
index 8d388bf8c7..1b4bc8d390 100644
--- a/plugins/MirLua/src/m_core.cpp
+++ b/plugins/MirLua/src/m_core.cpp
@@ -18,7 +18,7 @@ static int core_CreateHookableEvent(lua_State *L)
int HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param)
{
- lua_State *L = (lua_State*)obj;
+ lua_State *L = lua_newthread((lua_State*)obj);
int ref = param;
lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
@@ -46,9 +46,7 @@ static int core_HookEvent(lua_State *L)
lua_pushvalue(L, 2);
int ref = luaL_ref(L, LUA_REGISTRYINDEX);
- lua_State *T = lua_newthread(L);
-
- HANDLE hEvent = HookEventObjParam(name, HookEventObjParam, T, ref);
+ HANDLE hEvent = HookEventObjParam(name, HookEventObjParam, g_mLua, ref);
if (hEvent == NULL)
{
luaL_unref(L, LUA_REGISTRYINDEX, ref);
@@ -57,9 +55,6 @@ static int core_HookEvent(lua_State *L)
return 1;
}
- lua_rawsetp(L, LUA_REGISTRYINDEX, hEvent);
- lua_pushlightuserdata(L, hEvent);
-
return 1;
}
@@ -69,11 +64,6 @@ static int core_UnhookEvent(lua_State *L)
HANDLE hEvent = lua_touserdata(L, 1);
int res = UnhookEvent(hEvent);
- if (!res)
- {
- lua_pushnil(L);
- lua_rawsetp(L, LUA_REGISTRYINDEX, hEvent);
- }
lua_pushboolean(L, !res);
return 1;
@@ -107,7 +97,7 @@ static int core_DestroyHookableEvent(lua_State *L)
INT_PTR CreateServiceFunctionObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param)
{
- lua_State *L = (lua_State*)obj;
+ lua_State *L = lua_newthread((lua_State*)obj);
int ref = param;
lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
@@ -130,9 +120,7 @@ static int core_CreateServiceFunction(lua_State *L)
lua_pushvalue(L, 2);
int ref = luaL_ref(L, LUA_REGISTRYINDEX);
- lua_State *T = lua_newthread(L);
-
- HANDLE hService = CreateServiceFunctionObjParam(name, CreateServiceFunctionObjParam, T, ref);
+ HANDLE hService = CreateServiceFunctionObjParam(name, CreateServiceFunctionObjParam, g_mLua, ref);
if (!hService)
{
luaL_unref(L, LUA_REGISTRYINDEX, ref);
@@ -140,9 +128,6 @@ static int core_CreateServiceFunction(lua_State *L)
return 1;
}
- lua_rawsetp(L, LUA_REGISTRYINDEX, hService);
- lua_pushlightuserdata(L, hService);
-
return 1;
}
@@ -175,9 +160,6 @@ static int core_DestroyServiceFunction(lua_State *L)
DestroyServiceFunction(hService);
- lua_pushnil(L);
- lua_rawsetp(L, LUA_REGISTRYINDEX, hService);
-
return 0;
}