Skip to content

Godot virtuals are no longer required if a derived Godot class implements them #1136

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Bromeon
Copy link
Member

@Bromeon Bromeon commented Apr 21, 2025

Closes #1133.

@Bromeon Bromeon added quality-of-life No new functionality, but improves ergonomics/internals c: engine Godot classes (nodes, resources, ...) labels Apr 21, 2025
Bromeon added 2 commits April 21, 2025 16:55
Use Godot class names, make 4.4+ code more robust in case of future special cases.
@Bromeon Bromeon force-pushed the qol/virtuals-no-longer-required branch from afa8f0e to 5b65c25 Compare April 21, 2025 14:56
@Bromeon Bromeon changed the title Godot virtuals are no longer _required_ if a derived Godot class implements them Godot virtuals are no longer required if a derived Godot class implements them Apr 21, 2025
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1136

@Bromeon Bromeon added this to the 0.3 milestone Apr 27, 2025
@djcsdy
Copy link

djcsdy commented Apr 29, 2025

This might be considered only a partial fix.

AIUI, after this change, mix is no longer required, which is definitely an improvement.

However in practice, if the programmer does provide an implementation of mix, Godot will never call it.

The reason seems to be that AudioStreamPlaybackResampled.mix is not marked GDVIRTUAL: https://github.com/godotengine/godot/blob/4.4/servers/audio/audio_stream.h#L154

I assume this means that although it is a virtual method in the C++ code, it is not treated as virtual from the point of view of extensions.

It's not clear if that's deliberate but it would make sense.

So if possible it might be better to not only make mix optional but remove it from the trait altogether.

@Bromeon
Copy link
Member Author

Bromeon commented Apr 29, 2025

Thanks for the feedback. Good call, I asked on RocketChat to clarify the semantics.

If that's by design, then I agree, we should remove such methods from the trait. It's a bit strange from LSP perspective, but now our design choice to have one I* trait, rather than one per base class, will be rewarded 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: engine Godot classes (nodes, resources, ...) quality-of-life No new functionality, but improves ergonomics/internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IAudioStreamPlaybackResampled requires useless implementation of "mix"
4 participants