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

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