diff options
-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);
|