diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-04-18 17:02:29 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-04-18 17:02:29 +0000 |
commit | 6409436d74e5831d362a4e4a102f4ed5527c4562 (patch) | |
tree | 876b696f9679a617fa64bec654cb55a9fa3ae884 /plugins/MirLua/src/mlua_utils.cpp | |
parent | cb07641dfb24d64306b3c473990622d0c653e567 (diff) |
MirLua: returned some lua types support as lparam/wparam
git-svn-id: http://svn.miranda-ng.org/main/trunk@16715 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/mlua_utils.cpp')
-rw-r--r-- | plugins/MirLua/src/mlua_utils.cpp | 81 |
1 files changed, 25 insertions, 56 deletions
diff --git a/plugins/MirLua/src/mlua_utils.cpp b/plugins/MirLua/src/mlua_utils.cpp index d5ca5ed0bb..94e5e41434 100644 --- a/plugins/MirLua/src/mlua_utils.cpp +++ b/plugins/MirLua/src/mlua_utils.cpp @@ -165,6 +165,31 @@ int luaM_tonumber(lua_State *L) return 1;
}
+UINT_PTR luaM_tomparam(lua_State *L, int idx)
+{
+ switch (lua_type(L, idx))
+ {
+ case LUA_TBOOLEAN:
+ return lua_toboolean(L, idx);
+ case LUA_TSTRING:
+ return (UINT_PTR)lua_tostring(L, idx);
+ case LUA_TLIGHTUSERDATA:
+ return (UINT_PTR)lua_touserdata(L, idx);
+ case LUA_TNUMBER:
+ {
+ if (lua_isinteger(L, 1))
+ {
+ lua_Integer value = lua_tointeger(L, 1);
+ return value <= INTPTR_MAX
+ ? (UINT_PTR)value
+ : NULL;
+ }
+ }
+ default:
+ return NULL;
+ }
+}
+
int luaM_interpolate(lua_State *L)
{
const char *string = luaL_checkstring(L, 1);
@@ -202,62 +227,6 @@ int luaM_interpolate(lua_State *L) return 1;
}
-WPARAM luaM_towparam(lua_State *L, int idx)
-{
- if (lua_islightuserdata(L, idx))
- {
- return (WPARAM)lua_touserdata(L, idx);
- }
-
- char text[512];
- mir_snprintf(text, "Type %s is not supported. Use topointer(x) instead", luaL_typename(L, idx));
- Log(text);
- if (db_get_b(NULL, MODULE, "PopupOnObsolete", 0))
- ShowNotification(MODULE, text, MB_OK | MB_ICONWARNING, NULL);
-
- switch (lua_type(L, idx))
- {
- case LUA_TBOOLEAN:
- return lua_toboolean(L, idx);
- case LUA_TNUMBER:
- return (WPARAM)lua_tonumber(L, idx);
- case LUA_TSTRING:
- return (WPARAM)lua_tostring(L, idx);
- break;
- default:
- return NULL;
- }
-}
-
-LPARAM luaM_tolparam(lua_State *L, int idx)
-{
- if (lua_islightuserdata(L, idx))
- {
- return (LPARAM)lua_touserdata(L, idx);
- }
-
- char text[512];
- mir_snprintf(text, "Type %s is not supported. Use topointer(x) instead", luaL_typename(L, idx));
- Log(text);
- if (db_get_b(NULL, MODULE, "PopupOnObsolete", 0))
- ShowNotification(MODULE, text, MB_OK | MB_ICONWARNING, NULL);
-
- switch (lua_type(L, idx))
- {
- case LUA_TBOOLEAN:
- return lua_toboolean(L, idx);
- case LUA_TNUMBER:
- return (LPARAM)lua_tonumber(L, idx);
- case LUA_TSTRING:
- return (LPARAM)lua_tostring(L, idx);
- case LUA_TUSERDATA:
- case LUA_TLIGHTUSERDATA:
- return (LPARAM)lua_touserdata(L, idx);
- default:
- return NULL;
- }
-}
-
bool luaM_toboolean(lua_State *L, int idx)
{
if (lua_isnumber(L, idx))
|