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 --- .../MirLua/Modules/m_variables/m_variables.vcxproj | 28 +++++++++++++++++++ plugins/MirLua/Modules/m_variables/src/main.cpp | 32 ++++++++++++++++++++++ plugins/MirLua/Modules/m_variables/src/stdafx.cxx | 1 + plugins/MirLua/Modules/m_variables/src/stdafx.h | 14 ++++++++++ plugins/MirLua/Modules/module.props | 3 +- plugins/MirLua/src/m_variables.cpp | 32 ---------------------- plugins/MirLua/src/mlua.cpp | 16 ----------- plugins/MirLua/src/mlua.h | 2 -- plugins/MirLua/src/mlua_metatable.h | 2 +- plugins/MirLua/src/mlua_module_loader.cpp | 1 - plugins/MirLua/src/mlua_script.cpp | 4 +-- plugins/MirLua/src/stdafx.h | 5 ---- 12 files changed, 80 insertions(+), 60 deletions(-) create mode 100644 plugins/MirLua/Modules/m_variables/m_variables.vcxproj create mode 100644 plugins/MirLua/Modules/m_variables/src/main.cpp create mode 100644 plugins/MirLua/Modules/m_variables/src/stdafx.cxx create mode 100644 plugins/MirLua/Modules/m_variables/src/stdafx.h delete mode 100644 plugins/MirLua/src/m_variables.cpp diff --git a/plugins/MirLua/Modules/m_variables/m_variables.vcxproj b/plugins/MirLua/Modules/m_variables/m_variables.vcxproj new file mode 100644 index 0000000000..fedbf4a66c --- /dev/null +++ b/plugins/MirLua/Modules/m_variables/m_variables.vcxproj @@ -0,0 +1,28 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + m_variables + {E604CD58-4579-4F69-9D6A-2605FD7CF716} + + + + + 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; +} diff --git a/plugins/MirLua/Modules/m_variables/src/stdafx.cxx b/plugins/MirLua/Modules/m_variables/src/stdafx.cxx new file mode 100644 index 0000000000..fd4f341c7b --- /dev/null +++ b/plugins/MirLua/Modules/m_variables/src/stdafx.cxx @@ -0,0 +1 @@ +#include "stdafx.h" diff --git a/plugins/MirLua/Modules/m_variables/src/stdafx.h b/plugins/MirLua/Modules/m_variables/src/stdafx.h new file mode 100644 index 0000000000..0293856dbd --- /dev/null +++ b/plugins/MirLua/Modules/m_variables/src/stdafx.h @@ -0,0 +1,14 @@ +#ifndef _COMMON_H_ +#define _COMMON_H_ + +#include + +#define VARIABLES_NOHELPER + +#include + +#include +#include +#include + +#endif //_COMMON_H_ \ No newline at end of file diff --git a/plugins/MirLua/Modules/module.props b/plugins/MirLua/Modules/module.props index d5ba41546b..6def4559a2 100644 --- a/plugins/MirLua/Modules/module.props +++ b/plugins/MirLua/Modules/module.props @@ -18,7 +18,8 @@ $(ProjectDir)..\..\..\..\bin14\lib;%(AdditionalLibraryDirectories) - $(ProjectDir)..\..\..\..\include;$(ProjectDir)..\..\..\..\libs\liblua\include;%(AdditionalIncludeDirectories) + LUA_LIB;%(PreprocessorDefinitions) + $(ProjectDir)..\..\..\..\include;$(ProjectDir)..\..\..\ExternalAPI;$(ProjectDir)..\..\..\..\libs\liblua\include;%(AdditionalIncludeDirectories) diff --git a/plugins/MirLua/src/m_variables.cpp b/plugins/MirLua/src/m_variables.cpp deleted file mode 100644 index cf5b6e9890..0000000000 --- a/plugins/MirLua/src/m_variables.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "stdafx.h" - -static int lua_FormatString(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(format, NULL, hContact); - lua_pushstring(L, T2Utf(res)); - - return 1; -} - -static luaL_Reg variablesApi[] = -{ - { "FormatString", lua_FormatString }, - - { NULL, NULL } -}; - -LUAMOD_API int luaopen_m_variables(lua_State *L) -{ - luaL_newlib(L, variablesApi); - - return 1; -} diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index 18f2cf5315..917fa26631 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -105,20 +105,4 @@ void CMLua::KillLuaRefs() delete param; } } -} - -int CMLua::HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param) -{ - lua_State *L = (lua_State*)obj; - - int ref = param; - lua_rawgeti(L, LUA_REGISTRYINDEX, ref); - - lua_pushlightuserdata(L, (void*)wParam); - lua_pushlightuserdata(L, (void*)lParam); - luaM_pcall(L, 2, 1); - - int res = (int)lua_tointeger(L, 1); - - return res; } \ No newline at end of file diff --git a/plugins/MirLua/src/mlua.h b/plugins/MirLua/src/mlua.h index f85db956c3..c732d2c8a4 100644 --- a/plugins/MirLua/src/mlua.h +++ b/plugins/MirLua/src/mlua.h @@ -30,8 +30,6 @@ public: void Load(); void Unload(); - - static int HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param); }; #endif //_LUA_CORE_H_ diff --git a/plugins/MirLua/src/mlua_metatable.h b/plugins/MirLua/src/mlua_metatable.h index 143c3a6ace..39bc63149c 100644 --- a/plugins/MirLua/src/mlua_metatable.h +++ b/plugins/MirLua/src/mlua_metatable.h @@ -160,7 +160,7 @@ public: } template - MT& Field(L &f, const char *name, int type) + MT& Field(const L &f, const char *name, int type) { if (type != LUA_TNONE) fields[name] = new MTField(f, type); diff --git a/plugins/MirLua/src/mlua_module_loader.cpp b/plugins/MirLua/src/mlua_module_loader.cpp index 1abe63cc51..18137a6868 100644 --- a/plugins/MirLua/src/mlua_module_loader.cpp +++ b/plugins/MirLua/src/mlua_module_loader.cpp @@ -41,7 +41,6 @@ void CLuaModuleLoader::LoadModules() Preload(MLUA_MSGBUTTONSBAR, luaopen_m_msg_buttonsbar); Preload(MLUA_POPUP, luaopen_m_popup); Preload(MLUA_TOPTOOLBAR, luaopen_m_toptoolbar); - Preload(MLUA_VARIABLES, luaopen_m_variables); } void CLuaModuleLoader::Load(lua_State *L) diff --git a/plugins/MirLua/src/mlua_script.cpp b/plugins/MirLua/src/mlua_script.cpp index 9e3769cabe..39b7bbf9e0 100644 --- a/plugins/MirLua/src/mlua_script.cpp +++ b/plugins/MirLua/src/mlua_script.cpp @@ -29,7 +29,7 @@ CMLuaScript::~CMLuaScript() bool CMLuaScript::GetScriptEnviroment(lua_State *L) { lua_Debug ar; - if (lua_getstack(L, 1, &ar) == 0 || lua_getinfo(L, "Sf", &ar) == 0 || lua_iscfunction(L, -1)) + if (lua_getstack(L, 1, &ar) == 0 || lua_getinfo(L, "f", &ar) == 0 || lua_iscfunction(L, -1)) { lua_pop(L, 1); return false; @@ -105,7 +105,7 @@ bool CMLuaScript::Load() lua_getglobal(L, "_G"); lua_setfield(L, -2, "__index"); lua_setmetatable(L, -2); - const char *env = lua_setupvalue(L, -2, 1); + lua_setupvalue(L, -2, 1); if (luaM_pcall(L, 0, 1)) return false; diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index f90db7243b..82c6e97b29 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -32,7 +32,6 @@ #include #include #include -#include #include @@ -101,10 +100,6 @@ LUAMOD_API int (luaopen_m_sounds)(lua_State *L); #include "m_toptoolbar.h" -#define MLUA_VARIABLES "m_variables" -LUAMOD_API int (luaopen_m_variables)(lua_State *L); - - /* utils */ extern HANDLE hNetlib; -- cgit v1.2.3