-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Key union converted to a proper class
Unions are a C-reminiscense that are better avoided in modern C++. They cause specific problems due to their nature of representing independent types. The way they are used in Kaleidoscope, they can easily be replaced by a class. This enables it to properly work with Key objects in constexpr context where with the old union-based implementation the compiler reported errors when one Key was constructed based on a key_code/flags pair and another one through raw-data. In such a case, the compiler assumes that both Key instances represent something entirely different. This is because unions were never meant for type conversions and the C++ standard considers their use for that purpose as undefined behavior. The new class provides accessor methods for raw-data access and for key_code/flags-data access. This is a breaking change as it is is not possible to replace direct member access patterns like key.raw = 0xFFFF; based on the raw-accessors. For the .keyCode and .flags members, proxy objects are used to enable the generation of suitable deprecations warnings. All direct access via .raw, .keyCode and .flags have been replaced throughout Kaleidoscope. Signed-off-by: Florian Fleissner <[email protected]>
- Loading branch information
Florian Fleissner
committed
Nov 16, 2019
1 parent
aa5b55e
commit 0a18051
Showing
39 changed files
with
337 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.