-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Use enums for Modes and RawModes in C #8510
base: main
Are you sure you want to change the base?
Conversation
and change findMode() to match
Structs have better type safety, but they make allocation more difficult, especially when we have multiple Python modules trying to share the same code.
this is necessary to have python/typeshed#12791
|
||
typedef struct { | ||
const char *const name; | ||
} ModeData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've created a struct with only one member, presumably because you expect to add more members in the future. Are you trying to prepare for #6547?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some things I think could be added to this struct in the future, but the more important reason for this as it is right now is type safety. A char *
could be almost anything, but a ModeData
can only be a ModeData
.
Adds some type safety when comparing modes, and replaces a lot of string comparisons with enum comparisons.