From f9ce9a8e103b4b53ad3de032220c3e8799d52409 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Wed, 22 Sep 2021 18:33:29 +0200 Subject: [ClassDB] Unify construct/extension retrieval. --- core/object/class_db.cpp | 10 ++++++---- core/object/class_db.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'core/object') diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index 05b3dde4ed..8ba46e49eb 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -545,10 +545,12 @@ Object *ClassDB::instantiate(const StringName &p_class) { return ti->creation_func(); } -Object *ClassDB::construct_extended(Object *(*p_create_func)(), ObjectNativeExtension *p_extension) { - initializing_with_extension = true; - initializing_extension = p_extension; - initializing_extension_instance = p_extension->create_instance(p_extension->class_userdata); +Object *ClassDB::construct_object(Object *(*p_create_func)(), ObjectNativeExtension *p_extension) { + if (p_extension) { + initializing_with_extension = true; + initializing_extension = p_extension; + initializing_extension_instance = p_extension->create_instance(p_extension->class_userdata); + } return p_create_func(); } diff --git a/core/object/class_db.h b/core/object/class_db.h index 0ba9d5903c..3a1cbf8559 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -234,7 +234,7 @@ public: static bool is_parent_class(const StringName &p_class, const StringName &p_inherits); static bool can_instantiate(const StringName &p_class); static Object *instantiate(const StringName &p_class); - static Object *construct_extended(Object *(*p_create_func)(), ObjectNativeExtension *p_extension); + static Object *construct_object(Object *(*p_create_func)(), ObjectNativeExtension *p_extension); static void instance_get_native_extension_data(ObjectNativeExtension **r_extension, GDExtensionClassInstancePtr *r_extension_instance, Object *p_base); static APIType get_api_type(const StringName &p_class); -- cgit v1.2.3