1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-18 14:21:41 +00:00

[Core] Add ClassDB functions to retrieve/construct extensions.

Calling the constructor alone is not enough if the class to be
instantiated is not a base class.

This commit adds two functions, one for retrieving the the extension
class reference, the other to construct an instance using the
constructor and the extension class reference.
This commit is contained in:
Fabio Alessandrelli
2021-09-21 03:54:50 +02:00
parent a4b80cdad9
commit f724bd1880
4 changed files with 25 additions and 0 deletions

View File

@@ -545,6 +545,13 @@ 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);
return p_create_func();
}
bool ClassDB::can_instantiate(const StringName &p_class) {
OBJTYPE_RLOCK;