diff options
author | reduz <reduzio@gmail.com> | 2022-05-03 11:56:08 +0200 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2022-05-04 17:34:51 +0200 |
commit | de0ca3b999819a99a5dcab99f0083a760277b95e (patch) | |
tree | 3078cc65c19bdedfb25c977c48b50e44003a2802 /modules/text_server_fb | |
parent | 0a9d31a7eb9debe30cd5078688e895d2ce3f2efa (diff) |
Refactor module initialization
* Changed to use the same stages as extensions.
* Makes the initialization more coherent, helping solve problems due to lack of stages.
* Makes it easier to port between module and extension.
* removed the DRIVER initialization level (no longer needed).
Diffstat (limited to 'modules/text_server_fb')
-rw-r--r-- | modules/text_server_fb/register_types.cpp | 19 | ||||
-rw-r--r-- | modules/text_server_fb/register_types.h | 12 |
2 files changed, 20 insertions, 11 deletions
diff --git a/modules/text_server_fb/register_types.cpp b/modules/text_server_fb/register_types.cpp index 1044c3f872..fa7b87fc17 100644 --- a/modules/text_server_fb/register_types.cpp +++ b/modules/text_server_fb/register_types.cpp @@ -32,7 +32,11 @@ #include "text_server_fb.h" -void preregister_text_server_fb_types() { +void initialize_text_server_fb_module(ModuleInitializationLevel p_level) { + if (p_level != MODULE_INITIALIZATION_LEVEL_SERVERS) { + return; + } + GDREGISTER_CLASS(TextServerFallback); TextServerManager *tsman = TextServerManager::get_singleton(); if (tsman) { @@ -42,10 +46,10 @@ void preregister_text_server_fb_types() { } } -void register_text_server_fb_types() { -} - -void unregister_text_server_fb_types() { +void uninitialize_text_server_fb_module(ModuleInitializationLevel p_level) { + if (p_level != MODULE_INITIALIZATION_LEVEL_SERVERS) { + return; + } } #ifdef GDEXTENSION @@ -61,8 +65,9 @@ extern "C" { GDNativeBool GDN_EXPORT textserver_fallback_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization); - init_obj.register_server_initializer(&preregister_text_server_fb_types); - init_obj.register_server_terminator(&unregister_text_server_fb_types); + init_obj.register_initializer(&initialize_text_server_fb_module); + init_obj.register_terminator(&uninitialize_text_server_fb_module); + init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SERVERS); return init_obj.init(); } diff --git a/modules/text_server_fb/register_types.h b/modules/text_server_fb/register_types.h index 8652a8e9db..229aec2266 100644 --- a/modules/text_server_fb/register_types.h +++ b/modules/text_server_fb/register_types.h @@ -31,10 +31,14 @@ #ifndef TEXT_SERVER_FB_REGISTER_TYPES_H #define TEXT_SERVER_FB_REGISTER_TYPES_H -#define MODULE_TEXT_SERVER_FB_HAS_PREREGISTER +#ifdef GDEXTENSION +#include <godot_cpp/core/class_db.hpp> +using namespace godot; +#else +#include "modules/register_module_types.h" +#endif -void preregister_text_server_fb_types(); -void register_text_server_fb_types(); -void unregister_text_server_fb_types(); +void initialize_text_server_fb_module(ModuleInitializationLevel p_level); +void uninitialize_text_server_fb_module(ModuleInitializationLevel p_level); #endif // TEXT_SERVER_FB_REGISTER_TYPES_H |