From 962a3d06bbd73aa7bb46eb8ae3e65c31a1902d5d Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 17 Feb 2016 15:38:39 +0000 Subject: MirLua: m_variableas moved to separate lua library git-svn-id: http://svn.miranda-ng.org/main/trunk@16292 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/Modules/m_variables/src/main.cpp | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 plugins/MirLua/Modules/m_variables/src/main.cpp (limited to 'plugins/MirLua/Modules/m_variables/src/main.cpp') diff --git a/plugins/MirLua/Modules/m_variables/src/main.cpp b/plugins/MirLua/Modules/m_variables/src/main.cpp new file mode 100644 index 0000000000..1fb6dd29bb --- /dev/null +++ b/plugins/MirLua/Modules/m_variables/src/main.cpp @@ -0,0 +1,32 @@ +#include "stdafx.h" + +static int lua_Parse(lua_State *L) +{ + if (!ServiceExists(MS_VARS_FORMATSTRING)) + { + lua_pushvalue(L, 1); + return 1; + } + + ptrT format(mir_utf8decodeT(luaL_checkstring(L, 1))); + MCONTACT hContact = lua_tointeger(L, 2); + + TCHAR *res = variables_parse_ex(format, NULL, hContact, NULL, 0); + lua_pushstring(L, T2Utf(res)); + + return 1; +} + +static luaL_Reg variablesApi[] = +{ + { "Parse", lua_Parse }, + + { NULL, NULL } +}; + +LUAMOD_API int luaopen_m_variables(lua_State *L) +{ + luaL_newlib(L, variablesApi); + + return 1; +} -- cgit v1.2.3