diff --git a/core/config/engine.cpp b/core/config/engine.cpp index 0f7ead2f76e..a4d460ac7e4 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -400,8 +400,6 @@ String Engine::get_shader_cache_path() const { return shader_cache_path; } -Engine *Engine::singleton = nullptr; - Engine *Engine::get_singleton() { return singleton; } diff --git a/core/config/engine.h b/core/config/engine.h index 701cfda5667..ab03111f242 100644 --- a/core/config/engine.h +++ b/core/config/engine.h @@ -90,7 +90,7 @@ private: bool _print_header = true; - static Engine *singleton; + static inline Engine *singleton = nullptr; String write_movie_path; String shader_cache_path; diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 5e3e3569442..3732145ae6f 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -48,10 +48,6 @@ #include "modules/modules_enabled.gen.h" // For mono. #endif // TOOLS_ENABLED -const String ProjectSettings::PROJECT_DATA_DIR_NAME_SUFFIX = "godot"; - -ProjectSettings *ProjectSettings::singleton = nullptr; - ProjectSettings *ProjectSettings::get_singleton() { return singleton; } diff --git a/core/config/project_settings.h b/core/config/project_settings.h index 65fa72eaec8..7f348869cd0 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -44,7 +44,7 @@ class ProjectSettings : public Object { public: typedef HashMap CustomMap; - static const String PROJECT_DATA_DIR_NAME_SUFFIX; + static inline const String PROJECT_DATA_DIR_NAME_SUFFIX = "godot"; // Properties that are not for built in values begin from this value, so builtin ones are displayed first. constexpr static const int32_t NO_BUILTIN_ORDER_BASE = 1 << 16; @@ -116,7 +116,7 @@ protected: void _queue_changed(); void _emit_changed(); - static ProjectSettings *singleton; + static inline ProjectSettings *singleton = nullptr; Error _load_settings_text(const String &p_path); Error _load_settings_binary(const String &p_path); diff --git a/core/core_bind.cpp b/core/core_bind.cpp index ae7708074e7..d350a82a6c8 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -46,8 +46,6 @@ namespace CoreBind { ////// ResourceLoader ////// -ResourceLoader *ResourceLoader::singleton = nullptr; - Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads, CacheMode p_cache_mode) { return ::ResourceLoader::load_threaded_request(p_path, p_type_hint, p_use_sub_threads, ResourceFormatLoader::CacheMode(p_cache_mode)); } @@ -195,8 +193,6 @@ ResourceUID::ID ResourceSaver::get_resource_id_for_path(const String &p_path, bo return ::ResourceSaver::get_resource_id_for_path(p_path, p_generate); } -ResourceSaver *ResourceSaver::singleton = nullptr; - void ResourceSaver::_bind_methods() { ClassDB::bind_method(D_METHOD("save", "resource", "path", "flags"), &ResourceSaver::save, DEFVAL(""), DEFVAL((uint32_t)FLAG_NONE)); ClassDB::bind_method(D_METHOD("set_uid", "resource", "uid"), &ResourceSaver::set_uid); @@ -722,8 +718,6 @@ void OS::remove_logger(const Ref &p_logger) { logger_bind->loggers.erase(p_logger); } -OS *OS::singleton = nullptr; - void OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_entropy", "size"), &OS::get_entropy); ClassDB::bind_method(D_METHOD("get_system_ca_certificates"), &OS::get_system_ca_certificates); @@ -877,8 +871,6 @@ OS::~OS() { ////// Geometry2D ////// -Geometry2D *Geometry2D::singleton = nullptr; - Geometry2D *Geometry2D::get_singleton() { return singleton; } @@ -1138,8 +1130,6 @@ void Geometry2D::_bind_methods() { ////// Geometry3D ////// -Geometry3D *Geometry3D::singleton = nullptr; - Geometry3D *Geometry3D::get_singleton() { return singleton; } @@ -1282,8 +1272,6 @@ void Geometry3D::_bind_methods() { ////// Marshalls ////// -Marshalls *Marshalls::singleton = nullptr; - Marshalls *Marshalls::get_singleton() { return singleton; } @@ -2128,8 +2116,6 @@ void Engine::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "physics_jitter_fix"), "set_physics_jitter_fix", "get_physics_jitter_fix"); } -Engine *Engine::singleton = nullptr; - ////// EngineDebugger ////// bool EngineDebugger::is_active() { @@ -2275,8 +2261,6 @@ EngineDebugger::~EngineDebugger() { captures.clear(); } -EngineDebugger *EngineDebugger::singleton = nullptr; - void EngineDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("is_active"), &EngineDebugger::is_active); diff --git a/core/core_bind.h b/core/core_bind.h index 04f1183aa64..b1a014dad42 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -48,7 +48,7 @@ class ResourceLoader : public Object { protected: static void _bind_methods(); - static ResourceLoader *singleton; + static inline ResourceLoader *singleton = nullptr; public: enum ThreadLoadStatus { @@ -93,7 +93,7 @@ class ResourceSaver : public Object { protected: static void _bind_methods(); - static ResourceSaver *singleton; + static inline ResourceSaver *singleton = nullptr; public: enum SaverFlags { @@ -162,7 +162,7 @@ class OS : public Object { protected: static void _bind_methods(); - static OS *singleton; + static inline OS *singleton = nullptr; #ifndef DISABLE_DEPRECATED Dictionary _execute_with_pipe_bind_compat_94434(const String &p_path, const Vector &p_arguments); @@ -322,7 +322,7 @@ public: class Geometry2D : public Object { GDCLASS(Geometry2D, Object); - static Geometry2D *singleton; + static inline Geometry2D *singleton = nullptr; protected: static void _bind_methods(); @@ -388,7 +388,7 @@ public: class Geometry3D : public Object { GDCLASS(Geometry3D, Object); - static Geometry3D *singleton; + static inline Geometry3D *singleton = nullptr; protected: static void _bind_methods(); @@ -419,7 +419,7 @@ public: class Marshalls : public Object { GDCLASS(Marshalls, Object); - static Marshalls *singleton; + static inline Marshalls *singleton = nullptr; protected: static void _bind_methods(); @@ -570,7 +570,7 @@ class Engine : public Object { protected: static void _bind_methods(); - static Engine *singleton; + static inline Engine *singleton = nullptr; public: static Engine *get_singleton() { return singleton; } @@ -650,7 +650,7 @@ class EngineDebugger : public Object { protected: static void _bind_methods(); - static EngineDebugger *singleton; + static inline EngineDebugger *singleton = nullptr; public: static EngineDebugger *get_singleton() { return singleton; } diff --git a/core/core_globals.cpp b/core/core_globals.cpp deleted file mode 100644 index b164f5348a4..00000000000 --- a/core/core_globals.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************/ -/* core_globals.cpp */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* 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 "core_globals.h" - -bool CoreGlobals::leak_reporting_enabled = true; -bool CoreGlobals::print_line_enabled = true; -bool CoreGlobals::print_error_enabled = true; diff --git a/core/core_globals.h b/core/core_globals.h index 63a6a5b1739..a5aae961c6b 100644 --- a/core/core_globals.h +++ b/core/core_globals.h @@ -35,7 +35,7 @@ class CoreGlobals { public: - static bool leak_reporting_enabled; - static bool print_line_enabled; - static bool print_error_enabled; + static inline bool leak_reporting_enabled = true; + static inline bool print_line_enabled = true; + static inline bool print_error_enabled = true; }; diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp index 8d0f526130e..2035ab08afe 100644 --- a/core/debugger/engine_debugger.cpp +++ b/core/debugger/engine_debugger.cpp @@ -36,13 +36,6 @@ #include "core/debugger/script_debugger.h" #include "core/os/os.h" -EngineDebugger *EngineDebugger::singleton = nullptr; -ScriptDebugger *EngineDebugger::script_debugger = nullptr; - -HashMap EngineDebugger::profilers; -HashMap EngineDebugger::captures; -HashMap EngineDebugger::protocols; - void (*EngineDebugger::allow_focus_steal_fn)(); void EngineDebugger::register_profiler(const StringName &p_name, const Profiler &p_func) { diff --git a/core/debugger/engine_debugger.h b/core/debugger/engine_debugger.h index cfe1b6e3e9d..95b64458f6f 100644 --- a/core/debugger/engine_debugger.h +++ b/core/debugger/engine_debugger.h @@ -91,12 +91,12 @@ private: uint32_t poll_every = 0; protected: - static EngineDebugger *singleton; - static ScriptDebugger *script_debugger; + static inline EngineDebugger *singleton = nullptr; + static inline ScriptDebugger *script_debugger = nullptr; - static HashMap profilers; - static HashMap captures; - static HashMap protocols; + static inline HashMap profilers; + static inline HashMap captures; + static inline HashMap protocols; static void (*allow_focus_steal_fn)(); diff --git a/core/debugger/script_debugger.cpp b/core/debugger/script_debugger.cpp index e522d9bacb1..777cfe700ac 100644 --- a/core/debugger/script_debugger.cpp +++ b/core/debugger/script_debugger.cpp @@ -32,9 +32,6 @@ #include "core/debugger/engine_debugger.h" -thread_local int ScriptDebugger::lines_left = -1; -thread_local int ScriptDebugger::depth = -1; -thread_local ScriptLanguage *ScriptDebugger::break_lang = nullptr; thread_local Vector ScriptDebugger::error_stack_info; void ScriptDebugger::set_lines_left(int p_left) { diff --git a/core/debugger/script_debugger.h b/core/debugger/script_debugger.h index 0a5ffe78e31..aa63d5e11e7 100644 --- a/core/debugger/script_debugger.h +++ b/core/debugger/script_debugger.h @@ -43,9 +43,9 @@ class ScriptDebugger { HashMap> breakpoints; - static thread_local int lines_left; - static thread_local int depth; - static thread_local ScriptLanguage *break_lang; + static inline thread_local int lines_left = -1; + static inline thread_local int depth = -1; + static inline thread_local ScriptLanguage *break_lang = nullptr; static thread_local Vector error_stack_info; public: diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp index ea314b71226..77b24ccd21e 100644 --- a/core/extension/gdextension.cpp +++ b/core/extension/gdextension.cpp @@ -686,8 +686,6 @@ void GDExtension::_register_get_classes_used_callback(GDExtensionClassLibraryPtr #endif } -HashMap GDExtension::gdextension_interface_functions; - void GDExtension::register_interface_function(const StringName &p_function_name, GDExtensionInterfaceFunctionPtr p_function_pointer) { ERR_FAIL_COND_MSG(gdextension_interface_functions.has(p_function_name), vformat("Attempt to register interface function '%s', which appears to be already registered.", p_function_name)); gdextension_interface_functions.insert(p_function_name, p_function_pointer); @@ -1050,10 +1048,6 @@ PackedStringArray GDExtension::get_classes_used() const { return ret; } -Vector GDExtensionEditorPlugins::extension_classes; -GDExtensionEditorPlugins::EditorPluginRegisterFunc GDExtensionEditorPlugins::editor_node_add_plugin = nullptr; -GDExtensionEditorPlugins::EditorPluginRegisterFunc GDExtensionEditorPlugins::editor_node_remove_plugin = nullptr; - void GDExtensionEditorPlugins::add_extension_class(const StringName &p_class_name) { if (editor_node_add_plugin) { editor_node_add_plugin(p_class_name); @@ -1070,9 +1064,6 @@ void GDExtensionEditorPlugins::remove_extension_class(const StringName &p_class_ } } -GDExtensionEditorHelp::EditorHelpLoadXmlBufferFunc GDExtensionEditorHelp::editor_help_load_xml_buffer = nullptr; -GDExtensionEditorHelp::EditorHelpRemoveClassFunc GDExtensionEditorHelp::editor_help_remove_class = nullptr; - void GDExtensionEditorHelp::load_xml_buffer(const uint8_t *p_buffer, int p_size) { ERR_FAIL_NULL(editor_help_load_xml_buffer); editor_help_load_xml_buffer(p_buffer, p_size); diff --git a/core/extension/gdextension.h b/core/extension/gdextension.h index a40f7af4576..0daf57d6da9 100644 --- a/core/extension/gdextension.h +++ b/core/extension/gdextension.h @@ -115,7 +115,7 @@ class GDExtension : public Resource { void clear_instance_bindings(); #endif - static HashMap gdextension_interface_functions; + static inline HashMap gdextension_interface_functions; protected: static void _bind_methods(); @@ -189,7 +189,7 @@ public: #ifdef TOOLS_ENABLED class GDExtensionEditorPlugins { private: - static Vector extension_classes; + static inline Vector extension_classes; protected: friend class EditorNode; @@ -197,8 +197,8 @@ protected: // Since this in core, we can't directly reference EditorNode, so it will // set these function pointers in its constructor. typedef void (*EditorPluginRegisterFunc)(const StringName &p_class_name); - static EditorPluginRegisterFunc editor_node_add_plugin; - static EditorPluginRegisterFunc editor_node_remove_plugin; + static inline EditorPluginRegisterFunc editor_node_add_plugin = nullptr; + static inline EditorPluginRegisterFunc editor_node_remove_plugin = nullptr; public: static void add_extension_class(const StringName &p_class_name); @@ -218,10 +218,10 @@ protected: // is initialized even _before_ it gets instantiated, as we need to rely on // this method while initializing the engine. typedef void (*EditorHelpLoadXmlBufferFunc)(const uint8_t *p_buffer, int p_size); - static EditorHelpLoadXmlBufferFunc editor_help_load_xml_buffer; + static inline EditorHelpLoadXmlBufferFunc editor_help_load_xml_buffer = nullptr; typedef void (*EditorHelpRemoveClassFunc)(const String &p_class); - static EditorHelpRemoveClassFunc editor_help_remove_class; + static inline EditorHelpRemoveClassFunc editor_help_remove_class = nullptr; public: static void load_xml_buffer(const uint8_t *p_buffer, int p_size); diff --git a/core/extension/gdextension_manager.cpp b/core/extension/gdextension_manager.cpp index ae570f77593..07e7588bac2 100644 --- a/core/extension/gdextension_manager.cpp +++ b/core/extension/gdextension_manager.cpp @@ -411,8 +411,6 @@ void GDExtensionManager::_bind_methods() { ADD_SIGNAL(MethodInfo("extension_unloading", PropertyInfo(Variant::OBJECT, "extension", PROPERTY_HINT_RESOURCE_TYPE, "GDExtension"))); } -GDExtensionManager *GDExtensionManager::singleton = nullptr; - GDExtensionManager::GDExtensionManager() { ERR_FAIL_COND(singleton != nullptr); singleton = this; diff --git a/core/extension/gdextension_manager.h b/core/extension/gdextension_manager.h index 1523c07c32e..e0053e8a47d 100644 --- a/core/extension/gdextension_manager.h +++ b/core/extension/gdextension_manager.h @@ -41,7 +41,7 @@ class GDExtensionManager : public Object { static void _bind_methods(); - static GDExtensionManager *singleton; + static inline GDExtensionManager *singleton = nullptr; public: enum LoadStatus { diff --git a/core/extension/gdextension_special_compat_hashes.cpp b/core/extension/gdextension_special_compat_hashes.cpp index 154fdc654e0..b923c14fcc7 100644 --- a/core/extension/gdextension_special_compat_hashes.cpp +++ b/core/extension/gdextension_special_compat_hashes.cpp @@ -35,8 +35,6 @@ #include "core/object/class_db.h" #include "core/variant/variant.h" -HashMap> GDExtensionSpecialCompatHashes::mappings; - bool GDExtensionSpecialCompatHashes::lookup_current_hash(const StringName &p_class, const StringName &p_method, uint32_t p_legacy_hash, uint32_t *r_current_hash) { LocalVector *methods = mappings.getptr(p_class); if (!methods) { diff --git a/core/extension/gdextension_special_compat_hashes.h b/core/extension/gdextension_special_compat_hashes.h index 9cfb9208564..2f3cd146ae3 100644 --- a/core/extension/gdextension_special_compat_hashes.h +++ b/core/extension/gdextension_special_compat_hashes.h @@ -47,7 +47,7 @@ class GDExtensionSpecialCompatHashes { uint32_t current_hash; }; - static HashMap> mappings; + static inline HashMap> mappings; public: static void initialize(); diff --git a/core/input/input.cpp b/core/input/input.cpp index 6b9fec6f600..1ee99764d21 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -73,8 +73,6 @@ static const char *_joy_axes[(size_t)JoyAxis::SDL_MAX] = { "righttrigger", }; -Input *Input::singleton = nullptr; - void (*Input::set_mouse_mode_func)(Input::MouseMode) = nullptr; Input::MouseMode (*Input::get_mouse_mode_func)() = nullptr; void (*Input::set_mouse_mode_override_func)(Input::MouseMode) = nullptr; diff --git a/core/input/input.h b/core/input/input.h index e7abf746dd7..10d357a1f92 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -41,7 +41,7 @@ class Input : public Object { GDCLASS(Input, Object); _THREAD_SAFE_CLASS_ - static Input *singleton; + static inline Input *singleton = nullptr; static constexpr uint64_t MAX_EVENT = 32; diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 85c35c05b3a..7e7dc762aaa 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -35,9 +35,6 @@ #include "core/os/keyboard.h" #include "core/os/os.h" -const int InputEvent::DEVICE_ID_EMULATION = -1; -const int InputEvent::DEVICE_ID_INTERNAL = -2; - void InputEvent::set_device(int p_device) { device = p_device; emit_changed(); diff --git a/core/input/input_event.h b/core/input/input_event.h index 6e308f6c120..8bc9c5cd6c4 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -61,8 +61,8 @@ protected: static void _bind_methods(); public: - static const int DEVICE_ID_EMULATION; - static const int DEVICE_ID_INTERNAL; + static constexpr int DEVICE_ID_EMULATION = -1; + static constexpr int DEVICE_ID_INTERNAL = -2; void set_device(int p_device); int get_device() const; diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index ea03c25c729..02f24c66c08 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -37,10 +37,6 @@ #include "core/os/os.h" #include "core/variant/typed_array.h" -InputMap *InputMap::singleton = nullptr; - -int InputMap::ALL_DEVICES = -1; - void InputMap::_bind_methods() { ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action); ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions); diff --git a/core/input/input_map.h b/core/input/input_map.h index 00bc1550a2b..5d24c06e02b 100644 --- a/core/input/input_map.h +++ b/core/input/input_map.h @@ -45,7 +45,7 @@ public: /** * A special value used to signify that a given Action can be triggered by any device */ - static int ALL_DEVICES; + static constexpr int ALL_DEVICES = -1; struct Action { int id; @@ -58,7 +58,7 @@ public: static constexpr float DEFAULT_TOGGLE_DEADZONE = 0.5f; private: - static InputMap *singleton; + static inline InputMap *singleton = nullptr; mutable HashMap input_map; HashMap>> default_builtin_cache; diff --git a/core/io/compression.cpp b/core/io/compression.cpp index 79f37db1328..28a975e2c6e 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -35,7 +35,6 @@ #include "thirdparty/misc/fastlz.h" -#include #include #ifdef BROTLI_ENABLED @@ -364,10 +363,3 @@ int Compression::decompress_dynamic(Vector *p_dst_vect, int p_max_dst_s return Z_OK; } } - -int Compression::zlib_level = Z_DEFAULT_COMPRESSION; -int Compression::gzip_level = Z_DEFAULT_COMPRESSION; -int Compression::zstd_level = 3; -bool Compression::zstd_long_distance_matching = false; -int Compression::zstd_window_log_size = 27; // ZSTD_WINDOWLOG_LIMIT_DEFAULT -int Compression::gzip_chunk = 16384; diff --git a/core/io/compression.h b/core/io/compression.h index 08468de9d2e..a55c7c80d05 100644 --- a/core/io/compression.h +++ b/core/io/compression.h @@ -33,14 +33,16 @@ #include "core/templates/vector.h" #include "core/typedefs.h" +#include + class Compression { public: - static int zlib_level; - static int gzip_level; - static int zstd_level; - static bool zstd_long_distance_matching; - static int zstd_window_log_size; - static int gzip_chunk; + static inline int zlib_level = Z_DEFAULT_COMPRESSION; + static inline int gzip_level = Z_DEFAULT_COMPRESSION; + static inline int zstd_level = 3; + static inline bool zstd_long_distance_matching = false; + static inline int zstd_window_log_size = 27; // ZSTD_WINDOWLOG_LIMIT_DEFAULT + static inline int gzip_chunk = 16384; enum Mode : int32_t { MODE_FASTLZ, diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp index 02f270dac9b..8e29af7d541 100644 --- a/core/io/dir_access.cpp +++ b/core/io/dir_access.cpp @@ -36,8 +36,6 @@ #include "core/os/time.h" #include "core/templates/local_vector.h" -thread_local Error DirAccess::last_dir_open_error = OK; - String DirAccess::_get_root_path() const { switch (_access_type) { case ACCESS_RESOURCES: diff --git a/core/io/dir_access.h b/core/io/dir_access.h index 511a414f1c6..0cbb42779f1 100644 --- a/core/io/dir_access.h +++ b/core/io/dir_access.h @@ -56,7 +56,7 @@ private: Error _copy_dir(Ref &p_target_da, const String &p_to, int p_chmod_flags, bool p_copy_links); PackedStringArray _get_contents(bool p_directories); - thread_local static Error last_dir_open_error; + static inline thread_local Error last_dir_open_error = OK; bool include_navigational = false; bool include_hidden = false; diff --git a/core/io/dtls_server.cpp b/core/io/dtls_server.cpp index a84fff81fee..cdb2235b5fe 100644 --- a/core/io/dtls_server.cpp +++ b/core/io/dtls_server.cpp @@ -30,9 +30,6 @@ #include "dtls_server.h" -DTLSServer *(*DTLSServer::_create)(bool p_notify_postinitialize) = nullptr; -bool DTLSServer::available = false; - DTLSServer *DTLSServer::create(bool p_notify_postinitialize) { if (_create) { return _create(p_notify_postinitialize); diff --git a/core/io/dtls_server.h b/core/io/dtls_server.h index e22a0eff8f0..3417d150352 100644 --- a/core/io/dtls_server.h +++ b/core/io/dtls_server.h @@ -37,10 +37,10 @@ class DTLSServer : public RefCounted { GDCLASS(DTLSServer, RefCounted); protected: - static DTLSServer *(*_create)(bool p_notify_postinitialize); + static inline DTLSServer *(*_create)(bool p_notify_postinitialize) = nullptr; static void _bind_methods(); - static bool available; + static inline bool available = false; public: static bool is_available(); diff --git a/core/io/file_access.cpp b/core/io/file_access.cpp index 68b85cd1d17..7b01111488d 100644 --- a/core/io/file_access.cpp +++ b/core/io/file_access.cpp @@ -40,13 +40,6 @@ #include "core/os/os.h" #include "core/os/time.h" -FileAccess::CreateFunc FileAccess::create_func[ACCESS_MAX] = {}; - -FileAccess::FileCloseFailNotify FileAccess::close_fail_notify = nullptr; - -bool FileAccess::backup_save = false; -thread_local Error FileAccess::last_file_open_error = OK; - Ref FileAccess::create(AccessType p_access) { ERR_FAIL_INDEX_V(p_access, ACCESS_MAX, nullptr); ERR_FAIL_NULL_V(create_func[p_access], nullptr); diff --git a/core/io/file_access.h b/core/io/file_access.h index 1947da853da..30f27218957 100644 --- a/core/io/file_access.h +++ b/core/io/file_access.h @@ -112,7 +112,7 @@ protected: virtual int64_t _get_size(const String &p_file) = 0; virtual void _set_access_type(AccessType p_access); - static FileCloseFailNotify close_fail_notify; + static inline FileCloseFailNotify close_fail_notify = nullptr; #ifndef DISABLE_DEPRECATED static Ref _open_encrypted_bind_compat_98918(const String &p_path, ModeFlags p_mode_flags, const Vector &p_key); @@ -136,11 +136,11 @@ protected: #endif private: - static bool backup_save; - thread_local static Error last_file_open_error; + static inline bool backup_save = false; + static inline thread_local Error last_file_open_error = OK; AccessType _access_type = ACCESS_FILESYSTEM; - static CreateFunc create_func[ACCESS_MAX]; /** default file access creation function for a platform */ + static inline CreateFunc create_func[ACCESS_MAX]; /** default file access creation function for a platform */ template static Ref _create_builtin() { return memnew(T); diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 788825f3f33..58535ed3eaf 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -158,8 +158,6 @@ void PackedData::clear() { root = memnew(PackedDir); } -PackedData *PackedData::singleton = nullptr; - PackedData::PackedData() { singleton = this; root = memnew(PackedDir); diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 9a482db75b7..1d7b59006ba 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -102,7 +102,7 @@ private: PackedDir *root = nullptr; - static PackedData *singleton; + static inline PackedData *singleton = nullptr; bool disabled = false; void _free_packed_dirs(PackedDir *p_dir); diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index 047b27cf823..16c0bcd28d6 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -34,8 +34,6 @@ #include "core/io/file_access.h" -ZipArchive *ZipArchive::instance = nullptr; - extern "C" { struct ZipData { diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index e1f4439dfd5..1713bced017 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -53,7 +53,7 @@ private: HashMap files; - static ZipArchive *instance; + static inline ZipArchive *instance = nullptr; public: void close_handle(unzFile p_file) const; diff --git a/core/io/image.cpp b/core/io/image.cpp index 86038fb271c..f3b6c8e21b2 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -80,32 +80,6 @@ const char *Image::format_names[Image::FORMAT_MAX] = { "ASTC_8x8_HDR", }; -// External saver function pointers. - -SavePNGFunc Image::save_png_func = nullptr; -SaveJPGFunc Image::save_jpg_func = nullptr; -SaveEXRFunc Image::save_exr_func = nullptr; -SaveWebPFunc Image::save_webp_func = nullptr; -SaveDDSFunc Image::save_dds_func = nullptr; - -SavePNGBufferFunc Image::save_png_buffer_func = nullptr; -SaveJPGBufferFunc Image::save_jpg_buffer_func = nullptr; -SaveEXRBufferFunc Image::save_exr_buffer_func = nullptr; -SaveWebPBufferFunc Image::save_webp_buffer_func = nullptr; -SaveDDSBufferFunc Image::save_dds_buffer_func = nullptr; - -// External loader function pointers. - -ImageMemLoadFunc Image::_png_mem_loader_func = nullptr; -ImageMemLoadFunc Image::_png_mem_unpacker_func = nullptr; -ImageMemLoadFunc Image::_jpg_mem_loader_func = nullptr; -ImageMemLoadFunc Image::_webp_mem_loader_func = nullptr; -ImageMemLoadFunc Image::_tga_mem_loader_func = nullptr; -ImageMemLoadFunc Image::_bmp_mem_loader_func = nullptr; -ScalableImageMemLoadFunc Image::_svg_scalable_mem_loader_func = nullptr; -ImageMemLoadFunc Image::_ktx_mem_loader_func = nullptr; -ImageMemLoadFunc Image::_dds_mem_loader_func = nullptr; - // External VRAM compression function pointers. void (*Image::_image_compress_bc_func)(Image *, Image::UsedChannels) = nullptr; diff --git a/core/io/image.h b/core/io/image.h index 3cb57a3a01c..4bd125adcc7 100644 --- a/core/io/image.h +++ b/core/io/image.h @@ -184,28 +184,28 @@ public: // External saver function pointers. - static SavePNGFunc save_png_func; - static SaveJPGFunc save_jpg_func; - static SaveEXRFunc save_exr_func; - static SaveWebPFunc save_webp_func; - static SaveDDSFunc save_dds_func; - static SavePNGBufferFunc save_png_buffer_func; - static SaveEXRBufferFunc save_exr_buffer_func; - static SaveJPGBufferFunc save_jpg_buffer_func; - static SaveWebPBufferFunc save_webp_buffer_func; - static SaveDDSBufferFunc save_dds_buffer_func; + static inline SavePNGFunc save_png_func = nullptr; + static inline SaveJPGFunc save_jpg_func = nullptr; + static inline SaveEXRFunc save_exr_func = nullptr; + static inline SaveWebPFunc save_webp_func = nullptr; + static inline SaveDDSFunc save_dds_func = nullptr; + static inline SavePNGBufferFunc save_png_buffer_func = nullptr; + static inline SaveEXRBufferFunc save_exr_buffer_func = nullptr; + static inline SaveJPGBufferFunc save_jpg_buffer_func = nullptr; + static inline SaveWebPBufferFunc save_webp_buffer_func = nullptr; + static inline SaveDDSBufferFunc save_dds_buffer_func = nullptr; // External loader function pointers. - static ImageMemLoadFunc _png_mem_loader_func; - static ImageMemLoadFunc _png_mem_unpacker_func; - static ImageMemLoadFunc _jpg_mem_loader_func; - static ImageMemLoadFunc _webp_mem_loader_func; - static ImageMemLoadFunc _tga_mem_loader_func; - static ImageMemLoadFunc _bmp_mem_loader_func; - static ScalableImageMemLoadFunc _svg_scalable_mem_loader_func; - static ImageMemLoadFunc _ktx_mem_loader_func; - static ImageMemLoadFunc _dds_mem_loader_func; + static inline ImageMemLoadFunc _png_mem_loader_func = nullptr; + static inline ImageMemLoadFunc _png_mem_unpacker_func = nullptr; + static inline ImageMemLoadFunc _jpg_mem_loader_func = nullptr; + static inline ImageMemLoadFunc _webp_mem_loader_func = nullptr; + static inline ImageMemLoadFunc _tga_mem_loader_func = nullptr; + static inline ImageMemLoadFunc _bmp_mem_loader_func = nullptr; + static inline ScalableImageMemLoadFunc _svg_scalable_mem_loader_func = nullptr; + static inline ImageMemLoadFunc _ktx_mem_loader_func = nullptr; + static inline ImageMemLoadFunc _dds_mem_loader_func = nullptr; // External VRAM compression function pointers. diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 51c4c49bc58..df36c515cfa 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -124,8 +124,6 @@ Ref ImageLoader::recognize(const String &p_extension) { return nullptr; } -Vector> ImageLoader::loader; - void ImageLoader::add_image_format_loader(Ref p_loader) { loader.push_back(p_loader); } diff --git a/core/io/image_loader.h b/core/io/image_loader.h index 00642da083a..cbe012f120e 100644 --- a/core/io/image_loader.h +++ b/core/io/image_loader.h @@ -85,7 +85,7 @@ public: }; class ImageLoader { - static Vector> loader; + static inline Vector> loader; friend class ResourceFormatLoaderImage; protected: diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 3c67a8f8942..d93e3953a62 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -324,8 +324,6 @@ void IP::_bind_methods() { BIND_ENUM_CONSTANT(TYPE_ANY); } -IP *IP::singleton = nullptr; - IP *IP::get_singleton() { return singleton; } diff --git a/core/io/ip.h b/core/io/ip.h index 9d23a465b5c..bab9625c7e1 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -67,7 +67,7 @@ private: _IP_ResolverPrivate *resolver = nullptr; protected: - static IP *singleton; + static inline IP *singleton = nullptr; static void _bind_methods(); PackedStringArray _get_local_addresses() const; diff --git a/core/io/logger.cpp b/core/io/logger.cpp index aa47343965e..30ef65078f2 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -49,8 +49,6 @@ bool Logger::should_log(bool p_err) { return (!p_err || CoreGlobals::print_error_enabled) && (p_err || CoreGlobals::print_line_enabled); } -bool Logger::_flush_stdout_on_print = true; - void Logger::set_flush_stdout_on_print(bool value) { _flush_stdout_on_print = value; } diff --git a/core/io/logger.h b/core/io/logger.h index 7d23103bbc1..dc46647a026 100644 --- a/core/io/logger.h +++ b/core/io/logger.h @@ -43,7 +43,7 @@ class Logger { protected: bool should_log(bool p_err); - static bool _flush_stdout_on_print; + static inline bool _flush_stdout_on_print = true; public: enum ErrorType { diff --git a/core/io/packet_peer_dtls.cpp b/core/io/packet_peer_dtls.cpp index 5ac0dff7946..b37b79914e0 100644 --- a/core/io/packet_peer_dtls.cpp +++ b/core/io/packet_peer_dtls.cpp @@ -30,9 +30,6 @@ #include "packet_peer_dtls.h" -PacketPeerDTLS *(*PacketPeerDTLS::_create)(bool p_notify_postinitialize) = nullptr; -bool PacketPeerDTLS::available = false; - PacketPeerDTLS *PacketPeerDTLS::create(bool p_notify_postinitialize) { if (_create) { return _create(p_notify_postinitialize); diff --git a/core/io/packet_peer_dtls.h b/core/io/packet_peer_dtls.h index 5de9640dd54..5676ea50d3b 100644 --- a/core/io/packet_peer_dtls.h +++ b/core/io/packet_peer_dtls.h @@ -37,10 +37,10 @@ class PacketPeerDTLS : public PacketPeer { GDCLASS(PacketPeerDTLS, PacketPeer); protected: - static PacketPeerDTLS *(*_create)(bool p_notify_postinitialize); + static inline PacketPeerDTLS *(*_create)(bool p_notify_postinitialize) = nullptr; static void _bind_methods(); - static bool available; + static inline bool available = false; public: enum Status { diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 98511f02bb5..a0a156ad445 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -2506,8 +2506,6 @@ void ResourceFormatSaverBinary::get_recognized_extensions(const Ref &p } } -ResourceFormatSaverBinary *ResourceFormatSaverBinary::singleton = nullptr; - ResourceFormatSaverBinary::ResourceFormatSaverBinary() { singleton = this; } diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index dfd2cd6f55a..f4e845ef6d4 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -180,7 +180,7 @@ public: class ResourceFormatSaverBinary : public ResourceFormatSaver { public: - static ResourceFormatSaverBinary *singleton; + static inline ResourceFormatSaverBinary *singleton = nullptr; virtual Error save(const Ref &p_resource, const String &p_path, uint32_t p_flags = 0) override; virtual Error set_uid(const String &p_path, ResourceUID::ID p_uid) override; virtual bool recognize(const Ref &p_resource) const override; diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index 81c3deb945e..51cdbb7ae47 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -36,8 +36,6 @@ #include "core/os/os.h" #include "core/variant/variant_parser.h" -ResourceFormatImporterLoadOnStartup ResourceImporter::load_on_startup = nullptr; - bool ResourceFormatImporter::SortImporterByName::operator()(const Ref &p_a, const Ref &p_b) const { return p_a->get_importer_name() < p_b->get_importer_name(); } @@ -545,8 +543,6 @@ String ResourceFormatImporter::get_import_settings_hash() const { return hash.md5_text(); } -ResourceFormatImporter *ResourceFormatImporter::singleton = nullptr; - ResourceFormatImporter::ResourceFormatImporter() { singleton = this; } diff --git a/core/io/resource_importer.h b/core/io/resource_importer.h index ff1baad93fd..f8be5f505d8 100644 --- a/core/io/resource_importer.h +++ b/core/io/resource_importer.h @@ -50,7 +50,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool p_load, bool *r_valid = nullptr) const; - static ResourceFormatImporter *singleton; + static inline ResourceFormatImporter *singleton = nullptr; //need them to stay in order to compute the settings hash struct SortImporterByName { @@ -109,7 +109,7 @@ protected: static void _bind_methods(); public: - static ResourceFormatImporterLoadOnStartup load_on_startup; + static inline ResourceFormatImporterLoadOnStartup load_on_startup = nullptr; virtual String get_importer_name() const = 0; virtual String get_visible_name() const = 0; diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp index cff8c5d2dd4..716dcb8e710 100644 --- a/editor/gui/editor_file_dialog.cpp +++ b/editor/gui/editor_file_dialog.cpp @@ -51,12 +51,6 @@ #include "scene/gui/texture_rect.h" #include "servers/display_server.h" -EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func = nullptr; -EditorFileDialog::GetIconFunc EditorFileDialog::get_thumbnail_func = nullptr; - -EditorFileDialog::RegisterFunc EditorFileDialog::register_func = nullptr; -EditorFileDialog::RegisterFunc EditorFileDialog::unregister_func = nullptr; - void EditorFileDialog::_native_popup() { // Show native dialog directly. String root; @@ -1983,10 +1977,6 @@ void EditorFileDialog::_go_forward() { dir_next->set_disabled(local_history_pos == local_history.size() - 1); } -bool EditorFileDialog::default_show_hidden_files = false; - -EditorFileDialog::DisplayMode EditorFileDialog::default_display_mode = DISPLAY_THUMBNAILS; - void EditorFileDialog::set_display_mode(DisplayMode p_mode) { if (display_mode == p_mode) { return; diff --git a/editor/gui/editor_file_dialog.h b/editor/gui/editor_file_dialog.h index 1bde60ab535..30c6a32f614 100644 --- a/editor/gui/editor_file_dialog.h +++ b/editor/gui/editor_file_dialog.h @@ -72,10 +72,10 @@ public: typedef Ref (*GetIconFunc)(const String &); typedef void (*RegisterFunc)(EditorFileDialog *); - static GetIconFunc get_icon_func; - static GetIconFunc get_thumbnail_func; - static RegisterFunc register_func; - static RegisterFunc unregister_func; + static inline GetIconFunc get_icon_func = nullptr; + static inline GetIconFunc get_thumbnail_func = nullptr; + static inline RegisterFunc register_func = nullptr; + static inline RegisterFunc unregister_func = nullptr; private: enum ItemMenu { @@ -159,8 +159,8 @@ private: int preview_wheel_index = 0; float preview_wheel_timeout = 0.0f; - static bool default_show_hidden_files; - static DisplayMode default_display_mode; + static inline bool default_show_hidden_files = false; + static inline DisplayMode default_display_mode = DISPLAY_THUMBNAILS; bool show_hidden_files; DisplayMode display_mode;