commit ecea994588c735cd09eb9ba6178c7c4e8ca11956
parent 63e749eb199ed6537706be2f44540666e1c149f0
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date: Tue, 29 Jun 2021 17:22:38 +0200
Even easier
Diffstat:
5 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/examples/host/plugin-host.cc b/examples/host/plugin-host.cc
@@ -135,10 +135,10 @@ bool PluginHost::load(const QString &path, int pluginIndex) {
return false;
}
- if (desc->clap_version != CLAP_VERSION) {
- qWarning() << "incompatible clap version: " << clap_version_major(desc->clap_version) << "."
- << clap_version_minor(desc->clap_version) << "."
- << clap_version_revision(desc->clap_version);
+ if (!clap_version_is_compatible(desc->clap_version)) {
+ qWarning() << "incompatible clap version: " << desc->clap_version.major << "."
+ << desc->clap_version.minor << "."
+ << desc->clap_version.revision;
return false;
}
diff --git a/include/clap/clap.h b/include/clap/clap.h
@@ -96,7 +96,7 @@ typedef struct clap_process {
//////////
typedef struct clap_host {
- int32_t clap_version; // initialized to CLAP_VERSION
+ clap_version clap_version; // initialized to CLAP_VERSION
void *host_data; // reserved pointer for the host
diff --git a/include/clap/ext/draft/file-reference.h b/include/clap/ext/draft/file-reference.h
@@ -3,7 +3,7 @@
#include "../../clap.h"
#include "../../hash.h"
-static const char CLAP_EXT_FILE_REFERENCE[] = "clap/file-reference";
+static const char CLAP_EXT_FILE_REFERENCE[] = "clap/draft/file-reference";
#ifdef __cplusplus
extern "C" {
diff --git a/include/clap/macros.h b/include/clap/macros.h
@@ -13,4 +13,10 @@
# else
# define CLAP_EXPORT
# endif
+#endif
+
+#ifdef __cplusplus
+# define CLAP_CONSTEXPR constexpr
+#else
+# define CLAP_CONSTEXPR
#endif
\ No newline at end of file
diff --git a/include/clap/version.h b/include/clap/version.h
@@ -2,33 +2,31 @@
#include <stdint.h>
+#include "macros.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-typedef uint32_t clap_version;
+typedef struct clap_version {
+ int major;
+ int minor;
+ int revision;
+} clap_version;
-static inline clap_version clap_version_make(uint32_t major, uint32_t minor, uint32_t revision) {
- return (((major & 0xfff) << 20) | ((minor & 0xfff) << 8) | (revision & 0xff));
-}
+static const clap_version CLAP_VERSION = {0, 7, 0};
-static inline uint32_t clap_version_major(clap_version version)
+static CLAP_CONSTEXPR bool clap_version_is_compatible(const clap_version& v)
{
- return ((version) >> 20) & 0xfff;
-}
+ if (v.major == 0 && CLAP_VERSION.major == 0)
+ return v.minor == CLAP_VERSION.major;
-static inline uint32_t clap_version_minor(clap_version version)
-{
- return ((version) >> 8) & 0xfff;
-}
+ if (v.major == 1 && CLAP_VERSION.major == 1)
+ return true;
-static inline uint32_t clap_version_revision(clap_version version)
-{
- return version & 0xff;
+ return false;
}
-static const clap_version CLAP_VERSION = clap_version_make(0, 7, 0);
-
#ifdef __cplusplus
}
#endif
\ No newline at end of file