Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flagarde committed May 8, 2024
1 parent 8a15ff5 commit 33c4c81
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- name: 🔧 Configure
run: cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_NUMBER_JOBS=2 -DCMAKE_NUMBER_JOBS_TESTS=1

- uses: pre-commit/action@v3.0.1

- uses: pre-commit-ci/lite-action@v1.0.2
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ repos:
- id: cmake-lint
args: [--config=.cmake-linter.yml]

- repo: repo: https://github.com/Takishima/cmake-pre-commit-hooks
- repo: https://github.com/Takishima/cmake-pre-commit-hooks
rev: v1.8.0
hooks:
- id: clang-tidy
args: [-Bbuild, --config=]
- id: cppcheck-conda
args: [-Bbuild, --suppressions-list=.cppcheck]
- id: include-what-you-use-conda
args: [-Bbuild, -p, build, --jobs, '10']
#- id: cppcheck-conda
# args: [-Bbuild, --suppressions-list=.cppcheck]
#- id: include-what-you-use-conda
# args: [-Bbuild, -p, build, --jobs, '10']

- repo: https://gitlab.com/daverona/pre-commit/cpp
rev: 0.8.0
Expand Down
5 changes: 3 additions & 2 deletions include/khaos/CompareVersionMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@
*/

/** \hideinitializer
* \brief Check the \b version with \b major, \b minor, \b patch using the operator \b op
* \brief Check the \b version with \b major, \b minor, \b patch, \b tweak using the operator \b op
* \param[in] version version to compare.
* \param[in] op operator =, !=, >=, <= >, < .
* \param[in] major major part.
* \param[in] minor minor part.
* \param[in] patch patch part.
* \param[in] tweak tweak part.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/
#define CHECK_VERSION(version, op, major, minor, patch) ((KHAOS_VERSION_##version##_PRIVATE())op(SET_VERSION(major, minor, patch)))
#define CHECK_VERSION(version, op, major, minor, patch, tweak) ((KHAOS_VERSION_##version##_PRIVATE())op(SET_VERSION(major, minor, patch, tweak)))

/** \hideinitializer
* \brief Check the \b versiona with \b versionb using the operator \b op
Expand Down
11 changes: 1 addition & 10 deletions include/khaos/KhaosVersion.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,7 @@
\note Use #GET_VERSION_MAJOR(Khaos), #GET_VERSION_MINOR(Khaos), #GET_VERSION_PATCH(Khaos) to parse it.
*/
/* clang-format off */
#define KHAOS_VERSION_Khaos_PRIVATE() SET_VERSION(@Khaos_VERSION_MAJOR@UL,@Khaos_VERSION_MINOR@UL,@Khaos_VERSION_PATCH@UL)
/* clang-format on */

/*!
\brief Khaos version tweak. \hideinitializer
\returns Khaos version tweak in integer literal UL form.
\note Use #GET_VERSION_TWEAK(Khaos) to parse it.
*/
/* clang-format off */
#define KHAOS_VERSION_Khaos_TWEAK_PRIVATE() SET_VERSION_TWEAK(@Khaos_VERSION_TWEAK@UL)
#define KHAOS_VERSION_Khaos_PRIVATE() SET_VERSION(@Khaos_VERSION_MAJOR@ULL,@Khaos_VERSION_MINOR@ULL,@Khaos_VERSION_PATCH@ULL,@Khaos_VERSION_TWEAK@ULL)
/* clang-format on */

#endif /* KHAOS_KHAOSVERSION_H_ */
37 changes: 10 additions & 27 deletions include/khaos/VersionMacros.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#ifndef KHAOS_VERSIONMACROS_H_
#define KHAOS_VERSIONMACROS_H_

#include "khaos/CompareVersionMacros.h"
#include "khaos/KhaosVersion.h"

/** \file VersionMacros.h
* \copyright 2022 flagarde
* \brief Define macros to set, get versions.
Expand All @@ -20,68 +17,54 @@

/** \hideinitializer
* \brief Set standard version numbers.
* \param[in] major The major number can be in the [0,255] range.
* \param[in] minor The minor number can be in the [0,255] range.
* \param[in] major The major number can be in the [0,65535] range.
* \param[in] minor The minor number can be in the [0,65535] range.
* \param[in] patch The patch number can be in the [0,65535] range.
* \param[in] tweak The tweak number can be in the [0,65535] range.
*
* \remarks The number range is designed to allow for a (8,8,16) triplet; Which fits within a 32 bit value.
* \remarks The number range is designed to allow for a (16,16,16,16) quadruplet; Which fits within a 64 bit value.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
* \note Values can be specified in any base. As the defined value is an constant expression.
* \note The implementation enforces the individual ranges for the major, minor, and patch numbers.
* \warning Values over the ranges are truncated (modulo).
* \warning The name of the macro must be of the form KHAOS_VERSION_name_PRIVATE() to be able to be parsed by the Khaos library.
* \code{.cpp}
* #define KHAOS_VERSION_myversion_PRIVATE() SET_VERSION(2,3,4)
* \endcode
*/
#define SET_VERSION(major, minor, patch) ((((major)*1UL % 256) << 24) + (((minor)*1UL % 256) << 16) + ((patch)*1UL % 65536))

/** \hideinitializer
* \brief Set standard tweak (build) numbers.
* \param[in] tweak The tweak number can be in the [0,9999] range.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
* \note Values can be specified in any base. As the defined value is an constant expression.
* \note The implementation enforces the individual ranges for the major, minor, and patch numbers.
* \warning Values over the ranges are truncated (modulo).
* \warning The name of the macro must be of the form KHAOS_name_VERSION_TWEAK_PRIVATE() to be able to be parsed by the Khaos library.
* \code{.cpp}
* #define KHAOS_VERSION_myversion_TWEAK_PRIVATE() SET_VERSION_TWEAK(10)
* #define KHAOS_VERSION_myversion_PRIVATE() SET_VERSION(2,3,4,5)
* \endcode
*/
#define SET_VERSION_TWEAK(tweak) ((tweak)*1UL % 65536)
#define SET_VERSION(major, minor, patch, tweak) ((((major)*1ULL % 65536) << 48) + (((minor)*1ULL % 65536) << 32) + (((patch)*1ULL % 65536) << 16) + ((tweak)*1ULL % 65536))

/** \hideinitializer
* \brief Get standard major version numbers.
* \param[in] version The standard version number.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/
#define GET_VERSION_MAJOR(version) (((KHAOS_VERSION_##version##_PRIVATE()) * 1UL >> 24) % 256)
#define GET_VERSION_MAJOR(version) ((((KHAOS_VERSION_##version##_PRIVATE()) * 1ULL) >> 48) % 65536)

/** \hideinitializer
* \brief Get standard minor version numbers.
* \param[in] version The standard version number.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/
#define GET_VERSION_MINOR(version) (((KHAOS_VERSION_##version##_PRIVATE()) * 1UL >> 16) % 256)
#define GET_VERSION_MINOR(version) ((((KHAOS_VERSION_##version##_PRIVATE()) * 1ULL) >> 32) % 65536)

/** \hideinitializer
* \brief Get standard patch version numbers.
* \param[in] version The standard version number.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/
#define GET_VERSION_PATCH(version) ((KHAOS_VERSION_##version##_PRIVATE()) * 1UL % 65536)
#define GET_VERSION_PATCH(version) ((((KHAOS_VERSION_##version##_PRIVATE()) * 1ULL) >> 16) % 65536)

/** \hideinitializer
* \brief Get standard tweak version numbers.
* \param[in] version The standard version number.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/
#define GET_VERSION_TWEAK(version) ((KHAOS_VERSION_##version##_TWEAK_PRIVATE()) * 1UL % 65536)
#define GET_VERSION_TWEAK(version) (((KHAOS_VERSION_##version##_PRIVATE()) * 1ULL) % 65536)

#endif /* KHAOS_VERSIONMACROS_H_ */
Loading

0 comments on commit 33c4c81

Please sign in to comment.