diff options
Diffstat (limited to 'plugins/MirLua/src/m_genmenu.cpp')
-rw-r--r-- | plugins/MirLua/src/m_genmenu.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/MirLua/src/m_genmenu.cpp b/plugins/MirLua/src/m_genmenu.cpp index 64ff383ac6..8bad0c23c9 100644 --- a/plugins/MirLua/src/m_genmenu.cpp +++ b/plugins/MirLua/src/m_genmenu.cpp @@ -47,7 +47,7 @@ void MakeMenuItem(lua_State *L, CMenuItem &mi) static int lua_CreateRoot(lua_State *L)
{
- int hMenuObject = lua_tointeger(L, 1);
+ int hMenuObject = luaL_checkinteger(L, 1);
const char *name = luaL_checkstring(L, 2);
int position = lua_tointeger(L, 3);
HANDLE hIcon = (HANDLE)lua_touserdata(L, 4);
@@ -60,7 +60,7 @@ static int lua_CreateRoot(lua_State *L) static int lua_AddMenuItem(lua_State *L)
{
- int hMenuObject = lua_tointeger(L, 1);
+ int hMenuObject = luaL_checkinteger(L, 1);
if (lua_type(L, 2) != LUA_TTABLE)
{
@@ -71,7 +71,7 @@ static int lua_AddMenuItem(lua_State *L) CMenuItem mi;
MakeMenuItem(L, mi);
- HGENMENU res = ::Menu_AddItem(hMenuObject, &mi, NULL);
+ HGENMENU res = Menu_AddItem(hMenuObject, &mi, NULL);
lua_pushlightuserdata(L, res);
return 1;
@@ -79,6 +79,7 @@ static int lua_AddMenuItem(lua_State *L) static int lua_ModifyMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
ptrT name(mir_utf8decodeT(lua_tostring(L, 2)));
HANDLE hIcolibItem = lua_touserdata(L, 3);
@@ -87,47 +88,51 @@ static int lua_ModifyMenuItem(lua_State *L) if (!(flags & CMIF_UNICODE))
flags |= CMIF_UNICODE;
- INT_PTR res = ::Menu_ModifyItem(hMenuItem, name, hIcolibItem, flags);
+ INT_PTR res = Menu_ModifyItem(hMenuItem, name, hIcolibItem, flags);
lua_pushinteger(L, res);
return 1;
}
static int lua_ShowMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
bool isShow = luaM_toboolean(L, 2);
- ::Menu_ShowItem(hMenuItem, isShow);
+ Menu_ShowItem(hMenuItem, isShow);
return 0;
}
static int lua_EnableMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
bool isEnable = luaM_toboolean(L, 2);
- ::Menu_EnableItem(hMenuItem, isEnable);
+ Menu_EnableItem(hMenuItem, isEnable);
return 0;
}
static int lua_CheckMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
bool isChecked = luaM_toboolean(L, 2);
- ::Menu_SetChecked(hMenuItem, isChecked);
+ Menu_SetChecked(hMenuItem, isChecked);
return 0;
}
static int lua_RemoveMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
- INT_PTR res = ::Menu_RemoveItem(hMenuItem);
- lua_pushinteger(L, res);
+ INT_PTR res = Menu_RemoveItem(hMenuItem);
+ lua_pushboolean(L, res == 0);
return 1;
}
|