From 44cebe183fc13d6ced4c2eed155aa03909a542f4 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 25 Dec 2015 22:14:44 +0000 Subject: MirLua: minor fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@15942 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_hotkeys.cpp | 12 +++++------- plugins/MirLua/src/m_icolib.cpp | 8 ++++++-- plugins/MirLua/src/m_sounds.cpp | 16 +++++++--------- plugins/MirLua/src/mlua_metatable.h | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) (limited to 'plugins/MirLua/src') diff --git a/plugins/MirLua/src/m_hotkeys.cpp b/plugins/MirLua/src/m_hotkeys.cpp index e998b04a9a..2c71f28273 100644 --- a/plugins/MirLua/src/m_hotkeys.cpp +++ b/plugins/MirLua/src/m_hotkeys.cpp @@ -55,19 +55,18 @@ static int lua_Register(lua_State *L) MakeHotkey(L, hk); INT_PTR res = ::CallService("CoreHotkeys/Register", (WPARAM)hScriptsLangpack, (LPARAM)&hk); - lua_pushinteger(L, res); + lua_pushboolean(L, res); return 1; } static int lua_Unregister(lua_State *L) { - const char* name = luaL_checkstring(L, 1); + const char *name = luaL_checkstring(L, 1); - INT_PTR res = ::CallService("CoreHotkeys/Unregister", 0, (LPARAM)name); - lua_pushinteger(L, res); + ::CallService("CoreHotkeys/Unregister", 0, (LPARAM)name); - return 1; + return 0; } static int lua_MakeHotkey(lua_State *L) @@ -83,11 +82,10 @@ static int lua_MakeHotkey(lua_State *L) static luaL_Reg hotkeysApi[] = { + { "MakeHotkey", lua_MakeHotkey }, { "Register", lua_Register }, { "Unregister", lua_Unregister }, - { "MakeHotkey", lua_MakeHotkey }, - { NULL, NULL } }; diff --git a/plugins/MirLua/src/m_icolib.cpp b/plugins/MirLua/src/m_icolib.cpp index 733fab90e0..eea44838d4 100644 --- a/plugins/MirLua/src/m_icolib.cpp +++ b/plugins/MirLua/src/m_icolib.cpp @@ -5,9 +5,13 @@ static int lua_AddIcon(lua_State *L) const char *name = luaL_checkstring(L, 1); ptrT description(mir_utf8decodeT(luaL_checkstring(L, 2))); ptrT section(mir_utf8decodeT(luaL_optstring(L, 3, MODULE))); + ptrT filePath(mir_utf8decodeT(lua_tostring(L, 4))); - TCHAR filePath[MAX_PATH]; - GetModuleFileName(g_hInstance, filePath, _countof(filePath)); + if (filePath == NULL) + { + filePath = (TCHAR*)mir_calloc(MAX_PATH + 1); + GetModuleFileName(g_hInstance, filePath, MAX_PATH); + } SKINICONDESC si = { 0 }; si.flags = SIDF_ALL_TCHAR; diff --git a/plugins/MirLua/src/m_sounds.cpp b/plugins/MirLua/src/m_sounds.cpp index 8630c53093..de2a82c23f 100644 --- a/plugins/MirLua/src/m_sounds.cpp +++ b/plugins/MirLua/src/m_sounds.cpp @@ -5,9 +5,7 @@ static int lua_AddSound(lua_State *L) ptrA name(mir_utf8decodeA(luaL_checkstring(L, 1))); ptrT description(mir_utf8decodeT(luaL_checkstring(L, 2))); ptrT section(mir_utf8decodeT(luaL_optstring(L, 3, MODULE))); - - TCHAR filePath[MAX_PATH]; - GetModuleFileName(g_hInstance, filePath, _countof(filePath)); + ptrT filePath(mir_utf8decodeT(lua_tostring(L, 4))); SKINSOUNDDESCEX ssd = { sizeof(SKINSOUNDDESCEX) }; ssd.pszName = name; @@ -17,7 +15,7 @@ static int lua_AddSound(lua_State *L) ssd.ptszDefaultFile = filePath; INT_PTR res = ::CallService("Skin/Sounds/AddNew", hLangpack, (LPARAM)&ssd); - lua_pushnumber(L, res); + lua_pushboolean(L, res == 0); return 1; } @@ -26,18 +24,18 @@ static int lua_PlaySound(lua_State *L) { const char *name = luaL_checkstring(L, 1); - INT_PTR res = SkinPlaySound(name); - lua_pushnumber(L, res); + INT_PTR res = ::SkinPlaySound(name); + lua_pushboolean(L, res == 0); return 1; } static int lua_PlayFile(lua_State *L) { - const char *path = luaL_checkstring(L, 1); + ptrT filePath(mir_utf8decodeT(luaL_checkstring(L, 1))); - INT_PTR res = SkinPlaySoundFile(ptrT(mir_utf8decodeT(path))); - lua_pushnumber(L, res); + INT_PTR res = ::SkinPlaySoundFile(filePath); + lua_pushboolean(L, res == 0); return 1; } diff --git a/plugins/MirLua/src/mlua_metatable.h b/plugins/MirLua/src/mlua_metatable.h index f2143d5f27..df42f2dca9 100644 --- a/plugins/MirLua/src/mlua_metatable.h +++ b/plugins/MirLua/src/mlua_metatable.h @@ -101,7 +101,7 @@ private: static int lua__gc(lua_State *L) { - T* obj = (T*)luaL_checkudata(L, 1, MT::name); + T *obj = (T*)luaL_checkudata(L, 1, MT::name); MT::Free(&obj); return 0; } -- cgit v1.2.3