Skip to content

Sync defs #1758

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

Merged
merged 1 commit into from
Apr 15, 2025
Merged

Sync defs #1758

merged 1 commit into from
Apr 15, 2025

Conversation

tomfull123
Copy link
Contributor

@tomfull123 tomfull123 commented Apr 2, 2025

Code is from the godot repo, had to remove duplicate definitions from math.hpp for some types and moved out the math defs into their own file to mirror godot's file structure more closely.

I was looking at syncing some other classes, but there were some types missing, hence this PR.

Briefly tested it on one of my gdextension projects and there doesn't seem to be any issues when running it with Godot 4.4.

@tomfull123 tomfull123 requested a review from a team as a code owner April 2, 2025 23:46
@tomfull123 tomfull123 force-pushed the sync-defs branch 2 times, most recently from 2eb5739 to 8cab4b5 Compare April 2, 2025 23:52
@tomfull123 tomfull123 changed the title Synced defs.hpp with godot's typedefs.h Sync defs Apr 4, 2025
@tomfull123
Copy link
Contributor Author

tomfull123 commented Apr 4, 2025

This PR also gives us the is_zero_constructible type, which is used by a lot of classes and would allow us to sync those classes too

Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

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

Thanks! Overall, this looks good to me (although it's always hard to know for sure with these complex updating changes). Assuming there's not many changes to how Godot's header looks.

I'm not sure how to handle compatibility breakages for refactors. E.g. ABS was moved to the math namespace. We could still keep it temporarily but deprecate it. But this seems like a lot of work long term.

@tomfull123
Copy link
Contributor Author

tomfull123 commented Apr 5, 2025

Thanks! Overall, this looks good to me (although it's always hard to know for sure with these complex updating changes). Assuming there's not many changes to how Godot's header looks.

I'm not sure how to handle compatibility breakages for refactors. E.g. ABS was moved to the math namespace. We could still keep it temporarily but deprecate it. But this seems like a lot of work long term.

Yeah I saw that ABS was already deprecated and that it was only used in 2 places, so I changed those, slightly out of scope for the PR, but I didn't think it would impact PR readability too badly

And ABS has already been removed from Godot

@dsnopek
Copy link
Collaborator

dsnopek commented Apr 5, 2025

I'm not sure how to handle compatibility breakages for refactors. E.g. ABS was moved to the math namespace. We could still keep it temporarily but deprecate it. But this seems like a lot of work long term.

Hm. Normally, it would be my preference to have a deprecated alias for ABS, but there's a high risk of us accidentally removing it when we sync with Godot next - I'm not sure how to avoid that...

We have the using real_t = godot::real_t one too that was correctly maintained in this PR, but I could easily see us forgetting it.

Maybe we could put the deprecated aliases in special headers that are included into the main one?

Like, math.compat.inc and we could start using DISABLED_DEPRECATED like in Godot, putting something like this at the end of math.hpp:

#ifndef DISABLE_DEPRECATED
#include "math.compat.inc"
#endif

@Ivorforce
Copy link
Member

Maybe we could put the deprecated aliases in special headers that are included into the main one?

This sounds like a great idea to me!

@tomfull123 tomfull123 force-pushed the sync-defs branch 2 times, most recently from 2e7525b to 2afc460 Compare April 6, 2025 18:44
@tomfull123
Copy link
Contributor Author

I'm not sure how to handle compatibility breakages for refactors. E.g. ABS was moved to the math namespace. We could still keep it temporarily but deprecate it. But this seems like a lot of work long term.

Hm. Normally, it would be my preference to have a deprecated alias for ABS, but there's a high risk of us accidentally removing it when we sync with Godot next - I'm not sure how to avoid that...

We have the using real_t = godot::real_t one too that was correctly maintained in this PR, but I could easily see us forgetting it.

Maybe we could put the deprecated aliases in special headers that are included into the main one?

Like, math.compat.inc and we could start using DISABLED_DEPRECATED like in Godot, putting something like this at the end of math.hpp:

#ifndef DISABLE_DEPRECATED
#include "math.compat.inc"
#endif

Added the math.compat.inc file and moved the using real_t... def and the ABS macro into it and I've added the include at the bottom of math.hpp, how does it look now? 😊

Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

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

Assuming the bindings match Godot's closely, this works for me.

Copy link
Collaborator

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

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

Thanks!

This is looking good to me. I've skimmed over the updated files while looking at the Godot files next to them, and I can't spot any issues

@dsnopek dsnopek added enhancement This is an enhancement on the current functionality cherrypick:4.4 labels Apr 7, 2025
@dsnopek dsnopek added this to the 4.x milestone Apr 7, 2025
@dsnopek dsnopek merged commit 97ad05b into godotengine:master Apr 15, 2025
18 checks passed
@tomfull123 tomfull123 deleted the sync-defs branch April 15, 2025 16:54
dsnopek added a commit that referenced this pull request Apr 17, 2025
CMake: Match #1758 move of DEBUG_METHODS_ENABLED from build options to defs.hpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick:4.4 enhancement This is an enhancement on the current functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants