From 1beec8ac118508e731e286feb8b54af0ae9b4d2b Mon Sep 17 00:00:00 2001 From: trinitou Date: Fri, 19 Jan 2024 00:22:25 +0100 Subject: [PATCH 1/4] Update to latest clap/next --- .../helpers/preset-discovery-metadata-receiver.hh | 12 ++++++------ .../helpers/preset-discovery-metadata-receiver.hxx | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/clap/helpers/preset-discovery-metadata-receiver.hh b/include/clap/helpers/preset-discovery-metadata-receiver.hh index 73d337f..9fe3b80 100644 --- a/include/clap/helpers/preset-discovery-metadata-receiver.hh +++ b/include/clap/helpers/preset-discovery-metadata-receiver.hh @@ -36,7 +36,7 @@ namespace clap { namespace helpers { virtual bool beginPreset(const char *name, const char *load_key) noexcept { return false; } - virtual void addPluginId(const clap_plugin_id_t *plugin_id) noexcept {} + virtual void addPluginId(const clap_universal_plugin_id *plugin_id) noexcept {} virtual void setCollectionId(const char *collection_id) noexcept {} @@ -46,8 +46,8 @@ namespace clap { namespace helpers { virtual void setDescription(const char *description) noexcept {} - virtual void setTimestamps(clap_timestamp_t creation_time, - clap_timestamp_t modification_time) noexcept {} + virtual void setTimestamps(clap_timestamp creation_time, + clap_timestamp modification_time) noexcept {} virtual void addFeature(const char *feature) noexcept {} @@ -77,7 +77,7 @@ namespace clap { namespace helpers { static void receiverAddPluginId(const struct clap_preset_discovery_metadata_receiver *receiver, - const clap_plugin_id_t *plugin_id) noexcept; + const clap_universal_plugin_id *plugin_id) noexcept; static void receiverSetCollectionId(const struct clap_preset_discovery_metadata_receiver *receiver, @@ -95,8 +95,8 @@ namespace clap { namespace helpers { static void receiverSetTimestamps(const struct clap_preset_discovery_metadata_receiver *receiver, - clap_timestamp_t creation_time, - clap_timestamp_t modification_time) noexcept; + clap_timestamp creation_time, + clap_timestamp modification_time) noexcept; static void receiverAddFeature(const struct clap_preset_discovery_metadata_receiver *receiver, const char *feature) noexcept; diff --git a/include/clap/helpers/preset-discovery-metadata-receiver.hxx b/include/clap/helpers/preset-discovery-metadata-receiver.hxx index a9a96a3..4efca70 100644 --- a/include/clap/helpers/preset-discovery-metadata-receiver.hxx +++ b/include/clap/helpers/preset-discovery-metadata-receiver.hxx @@ -49,7 +49,7 @@ namespace clap { namespace helpers { template void PresetDiscoveryMetadataReceiver::receiverAddPluginId( const struct clap_preset_discovery_metadata_receiver *receiver, - const clap_plugin_id_t *plugin_id) noexcept { + const clap_universal_plugin_id *plugin_id) noexcept { auto &self = from(receiver); return self.addPluginId(plugin_id); } @@ -88,8 +88,8 @@ namespace clap { namespace helpers { template void PresetDiscoveryMetadataReceiver::receiverSetTimestamps( const struct clap_preset_discovery_metadata_receiver *receiver, - clap_timestamp_t creation_time, - clap_timestamp_t modification_time) noexcept { + clap_timestamp creation_time, + clap_timestamp modification_time) noexcept { auto &self = from(receiver); return self.setTimestamps(creation_time, modification_time); } From a47eb1c9ecd059d8580683b3b5b580146ad873ed Mon Sep 17 00:00:00 2001 From: trinitou Date: Fri, 19 Jan 2024 00:45:01 +0100 Subject: [PATCH 2/4] Add build test for clap::helpers::Host --- .gitignore | 5 +++-- CMakeLists.txt | 1 + include/clap/helpers/host.hxx | 4 ++-- include/clap/helpers/macros.hh | 6 ++++++ tests/host.cc | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 tests/host.cc diff --git a/.gitignore b/.gitignore index acf32bf..4ee5684 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Prerequisites +# Prerequisites *.d # Compiled Object files @@ -31,9 +31,10 @@ *.out *.app -#vs +# Visual Studio .vs out +.vscode #clion .idea diff --git a/CMakeLists.txt b/CMakeLists.txt index a0aee8d..3ff468e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ if (${CLAP_HELPERS_BUILD_TESTS}) add_executable(${PROJECT_NAME}-tests EXCLUDE_FROM_ALL tests/create-an-actual-plugin.cc tests/hex-encoder.cc + tests/host.cc tests/plugin.cc tests/param-queue-tests.cc tests/event-list-tests.cc diff --git a/include/clap/helpers/host.hxx b/include/clap/helpers/host.hxx index 280aa5e..54a5b76 100644 --- a/include/clap/helpers/host.hxx +++ b/include/clap/helpers/host.hxx @@ -428,7 +428,7 @@ namespace clap { namespace helpers { /////////////// template Host &Host::from(const clap_host *host) noexcept { - if constexpr (l >= CheckingLevel::Minimal) { + CLAP_IF_CONSTEXPR (l >= CheckingLevel::Minimal) { if (!host) CLAP_HELPERS_UNLIKELY { std::cerr << "Passed an null host pointer" << std::endl; std::terminate(); @@ -436,7 +436,7 @@ namespace clap { namespace helpers { } auto self = static_cast(host->host_data); - if constexpr (l >= CheckingLevel::Minimal) { + CLAP_IF_CONSTEXPR (l >= CheckingLevel::Minimal) { if (!self) CLAP_HELPERS_UNLIKELY { std::cerr << "Passed an invalid host pointer because the host_data is null" << std::endl; diff --git a/include/clap/helpers/macros.hh b/include/clap/helpers/macros.hh index 6c3ead4..d835368 100644 --- a/include/clap/helpers/macros.hh +++ b/include/clap/helpers/macros.hh @@ -1,5 +1,11 @@ #pragma once +#if defined(__cplusplus) && __cplusplus >= 201703L +# define CLAP_IF_CONSTEXPR if constexpr +#else +# define CLAP_IF_CONSTEXPR if +#endif + #if defined(__cplusplus) && __cplusplus >= 202002L # define CLAP_HELPERS_UNLIKELY [[unlikely]] #else diff --git a/tests/host.cc b/tests/host.cc new file mode 100644 index 0000000..33f80d7 --- /dev/null +++ b/tests/host.cc @@ -0,0 +1,34 @@ +#include +#include +#include + +#include + +template class clap::helpers::Host; +template class clap::helpers::Host; +template class clap::helpers::Host; +template class clap::helpers::Host; + +template class clap::helpers::PluginProxy; +template class clap::helpers::PluginProxy; +template class clap::helpers::PluginProxy; +template class clap::helpers::PluginProxy; + +CATCH_TEST_CASE("Host - Link") { + clap::helpers::Host *h0 = nullptr; + clap::helpers::Host *h1 = nullptr; + clap::helpers::Host *h2 = nullptr; + clap::helpers::Host *h3 = nullptr; +} From aa26d4850969ea90c43a8bd975b0480412ca791c Mon Sep 17 00:00:00 2001 From: trinitou Date: Fri, 19 Jan 2024 01:05:35 +0100 Subject: [PATCH 3/4] Add instanciation test for clap::helpers::Host --- CMakeLists.txt | 1 + tests/create-an-actual-host.cc | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/create-an-actual-host.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ff468e..671b2e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ if (${CLAP_HELPERS_BUILD_TESTS}) endif() add_executable(${PROJECT_NAME}-tests EXCLUDE_FROM_ALL + tests/create-an-actual-host.cc tests/create-an-actual-plugin.cc tests/hex-encoder.cc tests/host.cc diff --git a/tests/create-an-actual-host.cc b/tests/create-an-actual-host.cc new file mode 100644 index 0000000..c11196e --- /dev/null +++ b/tests/create-an-actual-host.cc @@ -0,0 +1,36 @@ +/* + * Actually use host.hh / host.hxx to create a host. Assert that it is constructable + */ + +#include "clap/helpers/host.hh" +#include "clap/helpers/host.hxx" + +#include + +#include + +struct test_host : clap::helpers::Host +{ + test_host() : clap::helpers::Host( + "Test Case Host", + "Free Audio", + "http://cleveraudio.org", + "1.0.0") {} + + bool threadCheckIsMainThread() const noexcept override { return true; }; + bool threadCheckIsAudioThread() const noexcept override { return false; }; + + void requestRestart() noexcept override {}; + void requestProcess() noexcept override {}; + void requestCallback() noexcept override {}; +}; + +CATCH_TEST_CASE("Create an Actual Host") +{ + CATCH_SECTION("Test Host is Creatable") + { + CATCH_REQUIRE(std::is_constructible::value); + } +} From e61cad1eff621d11e92bfc73ce7cab55e1c0e13e Mon Sep 17 00:00:00 2001 From: trinitou Date: Fri, 19 Jan 2024 14:02:09 +0100 Subject: [PATCH 4/4] Revert if constepr macro --- include/clap/helpers/host.hxx | 4 ++-- include/clap/helpers/macros.hh | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/clap/helpers/host.hxx b/include/clap/helpers/host.hxx index 54a5b76..280aa5e 100644 --- a/include/clap/helpers/host.hxx +++ b/include/clap/helpers/host.hxx @@ -428,7 +428,7 @@ namespace clap { namespace helpers { /////////////// template Host &Host::from(const clap_host *host) noexcept { - CLAP_IF_CONSTEXPR (l >= CheckingLevel::Minimal) { + if constexpr (l >= CheckingLevel::Minimal) { if (!host) CLAP_HELPERS_UNLIKELY { std::cerr << "Passed an null host pointer" << std::endl; std::terminate(); @@ -436,7 +436,7 @@ namespace clap { namespace helpers { } auto self = static_cast(host->host_data); - CLAP_IF_CONSTEXPR (l >= CheckingLevel::Minimal) { + if constexpr (l >= CheckingLevel::Minimal) { if (!self) CLAP_HELPERS_UNLIKELY { std::cerr << "Passed an invalid host pointer because the host_data is null" << std::endl; diff --git a/include/clap/helpers/macros.hh b/include/clap/helpers/macros.hh index d835368..6c3ead4 100644 --- a/include/clap/helpers/macros.hh +++ b/include/clap/helpers/macros.hh @@ -1,11 +1,5 @@ #pragma once -#if defined(__cplusplus) && __cplusplus >= 201703L -# define CLAP_IF_CONSTEXPR if constexpr -#else -# define CLAP_IF_CONSTEXPR if -#endif - #if defined(__cplusplus) && __cplusplus >= 202002L # define CLAP_HELPERS_UNLIKELY [[unlikely]] #else