diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-11-26 21:25:02 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-11-26 21:25:02 +0000 |
commit | 0960adf65f1702aa10210dacb6d60f61f23c416d (patch) | |
tree | aae03d88f0329832eed5a67f492e6de3f1913547 /plugins | |
parent | 7e78bc7d9b3530c999898dc56de668ac8a466102 (diff) |
MirLua: cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@15781 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/MirLua/src/m_core.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp index 133dfb119f..ee611886a2 100644 --- a/plugins/MirLua/src/m_core.cpp +++ b/plugins/MirLua/src/m_core.cpp @@ -151,45 +151,48 @@ static int lua_CreateServiceFunction(lua_State *L) return 1;
}
-static int lua_DestroyServiceFunction(lua_State *L)
+static int lua_CallService(lua_State *L)
{
- HANDLE hService = lua_touserdata(L, 1);
-
- HandleRefParam *param = (HandleRefParam*)CMLua::ServiceRefs.find(hService);
- if (param != NULL)
- {
- luaL_unref(param->L, LUA_REGISTRYINDEX, param->ref);
- CMLua::ServiceRefs.remove(param);
- delete param;
- }
+ const char *name = luaL_checkstring(L, 1);
+ WPARAM wParam = luaM_towparam(L, 2);
+ LPARAM lParam = luaM_tolparam(L, 3);
- ::DestroyServiceFunction(hService);
+ INT_PTR res = CallService(name, wParam, lParam);
+ lua_pushinteger(L, res);
- return 0;
+ return 1;
}
static int lua_ServiceExists(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
- int res = ::ServiceExists(name);
+ int res = ServiceExists(name);
lua_pushboolean(L, res);
return 1;
}
-static int lua_CallService(lua_State *L)
+static int lua_DestroyServiceFunction(lua_State *L)
{
- const char *name = luaL_checkstring(L, 1);
- WPARAM wParam = luaM_towparam(L, 2);
- LPARAM lParam = luaM_tolparam(L, 3);
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+ HANDLE hService = lua_touserdata(L, 1);
- INT_PTR res = ::CallService(name, wParam, lParam);
- lua_pushinteger(L, res);
+ HandleRefParam *param = (HandleRefParam*)CMLua::ServiceRefs.find(hService);
+ if (param != NULL)
+ {
+ luaL_unref(param->L, LUA_REGISTRYINDEX, param->ref);
+ CMLua::ServiceRefs.remove(param);
+ delete param;
+ }
- return 1;
+ DestroyServiceFunction(hService);
+
+ return 0;
}
+/***********************************************/
+
static int lua_IsPluginLoaded(lua_State *L)
{
const char *value = lua_tostring(L, 1);
|