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

Some bitflags still need a typedef. #9812

Closed
icculus opened this issue May 16, 2024 · 5 comments · Fixed by #9886
Closed

Some bitflags still need a typedef. #9812

icculus opened this issue May 16, 2024 · 5 comments · Fixed by #9886
Assignees
Milestone

Comments

@icculus
Copy link
Collaborator

icculus commented May 16, 2024

Right now SDL_Surface::flags is a Uint32. It should get the same typedef update (and wikiheaders magic) that other bitflags did.

@icculus icculus added this to the 3.2.0 milestone May 16, 2024
@icculus icculus self-assigned this May 16, 2024
@icculus
Copy link
Collaborator Author

icculus commented May 16, 2024

Just grepping for flags here...

  • SDL_GetPenCapabilities() needs this too.
  • SDL_test_common.h has a Uint32 flags that is...probably?...meant to be SDL_InitFlags.
  • SDL_test_common.h also has a Uint32 verbose that handles the VERBOSE_* defines above it.

@icculus icculus changed the title SDL_Surface::flags needs a typedef. Some bitflags still need a typedef. May 16, 2024
@icculus icculus modified the milestones: 3.2.0, 3.0 ABI May 18, 2024
@TerensTare
Copy link

Slightly off-topic but can I ask what is the reasoning behind having a typedef + macro values instead of simply an enum? I am trying to write a parser to help with #9771 and enums-over-macros would help a lot with parsing these bitflags under a common type.

@slouken
Copy link
Collaborator

slouken commented May 23, 2024

Conceptually an enum is simply a set of valid values, and C++ enforces this. To be correct, all of the valid flag combinations would need to be added to the enumeration, which is unwieldy and in some cases not possible. The SDL headers have formalized a typedef followed by defines so language bindings and other parsers can rely on that.

@TerensTare
Copy link

I see the reasoning, that's unfortunate for C ... Would love to learn more about how this method is handled by language bindings though!

@icculus
Copy link
Collaborator Author

icculus commented May 23, 2024

So if the parser is SDL-specific: by policy, these typedefs always have the #defines directly after them, since we have a perl script that parses the headers to add these to wiki pages, like this one:

https://wiki.libsdl.org/SDL3/SDL_WindowFlags

If that makes it easier to parse for SDL specifically.

More explanation: https://wiki.libsdl.org/SDL3/README/documentation-rules#defines-right-below-typedefs-and-functions-bind

icculus added a commit to icculus/SDL that referenced this issue May 24, 2024
icculus added a commit to icculus/SDL that referenced this issue May 24, 2024
icculus added a commit to icculus/SDL that referenced this issue May 26, 2024
icculus added a commit that referenced this issue May 26, 2024
icculus added a commit that referenced this issue May 26, 2024
icculus added a commit that referenced this issue May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants