Hide some SDL structure
Adding or removing fields to structure are always api breakage.
Should we try to expose less SDL structures, so that they don't prevent to break api.
- doesn't make sense to hide SDL_rect, because all fields are used
- doesn't make sense to expose SDL_render, because almost no fields are used.
Candidate are structures, with few used fields, that can be hidden, and we add get/set function for usage
Sure, do you have a set of structures you'd like to hide?
Tossing this into 3.0 ABI for further review, but it's possible that SDL_Properties mitigates this.
I grepped the codebase for lines with "typedef" and "struct", which brings up 125 items.
Most of these are already good (including the previously-mentioned SDL_Renderer, which is already an opaque type).
The only ones I saw that I think are worth considering at all...
- SDL_AtomicInt: maybe we just make this totally opaque, since its point is to prevent accessing the int value directly anyhow.
- SDL_Surface: Probably the perfect example of what @1bsyl is thinking of here, right?
- SDL_DisplayMode: has a
driverdatafield, which is a little awkward, maybe. - SDL_hid_device_info: I don't love that this is a linked list and has
unsigned shortvalues andwchar_t *fields, but I assume this is inherited from hidapi and we can't do much about this and most people don't need it anyhow.
The rest looks pretty good from here. A big pain point was SDL_RWops, but now it is opaque, and if we want to change the interface struct to add/remove/change function pointers, we'll just make a Version 2 struct and a new function to create an SDL_IOStream with the different interface, and paper over the Version 1 differences internally.
Anyhow, we can decide what to do with these (which might be nothing).
SDL_AtomicInt: maybe we just make this totally opaque, since its point is to prevent accessing the int value directly anyhow.
(then again, you can't simply create these as static/global if we make these opaque, which is a very common way to use atomic ints.)
I'm investigating trimming down SDL_Surface now, and opened a separate issue for SDL_DisplayMode in https://github.com/libsdl-org/SDL/issues/10198. SDL_AtomicInt we want to be static/global, and we won't touch SDL_hid_device_info, for source code compatibility with hidapi.