From 81885236ca6229fc40eeafda048a3ca677e9420f Mon Sep 17 00:00:00 2001 From: aunsane Date: Sun, 26 Nov 2017 18:13:28 +0300 Subject: MirLua: typo --- plugins/MirLua/src/m_core.cpp | 10 ++--- plugins/MirLua/src/m_genmenu.cpp | 2 +- plugins/MirLua/src/m_hotkeys.cpp | 2 +- plugins/MirLua/src/m_icolib.cpp | 2 +- plugins/MirLua/src/m_options.cpp | 2 +- plugins/MirLua/src/m_sounds.cpp | 2 +- plugins/MirLua/src/m_srmm.cpp | 2 +- plugins/MirLua/src/mlua.cpp | 6 +-- plugins/MirLua/src/mlua_enviroment.cpp | 71 --------------------------------- plugins/MirLua/src/mlua_enviroment.h | 25 ------------ plugins/MirLua/src/mlua_environment.cpp | 71 +++++++++++++++++++++++++++++++++ plugins/MirLua/src/mlua_environment.h | 25 ++++++++++++ plugins/MirLua/src/mlua_script.cpp | 6 +-- plugins/MirLua/src/mlua_script.h | 2 +- plugins/MirLua/src/stdafx.h | 2 +- 15 files changed, 115 insertions(+), 115 deletions(-) delete mode 100644 plugins/MirLua/src/mlua_enviroment.cpp delete mode 100644 plugins/MirLua/src/mlua_enviroment.h create mode 100644 plugins/MirLua/src/mlua_environment.cpp create mode 100644 plugins/MirLua/src/mlua_environment.h (limited to 'plugins/MirLua/src') diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp index 33214d061a..c57595ffef 100644 --- a/plugins/MirLua/src/m_core.cpp +++ b/plugins/MirLua/src/m_core.cpp @@ -37,7 +37,7 @@ int HookEventLuaStateParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param int HookEventEnvParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param) { - CMLuaEnviroment *env = (CMLuaEnviroment*)obj; + CMLuaEnvironment *env = (CMLuaEnvironment*)obj; int ref = param; lua_rawgeti(env->L, LUA_REGISTRYINDEX, ref); @@ -66,7 +66,7 @@ static int core_HookEvent(lua_State *L) int ref = luaL_ref(L, LUA_REGISTRYINDEX); HANDLE res = nullptr; - CMLuaEnviroment *env = CMLuaEnviroment::GetEnviroment(L); + CMLuaEnvironment *env = CMLuaEnvironment::GetEnvironment(L); if (env) res = HookEventObjParam(name, HookEventEnvParam, env, ref); else @@ -95,7 +95,7 @@ static int core_HookTemporaryEvent(lua_State *L) int ref = luaL_ref(L, LUA_REGISTRYINDEX); HANDLE res = nullptr; - CMLuaEnviroment *env = CMLuaEnviroment::GetEnviroment(L); + CMLuaEnvironment *env = CMLuaEnvironment::GetEnvironment(L); if (env) res = HookEventObjParam(name, HookEventEnvParam, env, ref); else @@ -171,7 +171,7 @@ INT_PTR CreateServiceFunctionLuaStateParam(void *obj, WPARAM wParam, LPARAM lPar INT_PTR CreateServiceFunctionEnvParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param) { - CMLuaEnviroment *env = (CMLuaEnviroment*)obj; + CMLuaEnvironment *env = (CMLuaEnvironment*)obj; int ref = param; lua_rawgeti(env->L, LUA_REGISTRYINDEX, ref); @@ -195,7 +195,7 @@ static int core_CreateServiceFunction(lua_State *L) int ref = luaL_ref(L, LUA_REGISTRYINDEX); HANDLE res = nullptr; - CMLuaEnviroment *env = CMLuaEnviroment::GetEnviroment(L); + CMLuaEnvironment *env = CMLuaEnvironment::GetEnvironment(L); if (env) res = CreateServiceFunctionObjParam(name, CreateServiceFunctionEnvParam, env, ref); else diff --git a/plugins/MirLua/src/m_genmenu.cpp b/plugins/MirLua/src/m_genmenu.cpp index 56ab193d52..e84f792a28 100644 --- a/plugins/MirLua/src/m_genmenu.cpp +++ b/plugins/MirLua/src/m_genmenu.cpp @@ -2,7 +2,7 @@ void MakeMenuItem(lua_State *L, CMenuItem &mi) { - mi.hLangpack = CMLuaEnviroment::GetEnviromentId(L); + mi.hLangpack = CMLuaEnvironment::GetEnvironmentId(L); lua_getfield(L, -1, "Flags"); mi.flags = lua_tointeger(L, -1); diff --git a/plugins/MirLua/src/m_hotkeys.cpp b/plugins/MirLua/src/m_hotkeys.cpp index 4988c80332..f6041b504e 100644 --- a/plugins/MirLua/src/m_hotkeys.cpp +++ b/plugins/MirLua/src/m_hotkeys.cpp @@ -41,7 +41,7 @@ static int hotkeys_Register(lua_State *L) HOTKEYDESC hk; MakeHotkey(L, hk); - int hScriptLangpack = CMLuaEnviroment::GetEnviromentId(L); + int hScriptLangpack = CMLuaEnvironment::GetEnvironmentId(L); INT_PTR res = Hotkey_Register(&hk, hScriptLangpack); lua_pushboolean(L, res); diff --git a/plugins/MirLua/src/m_icolib.cpp b/plugins/MirLua/src/m_icolib.cpp index d329d07ae4..06f5cb155f 100644 --- a/plugins/MirLua/src/m_icolib.cpp +++ b/plugins/MirLua/src/m_icolib.cpp @@ -72,7 +72,7 @@ static int lua_AddIcon(lua_State *L) else luaL_argerror(L, 1, luaL_typename(L, 1)); - int hScriptLangpack = CMLuaEnviroment::GetEnviromentId(L); + int hScriptLangpack = CMLuaEnvironment::GetEnvironmentId(L); HANDLE res = IcoLib_AddIcon(&sid, hScriptLangpack); lua_pushlightuserdata(L, res); diff --git a/plugins/MirLua/src/m_options.cpp b/plugins/MirLua/src/m_options.cpp index 9c549e96a2..5e548aeeb6 100644 --- a/plugins/MirLua/src/m_options.cpp +++ b/plugins/MirLua/src/m_options.cpp @@ -44,7 +44,7 @@ public: void MakeOptionDialogPage(lua_State *L, OPTIONSDIALOGPAGE &odp) { odp.hInstance = g_hInstance; - odp.hLangpack = CMLuaEnviroment::GetEnviromentId(L); + odp.hLangpack = CMLuaEnvironment::GetEnvironmentId(L); lua_getfield(L, -1, "Flags"); odp.flags = luaL_optinteger(L, -1, ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE); diff --git a/plugins/MirLua/src/m_sounds.cpp b/plugins/MirLua/src/m_sounds.cpp index f362e6b264..cd9a089ce4 100644 --- a/plugins/MirLua/src/m_sounds.cpp +++ b/plugins/MirLua/src/m_sounds.cpp @@ -7,7 +7,7 @@ static int lua_AddSound(lua_State *L) ptrW section(mir_utf8decodeW(luaL_optstring(L, 3, MODULE))); ptrW filePath(mir_utf8decodeW(lua_tostring(L, 4))); - int res = Skin_AddSound(name, section, description, filePath, CMLuaEnviroment::GetEnviromentId(L)); + int res = Skin_AddSound(name, section, description, filePath, CMLuaEnvironment::GetEnvironmentId(L)); lua_pushboolean(L, res == 0); return 1; diff --git a/plugins/MirLua/src/m_srmm.cpp b/plugins/MirLua/src/m_srmm.cpp index 232fd0f7c8..cd1562fe61 100644 --- a/plugins/MirLua/src/m_srmm.cpp +++ b/plugins/MirLua/src/m_srmm.cpp @@ -47,7 +47,7 @@ static int lua_AddButton(lua_State *L) BBButton bbb = { }; MakeBBButton(L, bbb); - int hScriptLangpack = CMLuaEnviroment::GetEnviromentId(L); + int hScriptLangpack = CMLuaEnvironment::GetEnvironmentId(L); INT_PTR res = Srmm_AddButton(&bbb, hScriptLangpack); CleanBBButton(bbb); diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index 150f5639ab..dba1cb607a 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -325,7 +325,7 @@ INT_PTR CMLua::Call(WPARAM wParam, LPARAM lParam) lua_newtable(L); lua_pushcclosure(L, mlua_call, 1); - CMLuaEnviroment env(L); + CMLuaEnvironment env(L); env.Load(); wchar_t *result = mir_utf8decodeW(lua_tostring(L, -1)); @@ -343,7 +343,7 @@ INT_PTR CMLua::Exec(WPARAM, LPARAM lParam) return NULL; } - CMLuaEnviroment env(L); + CMLuaEnvironment env(L); env.Load(); wchar_t *result = mir_utf8decodeW(lua_tostring(L, -1)); @@ -361,7 +361,7 @@ INT_PTR CMLua::Eval(WPARAM, LPARAM lParam) return NULL; } - CMLuaEnviroment env(L); + CMLuaEnvironment env(L); env.Load(); wchar_t *result = mir_utf8decodeW(lua_tostring(L, -1)); diff --git a/plugins/MirLua/src/mlua_enviroment.cpp b/plugins/MirLua/src/mlua_enviroment.cpp deleted file mode 100644 index 4e7225fd16..0000000000 --- a/plugins/MirLua/src/mlua_enviroment.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "stdafx.h" - -#define MT_ENVIROMENT "ENVIROMENT" - -CMLuaEnviroment::CMLuaEnviroment(lua_State *L) - : L(L) -{ - MUUID muidLast = MIID_LAST; - id = GetPluginLangId(muidLast, 0); -} - -CMLuaEnviroment::~CMLuaEnviroment() -{ - KillModuleIcons(id); - KillModuleSounds(id); - KillModuleMenus(id); - KillModuleHotkeys(id); - - KillObjectEventHooks(this); - KillObjectServices(this); -} - -CMLuaEnviroment* CMLuaEnviroment::GetEnviroment(lua_State *L) -{ - if (!luaM_getenv(L)) - return nullptr; - - lua_rawgeti(L, -1, NULL); - CMLuaEnviroment *env = (CMLuaEnviroment*)lua_touserdata(L, -1); - lua_pop(L, 3); - - return env; -} - -int CMLuaEnviroment::GetEnviromentId(lua_State *L) -{ - CMLuaEnviroment *script = GetEnviroment(L); - return script != nullptr - ? script->GetId() - : hMLuaLangpack; -} - -int CMLuaEnviroment::GetId() const -{ - return id; -} - -void CMLuaEnviroment::CreateEnviromentTable() -{ - lua_createtable(L, 1, 1); - lua_pushlightuserdata(L, this); - lua_rawseti(L, -2, NULL); - lua_pushvalue(L, -1); - lua_setfield(L, -2, "_G"); - lua_createtable(L, 0, 2); - lua_pushliteral(L, MT_ENVIROMENT); - lua_setfield(L, -2, "__metatable"); - lua_getglobal(L, "_G"); - lua_setfield(L, -2, "__index"); - lua_setmetatable(L, -2); -} - -bool CMLuaEnviroment::Load() -{ - luaL_checktype(L, -1, LUA_TFUNCTION); - - CreateEnviromentTable(); - lua_setupvalue(L, -2, 1); - - return lua_pcall(L, 0, 1, 0) == LUA_OK; -} diff --git a/plugins/MirLua/src/mlua_enviroment.h b/plugins/MirLua/src/mlua_enviroment.h deleted file mode 100644 index 73f3f9c377..0000000000 --- a/plugins/MirLua/src/mlua_enviroment.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _LUA_ENVIROMENT_H_ -#define _LUA_ENVIROMENT_H_ - -class CMLuaEnviroment -{ -private: - int id; - - void CreateEnviromentTable(); - -public: - lua_State *L; - - CMLuaEnviroment(lua_State *L); - virtual ~CMLuaEnviroment(); - - static CMLuaEnviroment* GetEnviroment(lua_State *L); - static int GetEnviromentId(lua_State *L); - - int GetId() const; - - bool Load(); -}; - -#endif //_LUA_ENVIROMENT_H_ diff --git a/plugins/MirLua/src/mlua_environment.cpp b/plugins/MirLua/src/mlua_environment.cpp new file mode 100644 index 0000000000..9c28645274 --- /dev/null +++ b/plugins/MirLua/src/mlua_environment.cpp @@ -0,0 +1,71 @@ +#include "stdafx.h" + +#define MT_ENVIRONMENT "ENVIRONMENT" + +CMLuaEnvironment::CMLuaEnvironment(lua_State *L) + : L(L) +{ + MUUID muidLast = MIID_LAST; + id = GetPluginLangId(muidLast, 0); +} + +CMLuaEnvironment::~CMLuaEnvironment() +{ + KillModuleIcons(id); + KillModuleSounds(id); + KillModuleMenus(id); + KillModuleHotkeys(id); + + KillObjectEventHooks(this); + KillObjectServices(this); +} + +CMLuaEnvironment* CMLuaEnvironment::GetEnvironment(lua_State *L) +{ + if (!luaM_getenv(L)) + return nullptr; + + lua_rawgeti(L, -1, NULL); + CMLuaEnvironment *env = (CMLuaEnvironment*)lua_touserdata(L, -1); + lua_pop(L, 3); + + return env; +} + +int CMLuaEnvironment::GetEnvironmentId(lua_State *L) +{ + CMLuaEnvironment *script = GetEnvironment(L); + return script != nullptr + ? script->GetId() + : hMLuaLangpack; +} + +int CMLuaEnvironment::GetId() const +{ + return id; +} + +void CMLuaEnvironment::CreateEnvironmentTable() +{ + lua_createtable(L, 1, 1); + lua_pushlightuserdata(L, this); + lua_rawseti(L, -2, NULL); + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_G"); + lua_createtable(L, 0, 2); + lua_pushliteral(L, MT_ENVIRONMENT); + lua_setfield(L, -2, "__metatable"); + lua_getglobal(L, "_G"); + lua_setfield(L, -2, "__index"); + lua_setmetatable(L, -2); +} + +bool CMLuaEnvironment::Load() +{ + luaL_checktype(L, -1, LUA_TFUNCTION); + + CreateEnvironmentTable(); + lua_setupvalue(L, -2, 1); + + return lua_pcall(L, 0, 1, 0) == LUA_OK; +} diff --git a/plugins/MirLua/src/mlua_environment.h b/plugins/MirLua/src/mlua_environment.h new file mode 100644 index 0000000000..eb72bf42b8 --- /dev/null +++ b/plugins/MirLua/src/mlua_environment.h @@ -0,0 +1,25 @@ +#ifndef _LUA_ENVIRONMENT_H_ +#define _LUA_ENVIRONMENT_H_ + +class CMLuaEnvironment +{ +private: + int id; + + void CreateEnvironmentTable(); + +public: + lua_State *L; + + CMLuaEnvironment(lua_State *L); + virtual ~CMLuaEnvironment(); + + static CMLuaEnvironment* GetEnvironment(lua_State *L); + static int GetEnvironmentId(lua_State *L); + + int GetId() const; + + bool Load(); +}; + +#endif //_LUA_ENVIRONMENT_H_ diff --git a/plugins/MirLua/src/mlua_script.cpp b/plugins/MirLua/src/mlua_script.cpp index ad70bef24c..79e52b9967 100644 --- a/plugins/MirLua/src/mlua_script.cpp +++ b/plugins/MirLua/src/mlua_script.cpp @@ -3,7 +3,7 @@ #define MT_SCRIPT "SCRIPT" CMLuaScript::CMLuaScript(lua_State *L, const wchar_t *path) - : CMLuaEnviroment(L), status(None), unloadRef(LUA_NOREF) + : CMLuaEnvironment(L), status(None), unloadRef(LUA_NOREF) { mir_wstrcpy(filePath, path); @@ -19,7 +19,7 @@ CMLuaScript::CMLuaScript(lua_State *L, const wchar_t *path) } CMLuaScript::CMLuaScript(const CMLuaScript &script) - : CMLuaEnviroment(L), status(None), unloadRef(LUA_NOREF) + : CMLuaEnvironment(L), status(None), unloadRef(LUA_NOREF) { mir_wstrcpy(filePath, script.filePath); fileName = mir_wstrdup(script.fileName); @@ -75,7 +75,7 @@ bool CMLuaScript::Load() return false; } - if (!CMLuaEnviroment::Load()) { + if (!CMLuaEnvironment::Load()) { ReportError(L); return false; } diff --git a/plugins/MirLua/src/mlua_script.h b/plugins/MirLua/src/mlua_script.h index 36008d063b..9a1ec98390 100644 --- a/plugins/MirLua/src/mlua_script.h +++ b/plugins/MirLua/src/mlua_script.h @@ -1,7 +1,7 @@ #ifndef _LUA_SCRIPT_H_ #define _LUA_SCRIPT_H_ -class CMLuaScript : public CMLuaEnviroment +class CMLuaScript : public CMLuaEnvironment { public: enum Status diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 4b5ad5a78b..92ae2a9d46 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -33,7 +33,7 @@ class CMLuaScript; #include "mlua.h" -#include "mlua_enviroment.h" +#include "mlua_environment.h" #include "mlua_script.h" #include "mlua_module_loader.h" #include "mlua_script_loader.h" -- cgit v1.2.3