summaryrefslogtreecommitdiff
path: root/core/object
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-09-23 16:09:53 +0200
committerGitHub <noreply@github.com>2021-09-23 16:09:53 +0200
commit8c8feb3ebdeeeee89133fc22516bab94801b5a09 (patch)
tree49cc0e042c41109a25acf069f0cd479d983daa1a /core/object
parent88b347dc2787aac2d52254787cc3a91e5807c4dd (diff)
parentf9ce9a8e103b4b53ad3de032220c3e8799d52409 (diff)
Merge pull request #52946 from Faless/ext/construct_extended
Diffstat (limited to 'core/object')
-rw-r--r--core/object/class_db.cpp9
-rw-r--r--core/object/class_db.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index 8e92340c1e..8ba46e49eb 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -545,6 +545,15 @@ Object *ClassDB::instantiate(const StringName &p_class) {
return ti->creation_func();
}
+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();
+}
+
bool ClassDB::can_instantiate(const StringName &p_class) {
OBJTYPE_RLOCK;
diff --git a/core/object/class_db.h b/core/object/class_db.h
index e89c7fffd7..3a1cbf8559 100644
--- a/core/object/class_db.h
+++ b/core/object/class_db.h
@@ -234,6 +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_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);