1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Fix wrapping Object's in GDExtension that aren't exposed

This commit is contained in:
David Snopek
2023-06-09 12:30:39 -05:00
parent 72b59325cf
commit 36f4b99638
2 changed files with 25 additions and 11 deletions

View File

@@ -1719,6 +1719,30 @@ uint32_t Object::get_edited_version() const {
}
#endif
StringName Object::get_class_name_for_extension(const GDExtension *p_library) const {
// Only return the class name per the extension if it matches the given p_library.
if (_extension && _extension->library == p_library) {
return _extension->class_name;
}
// Extensions only have wrapper classes for classes exposed in ClassDB.
const StringName *class_name = _get_class_namev();
if (ClassDB::is_class_exposed(*class_name)) {
return *class_name;
}
// Find the nearest parent class that's exposed.
StringName parent_class = ClassDB::get_parent_class(*class_name);
while (parent_class != StringName()) {
if (ClassDB::is_class_exposed(parent_class)) {
return parent_class;
}
parent_class = ClassDB::get_parent_class(parent_class);
}
return SNAME("Object");
}
void Object::set_instance_binding(void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks) {
// This is only meant to be used on creation by the binder.
ERR_FAIL_COND(_instance_bindings != nullptr);