summaryrefslogtreecommitdiff
path: root/core/os
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 12:53:38 +0200
committerGitHub <noreply@github.com>2020-05-14 12:53:38 +0200
commit5f5f53e8eba5c9b708714de58d3cca6ceb010279 (patch)
tree8bebdce946466ce8e9476ccd46c9dba62c323938 /core/os
parente7c9d818766a119089873e4941e4865fb36883ec (diff)
parent1f6f364a56319eabd02c050746fe7df3f55ffee3 (diff)
Merge pull request #38697 from akien-mga/member-init-c++11
Port member default initialization from constructor to declaration (C++11)
Diffstat (limited to 'core/os')
-rw-r--r--core/os/dir_access.cpp8
-rw-r--r--core/os/dir_access.h18
-rw-r--r--core/os/file_access.cpp12
-rw-r--r--core/os/file_access.h11
-rw-r--r--core/os/main_loop.cpp6
-rw-r--r--core/os/main_loop.h4
-rw-r--r--core/os/memory.cpp2
-rw-r--r--core/os/memory.h2
-rw-r--r--core/os/mutex.h2
-rw-r--r--core/os/os.cpp15
-rw-r--r--core/os/os.h24
-rw-r--r--core/os/rw_lock.cpp3
-rw-r--r--core/os/rw_lock.h2
-rw-r--r--core/os/semaphore.cpp31
-rw-r--r--core/os/thread.cpp6
-rw-r--r--core/os/thread.h4
16 files changed, 33 insertions, 117 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index b26cd46fd8..53b959a580 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -446,11 +446,3 @@ bool DirAccess::exists(String p_dir) {
memdelete(da);
return valid;
}
-
-DirAccess::DirAccess() {
-
- _access_type = ACCESS_FILESYSTEM;
-}
-
-DirAccess::~DirAccess() {
-}
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index 6c876cde5a..cac0d0ec7c 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -47,7 +47,7 @@ public:
typedef DirAccess *(*CreateFunc)();
private:
- AccessType _access_type;
+ AccessType _access_type = ACCESS_FILESYSTEM;
static CreateFunc create_func[ACCESS_MAX]; ///< set this to instance a filesystem object
Error _copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags);
@@ -110,16 +110,6 @@ public:
static String get_full_path(const String &p_path, AccessType p_access);
static DirAccess *create_for_path(const String &p_path);
- /*
- enum DirType {
-
- FILE_TYPE_INVALID,
- FILE_TYPE_FILE,
- FILE_TYPE_DIR,
- };
-
- //virtual DirType get_file_type() const=0;
-*/
static DirAccess *create(AccessType p_access);
template <class T>
@@ -130,8 +120,8 @@ public:
static DirAccess *open(const String &p_path, Error *r_error = nullptr);
- DirAccess();
- virtual ~DirAccess();
+ DirAccess() {}
+ virtual ~DirAccess() {}
};
struct DirAccessRef {
@@ -142,7 +132,9 @@ struct DirAccessRef {
}
operator bool() const { return f != nullptr; }
+
DirAccess *f;
+
DirAccessRef(DirAccess *fa) { f = fa; }
~DirAccessRef() {
if (f)
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 7055780f34..cb8705f706 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -278,7 +278,7 @@ class CharBuffer {
char *buffer;
int capacity;
- int written;
+ int written = 0;
bool grow() {
@@ -305,8 +305,7 @@ class CharBuffer {
public:
_FORCE_INLINE_ CharBuffer() :
buffer(stack_buffer),
- capacity(sizeof(stack_buffer) / sizeof(char)),
- written(0) {
+ capacity(sizeof(stack_buffer) / sizeof(char)) {
}
_FORCE_INLINE_ void push_back(char c) {
@@ -716,10 +715,3 @@ String FileAccess::get_sha256(const String &p_file) {
memdelete(f);
return String::hex_encode_buffer(hash, 32);
}
-
-FileAccess::FileAccess() {
-
- endian_swap = false;
- real_is_double = false;
- _access_type = ACCESS_FILESYSTEM;
-};
diff --git a/core/os/file_access.h b/core/os/file_access.h
index 0f85c447b6..0ee29abbc9 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -53,8 +53,8 @@ public:
typedef void (*FileCloseFailNotify)(const String &);
typedef FileAccess *(*CreateFunc)();
- bool endian_swap;
- bool real_is_double;
+ bool endian_swap = false;
+ bool real_is_double = false;
virtual uint32_t _get_unix_permissions(const String &p_file) = 0;
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) = 0;
@@ -69,7 +69,7 @@ protected:
private:
static bool backup_save;
- AccessType _access_type;
+ AccessType _access_type = ACCESS_FILESYSTEM;
static CreateFunc create_func[ACCESS_MAX]; /** default file access creation function for a platform */
template <class T>
static FileAccess *_create_builtin() {
@@ -176,7 +176,7 @@ public:
create_func[p_access] = _create_builtin<T>;
}
- FileAccess();
+ FileAccess() {}
virtual ~FileAccess() {}
};
@@ -188,8 +188,11 @@ struct FileAccessRef {
}
operator bool() const { return f != nullptr; }
+
FileAccess *f;
+
operator FileAccess *() { return f; }
+
FileAccessRef(FileAccess *fa) { f = fa; }
~FileAccessRef() {
if (f)
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 0d1a080682..b29e3f6142 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -60,12 +60,6 @@ void MainLoop::set_init_script(const Ref<Script> &p_init_script) {
init_script = p_init_script;
}
-MainLoop::MainLoop() {
-}
-
-MainLoop::~MainLoop() {
-}
-
void MainLoop::init() {
if (init_script.is_valid())
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index 8f6c8c91b1..c7cc8f01e0 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -64,8 +64,8 @@ public:
void set_init_script(const Ref<Script> &p_init_script);
- MainLoop();
- virtual ~MainLoop();
+ MainLoop() {}
+ virtual ~MainLoop() {}
};
#endif // MAIN_LOOP_H
diff --git a/core/os/memory.cpp b/core/os/memory.cpp
index d921c10ad4..0e48592cc1 100644
--- a/core/os/memory.cpp
+++ b/core/os/memory.cpp
@@ -204,8 +204,6 @@ uint64_t Memory::get_mem_max_usage() {
}
_GlobalNil::_GlobalNil() {
-
- color = 1;
left = this;
right = this;
parent = this;
diff --git a/core/os/memory.h b/core/os/memory.h
index d377d54fad..0588e47289 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -194,7 +194,7 @@ void memdelete_arr(T *p_class) {
struct _GlobalNil {
- int color;
+ int color = 1;
_GlobalNil *right;
_GlobalNil *left;
_GlobalNil *parent;
diff --git a/core/os/mutex.h b/core/os/mutex.h
index 526549dd93..69a15f96de 100644
--- a/core/os/mutex.h
+++ b/core/os/mutex.h
@@ -83,7 +83,7 @@ extern template class MutexLock<MutexImpl<std::mutex>>;
class FakeMutex {
- FakeMutex(){};
+ FakeMutex() {}
};
template <class MutexT>
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 425132fbec..cdc9f1e0ff 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -508,25 +508,10 @@ void OS::close_midi_inputs() {
OS::OS() {
void *volatile stack_bottom;
- restart_on_exit = false;
singleton = this;
- _keep_screen_on = true; // set default value to true, because this had been true before godot 2.0.
- low_processor_usage_mode = false;
- low_processor_usage_mode_sleep_usec = 10000;
- _verbose_stdout = false;
- _no_window = false;
- _exit_code = 0;
- _render_thread_mode = RENDER_THREAD_SAFE;
-
- _allow_hidpi = false;
- _allow_layered = false;
_stack_bottom = (void *)(&stack_bottom);
- _logger = nullptr;
-
- has_server_feature_callback = nullptr;
-
Vector<Logger *> loggers;
loggers.push_back(memnew(StdLogger));
_set_logger(memnew(CompositeLogger(loggers)));
diff --git a/core/os/os.h b/core/os/os.h
index 38114e6814..4340823cf4 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -46,17 +46,17 @@ class OS {
static OS *singleton;
String _execpath;
List<String> _cmdline;
- bool _keep_screen_on;
- bool low_processor_usage_mode;
- int low_processor_usage_mode_sleep_usec;
- bool _verbose_stdout;
+ bool _keep_screen_on = true; // set default value to true, because this had been true before godot 2.0.
+ bool low_processor_usage_mode = false;
+ int low_processor_usage_mode_sleep_usec = 10000;
+ bool _verbose_stdout = false;
String _local_clipboard;
uint64_t _msec_splash;
- bool _no_window;
- int _exit_code;
+ bool _no_window = false;
+ int _exit_code = 0;
int _orientation;
- bool _allow_hidpi;
- bool _allow_layered;
+ bool _allow_hidpi = false;
+ bool _allow_layered = false;
bool _use_vsync;
bool _vsync_via_compositor;
bool _disable_wintab;
@@ -65,9 +65,9 @@ class OS {
void *_stack_bottom;
- CompositeLogger *_logger;
+ CompositeLogger *_logger = nullptr;
- bool restart_on_exit;
+ bool restart_on_exit = false;
List<String> restart_commandline;
protected:
@@ -87,8 +87,8 @@ public:
protected:
friend class Main;
- HasServerFeatureCallback has_server_feature_callback;
- RenderThreadMode _render_thread_mode;
+ HasServerFeatureCallback has_server_feature_callback = nullptr;
+ RenderThreadMode _render_thread_mode = RENDER_THREAD_SAFE;
// functions used by main to initialize/deinitialize the OS
void add_logger(Logger *p_logger);
diff --git a/core/os/rw_lock.cpp b/core/os/rw_lock.cpp
index 1dd2c3bccb..81df7f7ea6 100644
--- a/core/os/rw_lock.cpp
+++ b/core/os/rw_lock.cpp
@@ -42,6 +42,3 @@ RWLock *RWLock::create() {
return create_func();
}
-
-RWLock::~RWLock() {
-}
diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h
index 2ef4df9b70..8dca8a230a 100644
--- a/core/os/rw_lock.h
+++ b/core/os/rw_lock.h
@@ -48,7 +48,7 @@ public:
static RWLock *create(); ///< Create a rwlock
- virtual ~RWLock();
+ virtual ~RWLock() {}
};
class RWLockRead {
diff --git a/core/os/semaphore.cpp b/core/os/semaphore.cpp
deleted file mode 100644
index 93f1e2dff4..0000000000
--- a/core/os/semaphore.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*************************************************************************/
-/* semaphore.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "semaphore.h"
diff --git a/core/os/thread.cpp b/core/os/thread.cpp
index 294b52f00c..a8eb0b2a9f 100644
--- a/core/os/thread.cpp
+++ b/core/os/thread.cpp
@@ -66,9 +66,3 @@ Error Thread::set_name(const String &p_name) {
return ERR_UNAVAILABLE;
};
-
-Thread::Thread() {
-}
-
-Thread::~Thread() {
-}
diff --git a/core/os/thread.h b/core/os/thread.h
index 76d296bcf7..005217dca7 100644
--- a/core/os/thread.h
+++ b/core/os/thread.h
@@ -63,7 +63,7 @@ protected:
static ID _main_thread_id;
- Thread();
+ Thread() {}
public:
virtual ID get_id() const = 0;
@@ -74,7 +74,7 @@ public:
static void wait_to_finish(Thread *p_thread); ///< waits until thread is finished, and deallocates it.
static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings()); ///< Static function to create a thread, will call p_callback
- virtual ~Thread();
+ virtual ~Thread() {}
};
#endif // THREAD_H