clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit a27cace9da9ae325213d6940d358921e78a03f9d
parent 1c0810906970bcf4ef687c7d28599a45ce754a04
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date:   Fri, 23 Dec 2022 22:23:38 +0100

Merge pull request #254 from baconpaul/version-stuff

Change VERSION macros to allow compares
Diffstat:
MCMakeLists.txt | 6+++---
MChangeLog.md | 4++++
Minclude/clap/version.h | 15+++++++++++----
Msrc/main.cc | 29+++++++++++++++++++++++++++--
4 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -3,11 +3,11 @@ enable_testing() # Extract the version from header file file(READ "include/clap/version.h" clap_version_header) -string(REGEX MATCH "CLAP_VERSION_MAJOR \\(\\(uint32_t\\)([0-9]+)\\)" _ ${clap_version_header}) +string(REGEX MATCH "CLAP_VERSION_MAJOR ([0-9]+)" _ ${clap_version_header}) set(CLAP_VERSION_MAJOR ${CMAKE_MATCH_1}) -string(REGEX MATCH "CLAP_VERSION_MINOR \\(\\(uint32_t\\)([0-9]+)\\)" _ ${clap_version_header}) +string(REGEX MATCH "CLAP_VERSION_MINOR ([0-9]+)" _ ${clap_version_header}) set(CLAP_VERSION_MINOR ${CMAKE_MATCH_1}) -string(REGEX MATCH "CLAP_VERSION_REVISION \\(\\(uint32_t\\)([0-9]+)\\)" _ ${clap_version_header}) +string(REGEX MATCH "CLAP_VERSION_REVISION ([0-9]+)" _ ${clap_version_header}) set(CLAP_VERSION_REVISION ${CMAKE_MATCH_1}) message(STATUS "CLAP version: ${CLAP_VERSION_MAJOR}.${CLAP_VERSION_MINOR}.${CLAP_VERSION_REVISION}") diff --git a/ChangeLog.md b/ChangeLog.md @@ -8,6 +8,10 @@ * Remove UTF-8 BOM from a few files * [plugin-template.c](src/plugin-template.c): add state impl and some comments * [audio-ports-activation.h](include/clap/ext/draft/audio-ports-activation.h): improved documentation +* [version.h](include/clap/version.h): Add a CLAP_VERSION_GE(maj,min,rev), _EQ and _LT macro. Remove the + uint32_t cast from CLAP_VERSION_MAJOR, _MINOR, and _REVISION macro, and introduce it to the CLAP_VERSION_INIT + macro. If you rely on these macros being a uint32_t or parse this header using external software, this + may be a breaking change. # Changes in 1.1.4 diff --git a/include/clap/version.h b/include/clap/version.h @@ -20,11 +20,18 @@ typedef struct clap_version { } #endif -#define CLAP_VERSION_MAJOR ((uint32_t)1) -#define CLAP_VERSION_MINOR ((uint32_t)1) -#define CLAP_VERSION_REVISION ((uint32_t)5) +#define CLAP_VERSION_MAJOR 1 +#define CLAP_VERSION_MINOR 1 +#define CLAP_VERSION_REVISION 5 + #define CLAP_VERSION_INIT \ - { CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION } + { (uint32_t)CLAP_VERSION_MAJOR, (uint32_t)CLAP_VERSION_MINOR, (uint32_t)CLAP_VERSION_REVISION } + +#define CLAP_VERSION_LT(maj,min,rev) (((maj) < CLAP_VERSION_MAJOR) || \ + ((maj) == CLAP_VERSION_MAJOR && (min) < CLAP_VERSION_MINOR ) || \ + ((maj) == CLAP_VERSION_MAJOR && (min) == CLAP_VERSION_MINOR && (rev) < CLAP_VERSION_REVISION)) +#define CLAP_VERSION_EQ(maj,min,rev) (((maj) == CLAP_VERSION_MAJOR) && ((min) == CLAP_VERSION_MINOR) && ((rev) == CLAP_VERSION_REVISION)) +#define CLAP_VERSION_GE(maj,min,rev) (!CLAP_VERSION_LT(maj,min,rev)) static const CLAP_CONSTEXPR clap_version_t CLAP_VERSION = CLAP_VERSION_INIT; diff --git a/src/main.cc b/src/main.cc @@ -2,8 +2,34 @@ // The purpose of this file is to check that all headers compile +#if CLAP_VERSION_LT(CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION) +#error CLAP_VERSION_LT is inconsistent +#endif + +#if !CLAP_VERSION_EQ(CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION) +#error CLAP_VERSION_EQ is inconsistent +#endif + +#if CLAP_VERSION_EQ(CLAP_VERSION_MAJOR + 1, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION) +#error CLAP_VERSION_EQ is inconsistent (MAJOR) +#endif +#if CLAP_VERSION_EQ(CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR + 1, CLAP_VERSION_REVISION) +#error CLAP_VERSION_EQ is inconsistent (MINOR) +#endif +#if CLAP_VERSION_EQ(CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION + 1) +#error CLAP_VERSION_EQ is inconsistent (REVISION) +#endif + +#if !CLAP_VERSION_GE(CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION) +#error CLAP_VERSION_GE is inconsistent +#endif + +#if CLAP_VERSION_LT(1,1,5) +#error CLAP_VERSION_GE was inroduced in 1.1.5 so we should be later than that version. +#endif + static const CLAP_CONSTEXPR clap_version m = CLAP_VERSION; int main(int, char **) { return !clap_version_is_compatible(m); -} -\ No newline at end of file +}