DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 01aca7649c1a3a5ee20a47c5ecd3cb2e29395f89
parent a3ef9b8a40a0921577f4120aa509b44c3abb58e1
Author: falkTX <falktx@falktx.com>
Date:   Wed, 27 Mar 2024 11:57:46 +0100

Remove some constexpr constructors that never worked

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdistrho/DistrhoDetails.hpp | 90+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Mdistrho/extra/String.hpp | 22++++------------------
2 files changed, 53 insertions(+), 59 deletions(-)

diff --git a/distrho/DistrhoDetails.hpp b/distrho/DistrhoDetails.hpp @@ -511,15 +511,6 @@ struct ParameterEnumerationValue { ParameterEnumerationValue(float v, const char* l) noexcept : value(v), label(l) {} - -#if __cplusplus >= 201703L - /** - Constructor using custom values, constexpr compatible variant. - */ - constexpr ParameterEnumerationValue(float v, const std::string_view& l) noexcept - : value(v), - label(l) {} -#endif }; /** @@ -714,29 +705,6 @@ struct Parameter { groupId(kPortGroupNone) {} #endif -#if __cplusplus >= 201703L - /** - Constructor for constexpr compatible data. - */ - constexpr Parameter(uint32_t h, - const std::string_view& n, - const std::string_view& sn, - const std::string_view& sym, - const std::string_view& u, - const std::string_view& desc) noexcept - : hints(h), - name(n), - shortName(sn), - symbol(sym), - unit(u), - description(desc), - ranges(), - enumValues(), - designation(kParameterDesignationNull), - midiCC(0), - groupId(kPortGroupNone) {} -#endif - /** Initialize a parameter for a specific designation. */ @@ -762,17 +730,57 @@ struct Parameter { break; } } -}; -#if __cplusplus >= 202001L /* TODO */ -/** - Bypass parameter definition in constexpr form. - */ -static constexpr const Parameter kParameterBypass = { - kParameterIsAutomatable|kParameterIsBoolean|kParameterIsInteger, - "Bypass", "Bypass", ParameterDesignationSymbols::bypass, "", "", {}, {}, 0, kPortGroupNone, + Parameter& operator=(Parameter& other) noexcept + { + hints = other.hints; + name = other.name; + shortName = other.shortName; + symbol = other.symbol; + unit = other.unit; + description = other.description; + ranges = other.ranges; + designation = other.designation; + midiCC = other.midiCC; + groupId = other.groupId; + + // enumValues needs special handling + enumValues.count = other.enumValues.count; + enumValues.restrictedMode = other.enumValues.restrictedMode; + enumValues.values = other.enumValues.values; + enumValues.deleteLater = other.enumValues.deleteLater; + + // make sure to not delete data twice + other.enumValues.deleteLater = false; + + return *this; + } + + Parameter& operator=(const Parameter& other) noexcept + { + hints = other.hints; + name = other.name; + shortName = other.shortName; + symbol = other.symbol; + unit = other.unit; + description = other.description; + ranges = other.ranges; + designation = other.designation; + midiCC = other.midiCC; + groupId = other.groupId; + + // make sure to not delete data twice + DISTRHO_SAFE_ASSERT_RETURN(other.enumValues.values == nullptr || !other.enumValues.deleteLater, *this); + + // enumValues needs special handling + enumValues.count = other.enumValues.count; + enumValues.restrictedMode = other.enumValues.restrictedMode; + enumValues.values = other.enumValues.values; + enumValues.deleteLater = other.enumValues.deleteLater; + + return *this; + } }; -#endif /** Port Group.@n diff --git a/distrho/extra/String.hpp b/distrho/extra/String.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com> * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -22,10 +22,6 @@ #include <algorithm> -#if __cplusplus >= 201703L -# include <string_view> -#endif - START_NAMESPACE_DISTRHO // ----------------------------------------------------------------------- @@ -91,16 +87,6 @@ public: _dup(strBuf); } - #if __cplusplus >= 201703L - /* - * constexpr compatible variant. - */ - explicit constexpr String(const std::string_view& strView) noexcept - : fBuffer(const_cast<char*>(strView.data())), - fBufferLen(strView.size()), - fBufferAlloc(false) {} - #endif - /* * Integer. */ @@ -695,11 +681,11 @@ public: "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; -#ifndef _MSC_VER + #ifndef _MSC_VER const std::size_t kTmpBufSize = std::min(d_nextPowerOf2(static_cast<uint32_t>(dataSize/3)), 65536U); -#else + #else constexpr std::size_t kTmpBufSize = 65536U; -#endif + #endif const uchar* bytesToEncode((const uchar*)data);