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 GDExtensions to register virtual methods and call them on scripts (godot-cpp support) #1377

Merged

Conversation

dsnopek
Copy link
Collaborator

@dsnopek dsnopek commented Jan 30, 2024

This depends on PR godotengine/godot#87758

It adds APIs compatible with Godot's, including the following macros:

  • GDVIRTUAL*() (like GDVIRTUAL0R(), GDVIRTUAL2C(), etc)
  • GDVIRTUAL_BIND()
  • GDVIRTUAL_CALL()
  • GDVIRTUAL_IS_OVERRIDDEN()
  • ... and all the rest!

It also adds an automated test for this functionality to CI.

NOTE: The tests here will fail until after the Godot PR is merged! However, they are passing for me locally.

Fixes #1199
Fixes #1072
Fixes #910

@dsnopek dsnopek added the enhancement This is an enhancement on the current functionality label Jan 30, 2024
@dsnopek dsnopek added this to the 4.x milestone Jan 30, 2024
@dsnopek dsnopek requested a review from a team as a code owner January 30, 2024 22:35
@dsnopek dsnopek force-pushed the gdextension-register-virtual-method branch from da9098a to a969e47 Compare January 30, 2024 22:41
@AThousandShips AThousandShips added the waiting for Godot This issue needs a Godot Engine improvement to be solved label Jan 31, 2024
@Remi123
Copy link

Remi123 commented Jan 31, 2024

I've been waiting for this feature for over a year. Thank you so much.

Glad to see an example. 4.3 will be great for plugin.

@dsnopek dsnopek force-pushed the gdextension-register-virtual-method branch from a969e47 to 8fbb7cf Compare February 12, 2024 19:30
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.

Didn't review in depth, but looks good at a glance. We merged the upstream counterpart so this could be merged now.

@dsnopek dsnopek merged commit 5fcc43e into godotengine:master Feb 13, 2024
12 checks passed
@Kehom
Copy link
Contributor

Kehom commented Mar 11, 2024

I finally got back to the code I needed this feature. I have noticed that the macros defined in the gdvirtual.gen.inc file begin with StringName _gdvritual_ without explicit namespace usage. This somewhat forces extension code to add using namespace godot.

Is this intended?

EDIT: I attempted to create a custom macro copying the original one but adding the explicit godot::NameString thing. It didn't work. Nevertheless, the macros do work if I add the using namespace godot (which is not exactly something I wanted to do).

@dsnopek
Copy link
Collaborator Author

dsnopek commented Mar 11, 2024

Is this intended?

Nope! This is probably just an artifact of those macros starting out as a copy of the same macros from Godot.

@dsnopek
Copy link
Collaborator Author

dsnopek commented Mar 11, 2024

@Kehom Can you test if this PR fixes it for you? #1412 Unfortunately, I don't have a project that doesn't use using namespace godot at hand to test if those changes are sufficient

@Kehom
Copy link
Contributor

Kehom commented Mar 11, 2024

Thanks for the answer. I think it will be best for me to answer about the fix in the PR itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement on the current functionality waiting for Godot This issue needs a Godot Engine improvement to be solved
Projects
None yet
5 participants