diff options
author | Vincent Glize <vincentglize@hotmail.fr> | 2017-06-19 23:54:58 +0200 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-06-19 23:54:58 +0200 |
commit | 4a5e8ad343079f6552fab639770e5771ed7c4e7a (patch) | |
tree | eeab3adec1fc3e7a3b06d9f53b92ab99a5e0d290 /src/script/cpp_api | |
parent | 4a789490834157baa8788a2f36c95b86c1e4440e (diff) | |
download | minetest-4a5e8ad343079f6552fab639770e5771ed7c4e7a.tar.gz minetest-4a5e8ad343079f6552fab639770e5771ed7c4e7a.tar.bz2 minetest-4a5e8ad343079f6552fab639770e5771ed7c4e7a.zip |
C++11 cleanup on constructors (#6000)
* C++11 cleanup on constructors dir script
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r-- | src/script/cpp_api/s_async.cpp | 7 | ||||
-rw-r--r-- | src/script/cpp_api/s_async.h | 26 | ||||
-rw-r--r-- | src/script/cpp_api/s_base.cpp | 12 | ||||
-rw-r--r-- | src/script/cpp_api/s_base.h | 10 |
4 files changed, 16 insertions, 39 deletions
diff --git a/src/script/cpp_api/s_async.cpp b/src/script/cpp_api/s_async.cpp index 722359066..5cca5fc03 100644 --- a/src/script/cpp_api/s_async.cpp +++ b/src/script/cpp_api/s_async.cpp @@ -34,13 +34,6 @@ extern "C" { #include "common/c_internal.h" /******************************************************************************/ -AsyncEngine::AsyncEngine() : - initDone(false), - jobIdCounter(0) -{ -} - -/******************************************************************************/ AsyncEngine::~AsyncEngine() { diff --git a/src/script/cpp_api/s_async.h b/src/script/cpp_api/s_async.h index 45f935d0a..94b55db6e 100644 --- a/src/script/cpp_api/s_async.h +++ b/src/script/cpp_api/s_async.h @@ -39,24 +39,18 @@ class AsyncEngine; // Data required to queue a job struct LuaJobInfo { - LuaJobInfo() : - serializedFunction(""), - serializedParams(""), - serializedResult(""), - id(0), - valid(false) - {} + LuaJobInfo() {}; // Function to be called in async environment - std::string serializedFunction; + std::string serializedFunction = ""; // Parameter to be passed to function - std::string serializedParams; + std::string serializedParams = ""; // Result of function call - std::string serializedResult; + std::string serializedResult = ""; // JobID used to identify a job and match it to callback - unsigned int id; + unsigned int id = 0; - bool valid; + bool valid = false; }; // Asynchronous working environment @@ -68,7 +62,7 @@ public: void *run(); private: - AsyncEngine *jobDispatcher; + AsyncEngine *jobDispatcher = nullptr; }; // Asynchornous thread and job management @@ -76,7 +70,7 @@ class AsyncEngine { friend class AsyncWorkerThread; typedef void (*StateInitializer)(lua_State *L, int top); public: - AsyncEngine(); + AsyncEngine() {}; ~AsyncEngine(); /** @@ -137,13 +131,13 @@ protected: private: // Variable locking the engine against further modification - bool initDone; + bool initDone = false; // Internal store for registred state initializers std::vector<StateInitializer> stateInitializers; // Internal counter to create job IDs - unsigned int jobIdCounter; + unsigned int jobIdCounter = 0; // Mutex to protect job queue std::mutex jobQueueMutex; diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp index 4d7461c5b..aaf26a9c3 100644 --- a/src/script/cpp_api/s_base.cpp +++ b/src/script/cpp_api/s_base.cpp @@ -71,9 +71,7 @@ public: ScriptApiBase */ -ScriptApiBase::ScriptApiBase() : - m_luastackmutex(), - m_gamedef(NULL) +ScriptApiBase::ScriptApiBase() { #ifdef SCRIPTAPI_LOCK_DEBUG m_lock_recursion_count = 0; @@ -111,14 +109,6 @@ ScriptApiBase::ScriptApiBase() : lua_pushstring(m_luastack, porting::getPlatformName()); lua_setglobal(m_luastack, "PLATFORM"); - - // m_secure gets set to true inside - // ScriptApiSecurity::initializeSecurity(), if neccessary. - // Default to false otherwise - m_secure = false; - - m_environment = NULL; - m_guiengine = NULL; } ScriptApiBase::~ScriptApiBase() diff --git a/src/script/cpp_api/s_base.h b/src/script/cpp_api/s_base.h index ed056db31..38ee9901b 100644 --- a/src/script/cpp_api/s_base.h +++ b/src/script/cpp_api/s_base.h @@ -119,7 +119,7 @@ protected: std::recursive_mutex m_luastackmutex; std::string m_last_run_mod; - bool m_secure; + bool m_secure = false; #ifdef SCRIPTAPI_LOCK_DEBUG int m_lock_recursion_count; std::thread::id m_owning_thread; @@ -128,11 +128,11 @@ protected: private: static int luaPanic(lua_State *L); - lua_State* m_luastack; + lua_State *m_luastack = nullptr; - IGameDef* m_gamedef; - Environment* m_environment; - GUIEngine* m_guiengine; + IGameDef *m_gamedef = nullptr; + Environment *m_environment = nullptr; + GUIEngine *m_guiengine = nullptr; }; #endif /* S_BASE_H_ */ |