Fix wrapping Object's in GDExtension that aren't exposed #78061
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a bug in PR #73511
The
Object::get_class_name_for_extension()
method is used to pick which wrapper class should be used to create the wrapper on the godot-cpp side. However, GDExtensions only have wrapper classes that are exposed, because those are the only ones listed in extension_api.json. For classes that aren't exposed, we should be creating the wrapper using the nearest parent class that is exposed.For example, while working on an editor plugin in GDExtension, I was getting error spam in the console like:
These are all child classes of
EditorProperty
which is exposed, so, on the GDExtension side, we want to create anEditorProperty
wrapper for each of them.This PR changes the
Object::get_class_name_for_extension()
method to check if the class is exposed, and if not, it walks up the classes parents until it finds one that is exposed.