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

Allow registering "runtime classes" in modules (not just GDExtension) #88683

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Feb 22, 2024

PR #82554 added the ability to register "runtime classes" from GDExtension.

This PR allow registering them from modules too!

It works just like the GDExtension version where it generates a fake ObjectGDExtension struct for the placeholder instances, but in this case it's generating it for a native class rather than a GDExtension class.

I personally think this is worth implementing, because:

  1. We want Godot and godot-cpp to provide the same API as much as possible. In fact, we usually tell contributors wanting to add something to godot-cpp that it needs to be supported in Godot before we can add it to godot-cpp. This is going a little bit in reverse :-) but it allows us to maintain that goal.
  2. It makes it possible for a GDExtension with "runtime classes" to optionally be compiled as a module. This is somewhat related to the first point, because this is part of the reason we want godot-cpp and Godot to have the same API, but I think this is worth calling out separately. Being able to easily compile a GDExtension as a module could be especially useful if porting a game to a platform that doesn't support GDExtension.
  3. Some people do code their gameplay logic in a module, and this makes that more convenient. While it's a very, very small minority of people who do this, there are some people who code their gameplay in a custom module. This will make that more convenient in the same way it makes coding gameplay logic in a GDExtension more convenient.
  4. The implementation is pretty small. It's not that much additional code to support this, so, why not :-)

@dsnopek dsnopek added this to the 4.3 milestone Feb 22, 2024
@dsnopek dsnopek requested a review from a team as a code owner February 22, 2024 20:29
@dsnopek dsnopek requested a review from a team February 22, 2024 20:34
core/object/class_db.cpp Outdated Show resolved Hide resolved
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.

Makes sense to me to expose this to modules.

@dsnopek dsnopek force-pushed the runtime-classes-in-modules branch from b77ef0e to 4d0b989 Compare February 22, 2024 20:50
@akien-mga akien-mga merged commit 45dd2bd into godotengine:master Feb 23, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

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