Skip to content

Convert PtrToArg macros to regular C++ structs. #105231

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 1 commit into
base: master
Choose a base branch
from

Conversation

Ivorforce
Copy link
Member

@Ivorforce Ivorforce commented Apr 10, 2025

I'd like to reduce the number of both macro and template magic throughout Godot. Some of it is pretty convoluted and can be simplified.

As a first step, macros should be converted to regular C++ structs as much as possible.
C style macros are difficult to edit, because they are (until called) not 'regular' code. For example, IDEs struggle to syntax highlight them, or give insights. Therefore, they are undesirable.

For this PR, I simply copy-pasted macro code to named structs. Then, I replaced the macro contents to simply instantiate the requested type with a specialization. Finally, I used my IDE to replace the macros with their contents, to avoid any mistakes with type arguments if I was manually converting.

As a second step, some of these can probably be simplified with C++ template magic in the future. But that's out of scope for this PR.

@Ivorforce Ivorforce added this to the 4.x milestone Apr 10, 2025
@Ivorforce Ivorforce requested a review from Repiteo April 10, 2025 09:26
@Ivorforce Ivorforce requested a review from a team as a code owner April 10, 2025 09:26
@Ivorforce Ivorforce force-pushed the ptr-to-arg-nomacro branch from 44fcd89 to 1151d9d Compare April 10, 2025 09:30
Copy link
Contributor

@Repiteo Repiteo left a comment

Choose a reason for hiding this comment

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

Rather than globally-defining structs with a leading underscore, could we contain them in an Internal namespace instead?

@Ivorforce Ivorforce force-pushed the ptr-to-arg-nomacro branch from 1151d9d to 42dd13f Compare April 10, 2025 18:34
@Ivorforce
Copy link
Member Author

Rather than globally-defining structs with a leading underscore, could we contain them in an Internal namespace instead?

Good idea, done!

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