Inline static variables (part 1)

This commit is contained in:
kobewi 2025-04-28 20:27:50 +02:00
parent 67c96c89cc
commit 5af4bef46f
52 changed files with 85 additions and 247 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -44,7 +44,7 @@ class ProjectSettings : public Object {
public:
typedef HashMap<String, Variant> 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);

View file

@ -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<Logger> &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);

View file

@ -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<String> &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; }

View file

@ -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;

View file

@ -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;
};

View file

@ -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<StringName, EngineDebugger::Profiler> EngineDebugger::profilers;
HashMap<StringName, EngineDebugger::Capture> EngineDebugger::captures;
HashMap<String, EngineDebugger::CreatePeerFunc> EngineDebugger::protocols;
void (*EngineDebugger::allow_focus_steal_fn)();
void EngineDebugger::register_profiler(const StringName &p_name, const Profiler &p_func) {

View file

@ -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<StringName, Profiler> profilers;
static HashMap<StringName, Capture> captures;
static HashMap<String, CreatePeerFunc> protocols;
static inline HashMap<StringName, Profiler> profilers;
static inline HashMap<StringName, Capture> captures;
static inline HashMap<String, CreatePeerFunc> protocols;
static void (*allow_focus_steal_fn)();

View file

@ -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::StackInfo> ScriptDebugger::error_stack_info;
void ScriptDebugger::set_lines_left(int p_left) {

View file

@ -43,9 +43,9 @@ class ScriptDebugger {
HashMap<int, HashSet<StringName>> 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<StackInfo> error_stack_info;
public:

View file

@ -686,8 +686,6 @@ void GDExtension::_register_get_classes_used_callback(GDExtensionClassLibraryPtr
#endif
}
HashMap<StringName, GDExtensionInterfaceFunctionPtr> 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<StringName> 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);

View file

@ -115,7 +115,7 @@ class GDExtension : public Resource {
void clear_instance_bindings();
#endif
static HashMap<StringName, GDExtensionInterfaceFunctionPtr> gdextension_interface_functions;
static inline HashMap<StringName, GDExtensionInterfaceFunctionPtr> gdextension_interface_functions;
protected:
static void _bind_methods();
@ -189,7 +189,7 @@ public:
#ifdef TOOLS_ENABLED
class GDExtensionEditorPlugins {
private:
static Vector<StringName> extension_classes;
static inline Vector<StringName> 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);

View file

@ -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;

View file

@ -41,7 +41,7 @@ class GDExtensionManager : public Object {
static void _bind_methods();
static GDExtensionManager *singleton;
static inline GDExtensionManager *singleton = nullptr;
public:
enum LoadStatus {

View file

@ -35,8 +35,6 @@
#include "core/object/class_db.h"
#include "core/variant/variant.h"
HashMap<StringName, LocalVector<GDExtensionSpecialCompatHashes::Mapping>> 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<Mapping> *methods = mappings.getptr(p_class);
if (!methods) {

View file

@ -47,7 +47,7 @@ class GDExtensionSpecialCompatHashes {
uint32_t current_hash;
};
static HashMap<StringName, LocalVector<Mapping>> mappings;
static inline HashMap<StringName, LocalVector<Mapping>> mappings;
public:
static void initialize();

View file

@ -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;

View file

@ -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;

View file

@ -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();

View file

@ -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;

View file

@ -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);

View file

@ -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<StringName, Action> input_map;
HashMap<String, List<Ref<InputEvent>>> default_builtin_cache;

View file

@ -35,7 +35,6 @@
#include "thirdparty/misc/fastlz.h"
#include <zlib.h>
#include <zstd.h>
#ifdef BROTLI_ENABLED
@ -364,10 +363,3 @@ int Compression::decompress_dynamic(Vector<uint8_t> *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;

View file

@ -33,14 +33,16 @@
#include "core/templates/vector.h"
#include "core/typedefs.h"
#include <zlib.h>
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,

View file

@ -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:

View file

@ -56,7 +56,7 @@ private:
Error _copy_dir(Ref<DirAccess> &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;

View file

@ -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);

View file

@ -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();

View file

@ -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> FileAccess::create(AccessType p_access) {
ERR_FAIL_INDEX_V(p_access, ACCESS_MAX, nullptr);
ERR_FAIL_NULL_V(create_func[p_access], nullptr);

View file

@ -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<FileAccess> _open_encrypted_bind_compat_98918(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &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 <typename T>
static Ref<FileAccess> _create_builtin() {
return memnew(T);

View file

@ -158,8 +158,6 @@ void PackedData::clear() {
root = memnew(PackedDir);
}
PackedData *PackedData::singleton = nullptr;
PackedData::PackedData() {
singleton = this;
root = memnew(PackedDir);

View file

@ -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);

View file

@ -34,8 +34,6 @@
#include "core/io/file_access.h"
ZipArchive *ZipArchive::instance = nullptr;
extern "C" {
struct ZipData {

View file

@ -53,7 +53,7 @@ private:
HashMap<String, File> files;
static ZipArchive *instance;
static inline ZipArchive *instance = nullptr;
public:
void close_handle(unzFile p_file) const;

View file

@ -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;

View file

@ -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.

View file

@ -124,8 +124,6 @@ Ref<ImageFormatLoader> ImageLoader::recognize(const String &p_extension) {
return nullptr;
}
Vector<Ref<ImageFormatLoader>> ImageLoader::loader;
void ImageLoader::add_image_format_loader(Ref<ImageFormatLoader> p_loader) {
loader.push_back(p_loader);
}

View file

@ -85,7 +85,7 @@ public:
};
class ImageLoader {
static Vector<Ref<ImageFormatLoader>> loader;
static inline Vector<Ref<ImageFormatLoader>> loader;
friend class ResourceFormatLoaderImage;
protected:

View file

@ -324,8 +324,6 @@ void IP::_bind_methods() {
BIND_ENUM_CONSTANT(TYPE_ANY);
}
IP *IP::singleton = nullptr;
IP *IP::get_singleton() {
return singleton;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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 {

View file

@ -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);

View file

@ -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 {

View file

@ -2506,8 +2506,6 @@ void ResourceFormatSaverBinary::get_recognized_extensions(const Ref<Resource> &p
}
}
ResourceFormatSaverBinary *ResourceFormatSaverBinary::singleton = nullptr;
ResourceFormatSaverBinary::ResourceFormatSaverBinary() {
singleton = this;
}

View file

@ -180,7 +180,7 @@ public:
class ResourceFormatSaverBinary : public ResourceFormatSaver {
public:
static ResourceFormatSaverBinary *singleton;
static inline ResourceFormatSaverBinary *singleton = nullptr;
virtual Error save(const Ref<Resource> &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<Resource> &p_resource) const override;

View file

@ -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<ResourceImporter> &p_a, const Ref<ResourceImporter> &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;
}

View file

@ -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;

View file

@ -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;

View file

@ -72,10 +72,10 @@ public:
typedef Ref<Texture2D> (*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;