summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-07-07 13:49:53 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-07-07 13:49:53 +0000
commit579b92a2f091284839bfa112116ed088dd3b2418 (patch)
treebb17a0226477f5aacb2d0caf5e5b1ec01f91342c /plugins
parenta6849e6952b88ca67f2eac3f1e2adc287246b0a5 (diff)
MirLua:
- added Utf8DecodeA, Utf8DecodeW and Free to m - more correct number to boolean in m_genmenu - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@14505 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MirLua/src/m_core.cpp35
-rw-r--r--plugins/MirLua/src/m_genmenu.cpp6
-rw-r--r--plugins/MirLua/src/mlua_utils.cpp5
-rw-r--r--plugins/MirLua/src/stdafx.h2
-rw-r--r--plugins/MirLua/src/version.h2
5 files changed, 43 insertions, 7 deletions
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp
index c9eec524c7..2a5564a07b 100644
--- a/plugins/MirLua/src/m_core.cpp
+++ b/plugins/MirLua/src/m_core.cpp
@@ -160,6 +160,36 @@ static int lua_CallService(lua_State *L)
return 1;
}
+static int lua_Utf8DecodeA(lua_State *L)
+{
+ const char *string = luaL_checkstring(L, 1);
+
+ char *res = mir_utf8decodeA(string);
+ lua_pushlightuserdata(L, res);
+
+ return 1;
+}
+
+static int lua_Utf8DecodeW(lua_State *L)
+{
+ const char *string = luaL_checkstring(L, 1);
+
+ wchar_t *res = mir_utf8decodeW(string);
+ lua_pushlightuserdata(L, res);
+
+ return 1;
+}
+
+static int lua_Free(lua_State *L)
+{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+ void *ptr = lua_touserdata(L, 1);
+
+ mir_free(ptr);
+
+ return 0;
+}
+
static int lua_Translate(lua_State *L)
{
char *what = (char*)luaL_checkstring(L, 1);
@@ -196,6 +226,11 @@ luaL_Reg coreApi[] =
{ "ServiceExists", lua_ServiceExists },
{ "CallService", lua_CallService },
+ { "Utf8DecodeA", lua_Utf8DecodeA },
+ { "Utf8DecodeW", lua_Utf8DecodeW },
+
+ { "Free", lua_Free },
+
{ "Translate", lua_Translate },
{ "ReplaceVariables", lua_ReplaceVariables },
diff --git a/plugins/MirLua/src/m_genmenu.cpp b/plugins/MirLua/src/m_genmenu.cpp
index 41e30c3a67..57c6938f60 100644
--- a/plugins/MirLua/src/m_genmenu.cpp
+++ b/plugins/MirLua/src/m_genmenu.cpp
@@ -75,7 +75,7 @@ static int lua_ModifyMenuItem(lua_State *L)
static int lua_ShowMenuItem(lua_State *L)
{
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
- bool isShow = lua_toboolean(L, 2) != 0;
+ bool isShow = luaM_toboolean(L, 2);
::Menu_ShowItem(hMenuItem, isShow);
@@ -85,7 +85,7 @@ static int lua_ShowMenuItem(lua_State *L)
static int lua_EnableMenuItem(lua_State *L)
{
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
- bool isEnable = lua_toboolean(L, 2) != 0;
+ bool isEnable = luaM_toboolean(L, 2);
::Menu_EnableItem(hMenuItem, isEnable);
@@ -95,7 +95,7 @@ static int lua_EnableMenuItem(lua_State *L)
static int lua_CheckMenuItem(lua_State *L)
{
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
- bool isChecked = lua_toboolean(L, 2) != 0;
+ bool isChecked = luaM_toboolean(L, 2);
::Menu_SetChecked(hMenuItem, isChecked);
diff --git a/plugins/MirLua/src/mlua_utils.cpp b/plugins/MirLua/src/mlua_utils.cpp
index 837ab08c53..6c9bfa2a97 100644
--- a/plugins/MirLua/src/mlua_utils.cpp
+++ b/plugins/MirLua/src/mlua_utils.cpp
@@ -20,9 +20,10 @@ int luaM_atpanic(lua_State *L)
return 0;
}
-bool luaM_checkboolean(lua_State *L, int idx)
+bool luaM_toboolean(lua_State *L, int idx)
{
- luaL_checktype(L, 2, LUA_TBOOLEAN);
+ if (lua_type(L, idx) == LUA_TNUMBER)
+ return lua_tonumber(L, idx) != 0;
return lua_toboolean(L, idx) > 0;
}
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h
index 2fbbc83429..d871d739ea 100644
--- a/plugins/MirLua/src/stdafx.h
+++ b/plugins/MirLua/src/stdafx.h
@@ -95,7 +95,7 @@ LUAMOD_API int (luaopen_m_windows)(lua_State *L);
int luaM_print(lua_State *L);
int luaM_atpanic(lua_State *L);
-bool luaM_checkboolean(lua_State *L, int idx);
+bool luaM_toboolean(lua_State *L, int idx);
WPARAM luaM_towparam(lua_State *L, int idx);
LPARAM luaM_tolparam(lua_State *L, int idx);
diff --git a/plugins/MirLua/src/version.h b/plugins/MirLua/src/version.h
index 4a26c2ba41..5f118b7f7c 100644
--- a/plugins/MirLua/src/version.h
+++ b/plugins/MirLua/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 3
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>