Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 15, 2023

Conversation

dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Jun 9, 2023

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:

ERROR: Cannot find instance binding callbacks for class 'EditorPropertyCheck'.
   at: get_instance_binding_callbacks (godot-cpp/src/core/class_db.cpp:320)
ERROR: Cannot find instance binding callbacks for class 'EditorPropertyVector2i'.
   at: get_instance_binding_callbacks (godot-cpp/src/core/class_db.cpp:320)
ERROR: Cannot find instance binding callbacks for class 'EditorPropertyResource'.
   at: get_instance_binding_callbacks (godot-cpp/src/core/class_db.cpp:320)
ERROR: Cannot find instance binding callbacks for class 'EditorPropertyText'.
   at: get_instance_binding_callbacks (godot-cpp/src/core/class_db.cpp:320)
ERROR: Cannot find instance binding callbacks for class 'EditorPropertyInteger'.
   at: get_instance_binding_callbacks (godot-cpp/src/core/class_db.cpp:320)
ERROR: Cannot find instance binding callbacks for class 'EditorPropertyFloat'.
   at: get_instance_binding_callbacks (godot-cpp/src/core/class_db.cpp:320)
ERROR: Cannot find instance binding callbacks for class 'EditorPropertyVector2'.
   at: get_instance_binding_callbacks (godot-cpp/src/core/class_db.cpp:320)

These are all child classes of EditorProperty which is exposed, so, on the GDExtension side, we want to create an EditorProperty 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.

@dsnopek dsnopek added this to the 4.1 milestone Jun 9, 2023
@dsnopek dsnopek requested a review from a team June 9, 2023 18:41
@dsnopek dsnopek requested a review from a team as a code owner June 9, 2023 18:41
@dsnopek dsnopek force-pushed the gdextension-class-not-exposed branch from 2d50b35 to 36f4b99 Compare June 9, 2023 18:42
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't review in depth, but the overall changes seem fine to me.

@akien-mga akien-mga merged commit 8c5c29f into godotengine:master Jun 15, 2023
@akien-mga
Copy link
Member

Thanks!

@dsnopek dsnopek deleted the gdextension-class-not-exposed branch July 22, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants