From e69e24524436a1ce013bf461f87924f57ed075fb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 28 May 2018 14:09:32 +0300 Subject: core changes: - added methods CMPluginBase::Load & CMPluginBase::Unload - duplicated data removed from BASIC_PLUGIN_INFO and replaced with data from CMPluginBase; - code cleaning --- plugins/MirLua/src/environment.cpp | 2 +- plugins/MirLua/src/environment.h | 2 +- plugins/MirLua/src/mplugin.cpp | 6 ++++-- plugins/MirLua/src/mplugin.h | 6 +++--- plugins/MirLua/src/script.cpp | 5 +++-- plugins/MirLua/src/script.h | 6 +++--- 6 files changed, 15 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/MirLua/src/environment.cpp b/plugins/MirLua/src/environment.cpp index 3127edee82..321eace843 100644 --- a/plugins/MirLua/src/environment.cpp +++ b/plugins/MirLua/src/environment.cpp @@ -138,7 +138,7 @@ void CMLuaEnvironment::CreateEnvironmentTable() lua_setmetatable(L, -2); } -bool CMLuaEnvironment::Load() +int CMLuaEnvironment::Load() { luaL_checktype(L, -1, LUA_TFUNCTION); diff --git a/plugins/MirLua/src/environment.h b/plugins/MirLua/src/environment.h index 1ede34756f..1c35c2073d 100644 --- a/plugins/MirLua/src/environment.h +++ b/plugins/MirLua/src/environment.h @@ -23,5 +23,5 @@ public: HANDLE CreateServiceFunction(const char *name, int ref); void DestroyServiceFunction(HANDLE hService); - bool Load(); + int Load() override; }; diff --git a/plugins/MirLua/src/mplugin.cpp b/plugins/MirLua/src/mplugin.cpp index 5262499e98..44e73ae9cc 100644 --- a/plugins/MirLua/src/mplugin.cpp +++ b/plugins/MirLua/src/mplugin.cpp @@ -24,7 +24,7 @@ CMPlugin::~CMPlugin() Unload(); } -void CMPlugin::Load() +int CMPlugin::Load() { Log("Loading lua engine"); L = luaL_newstate(); @@ -36,9 +36,10 @@ void CMPlugin::Load() CMLuaFunctionLoader::Load(L); CMLuaModuleLoader::Load(L); CMLuaScriptLoader::Load(L); + return 0; } -void CMPlugin::Unload() +int CMPlugin::Unload() { Log("Unloading lua engine"); @@ -53,6 +54,7 @@ void CMPlugin::Unload() KillObjectServices(L); lua_close(L); + return 0; } void CMPlugin::Reload() diff --git a/plugins/MirLua/src/mplugin.h b/plugins/MirLua/src/mplugin.h index 9db92580f8..f448d06daf 100644 --- a/plugins/MirLua/src/mplugin.h +++ b/plugins/MirLua/src/mplugin.h @@ -8,8 +8,6 @@ struct CMPlugin : public PLUGIN private: lua_State *L; - void Unload(); - INT_PTR __cdecl Eval(WPARAM, LPARAM); INT_PTR __cdecl Call(WPARAM, LPARAM); INT_PTR __cdecl Exec(WPARAM, LPARAM); @@ -20,7 +18,9 @@ public: CMPlugin(); ~CMPlugin(); - void Load(); + int Load() override; + int Unload() override; + void Reload(); }; diff --git a/plugins/MirLua/src/script.cpp b/plugins/MirLua/src/script.cpp index 0b6b148536..50e061b59c 100644 --- a/plugins/MirLua/src/script.cpp +++ b/plugins/MirLua/src/script.cpp @@ -62,7 +62,7 @@ CMLuaScript::Status CMLuaScript::GetStatus() const return status; } -bool CMLuaScript::Load() +int CMLuaScript::Load() { status = Failed; @@ -114,7 +114,7 @@ bool CMLuaScript::Load() return true; } -void CMLuaScript::Unload() +int CMLuaScript::Unload() { if (status == Loaded) { lua_rawgeti(L, LUA_REGISTRYINDEX, unloadRef); @@ -129,6 +129,7 @@ void CMLuaScript::Unload() lua_pushnil(L); lua_setfield(L, -2, m_szModuleName); lua_pop(L, 1); + return 0; } bool CMLuaScript::Reload() diff --git a/plugins/MirLua/src/script.h b/plugins/MirLua/src/script.h index 8ff5b40600..2caf88c925 100644 --- a/plugins/MirLua/src/script.h +++ b/plugins/MirLua/src/script.h @@ -17,8 +17,6 @@ private: const wchar_t *fileName; wchar_t filePath[MAX_PATH]; - void Unload(); - public: CMLuaScript(lua_State *L, const wchar_t *path); CMLuaScript(const CMLuaScript &script); @@ -33,6 +31,8 @@ public: Status GetStatus() const; - bool Load(); + int Load() override; + int Unload() override; + bool Reload(); }; -- cgit v1.2.3