diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/editor_plugin_registration.cpp (renamed from src/classes/editor_plugin.cpp) | 6 | ||||
-rw-r--r-- | src/classes/wrapped.cpp | 25 | ||||
-rw-r--r-- | src/godot.cpp | 4 |
3 files changed, 30 insertions, 5 deletions
diff --git a/src/classes/editor_plugin.cpp b/src/classes/editor_plugin_registration.cpp index ca98a89..99819be 100644 --- a/src/classes/editor_plugin.cpp +++ b/src/classes/editor_plugin_registration.cpp @@ -1,5 +1,5 @@ /**************************************************************************/ -/* editor_plugin.cpp */ +/* editor_plugin_registration.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,9 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#include <godot_cpp/classes/editor_plugin.hpp> +#include <godot_cpp/classes/editor_plugin_registration.hpp> -#include <godot_cpp/variant/string_name.hpp> +#include <godot_cpp/variant/variant.hpp> namespace godot { diff --git a/src/classes/wrapped.cpp b/src/classes/wrapped.cpp index 5b425c7..37fcf65 100644 --- a/src/classes/wrapped.cpp +++ b/src/classes/wrapped.cpp @@ -28,12 +28,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ +#include <vector> + #include <godot_cpp/classes/wrapped.hpp> #include <godot_cpp/variant/builtin_types.hpp> #include <godot_cpp/classes/object.hpp> +#include <godot_cpp/core/class_db.hpp> + namespace godot { const StringName *Wrapped::_get_extension_class_name() const { @@ -81,6 +85,11 @@ void postinitialize_handler(Wrapped *p_wrapped) { namespace internal { +std::vector<EngineClassRegistrationCallback> &get_engine_class_registration_callbacks() { + static std::vector<EngineClassRegistrationCallback> engine_class_registration_callbacks; + return engine_class_registration_callbacks; +} + GDExtensionPropertyInfo *create_c_property_list(const ::godot::List<::godot::PropertyInfo> &plist_cpp, uint32_t *r_size) { GDExtensionPropertyInfo *plist = nullptr; // Linked list size can be expensive to get so we cache it @@ -106,6 +115,22 @@ void free_c_property_list(GDExtensionPropertyInfo *plist) { memfree(plist); } +void add_engine_class_registration_callback(EngineClassRegistrationCallback p_callback) { + get_engine_class_registration_callbacks().push_back(p_callback); +} + +void register_engine_class(const StringName &p_name, const GDExtensionInstanceBindingCallbacks *p_callbacks) { + ClassDB::_register_engine_class(p_name, p_callbacks); +} + +void register_engine_classes() { + std::vector<EngineClassRegistrationCallback> &engine_class_registration_callbacks = get_engine_class_registration_callbacks(); + for (EngineClassRegistrationCallback cb : engine_class_registration_callbacks) { + cb(); + } + engine_class_registration_callbacks.clear(); +} + } // namespace internal } // namespace godot diff --git a/src/godot.cpp b/src/godot.cpp index 05413ff..ebf4400 100644 --- a/src/godot.cpp +++ b/src/godot.cpp @@ -30,7 +30,7 @@ #include <godot_cpp/godot.hpp> -#include <godot_cpp/classes/editor_plugin.hpp> +#include <godot_cpp/classes/editor_plugin_registration.hpp> #include <godot_cpp/classes/wrapped.hpp> #include <godot_cpp/core/class_db.hpp> #include <godot_cpp/core/memory.hpp> @@ -416,7 +416,7 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge ERR_FAIL_NULL_V_MSG(init_callback, false, "Initialization callback must be defined."); Variant::init_bindings(); - register_engine_classes(); + godot::internal::register_engine_classes(); return true; } |