mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
cbec344876
There were 6 copies of InputImpl.hpp for Windows, macOS, Linux, Linux DRM, iOS, and Android. All but Windows and Linux DRM were identical so there's already an easy opportunity for consolidation. The Windows header included some additional private static functions and data. An equivalent way of expressing this is via more data and functions instead the anonymous namespace of Win32/InputImpl.cpp so that's what I did. To fix some issues with functions being used before they're defined I moved number of functions into the anonymous namespace of that file which resulted in adding `sf::` in lots of places. InputImplUDev.hpp used by the DRM backend was trickier because includes WindowImplDRM as a friend. This creates a weird dependency graph where a distant class can call private functions that mutate private state. I kept the definitions of those functions inside DRM/InputImpl.cpp while moving their declaration to WindowImplDRM.cpp which is the only file where they're used. This is a bit odd but it avoids using the preprocessor and ensures that only the file that needs these functions can call them. In the end I was able to delete all 6 separate copies of InputImpl.hpp and consolidate them into src/SFML/Window/InputImpl.hpp saving nearly 1,000 lines of code. Because `sf::priv::InputImpl` is merely a set of static functions I converted this class to a simple namespace. The use of a namespace is what ultimately allowed me to untangle the DRM functions that were not present in other implementations |
||
---|---|---|
.. | ||
Audio | ||
Graphics | ||
Main | ||
Network | ||
System | ||
Window | ||
Android.mk | ||
CMakeLists.txt | ||
PCH.hpp |