From d442af3e1a637d76daa7daa60557a7a92078ab24 Mon Sep 17 00:00:00 2001 From: Richard Powell Date: Mon, 12 Apr 2021 13:46:40 -0700 Subject: [PATCH] Issue: not able to change beats on step drills. We weren't providing the right set of arguments to the replace function. Adding a static check to make sure all the other continuity functions are correct. --- src/core/cont.cpp | 61 ++++++++++++++++++++++++----------------------- src/core/cont.h | 30 +++++++++++++++++++++++ 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/src/core/cont.cpp b/src/core/cont.cpp index d5d59949..2ae7d90a 100644 --- a/src/core/cont.cpp +++ b/src/core/cont.cpp @@ -149,9 +149,10 @@ void replace_helper2(R replace, UP& new_value, T& t, Ts&... ts) } } -template +template void replace_helper(P parent, R replace, UP& new_value, T& t, Ts&... ts) { + static_assert(N == (sizeof...(Ts) + 1)); replace_helper2(replace, new_value, t, ts...); SetParentPtr_helper(parent, t, ts...); } @@ -1022,7 +1023,7 @@ std::unique_ptr ContValueAdd::clone() const void ContValueAdd::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, val1, val2); + replace_helper(this, which, v, val1, val2); } std::vector ContValueAdd::Serialize() const @@ -1095,7 +1096,7 @@ std::unique_ptr ContValueSub::clone() const void ContValueSub::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, val1, val2); + replace_helper(this, which, v, val1, val2); } std::vector ContValueSub::Serialize() const @@ -1168,7 +1169,7 @@ std::unique_ptr ContValueMult::clone() const void ContValueMult::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, val1, val2); + replace_helper(this, which, v, val1, val2); } std::vector ContValueMult::Serialize() const @@ -1247,7 +1248,7 @@ std::unique_ptr ContValueDiv::clone() const void ContValueDiv::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, val1, val2); + replace_helper(this, which, v, val1, val2); } std::vector ContValueDiv::Serialize() const @@ -1315,7 +1316,7 @@ std::unique_ptr ContValueNeg::clone() const void ContValueNeg::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, val); + replace_helper(this, which, v, val); } std::vector ContValueNeg::Serialize() const @@ -1546,7 +1547,7 @@ std::unique_ptr ContFuncDir::clone() const void ContFuncDir::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt); + replace_helper(this, which, v, pnt); } std::vector ContFuncDir::Serialize() const @@ -1622,7 +1623,7 @@ std::unique_ptr ContFuncDirFrom::clone() const void ContFuncDirFrom::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt_start, pnt_end); + replace_helper(this, which, v, pnt_start, pnt_end); } std::vector ContFuncDirFrom::Serialize() const @@ -1694,7 +1695,7 @@ std::unique_ptr ContFuncDist::clone() const void ContFuncDist::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt); + replace_helper(this, which, v, pnt); } std::vector ContFuncDist::Serialize() const @@ -1766,7 +1767,7 @@ std::unique_ptr ContFuncDistFrom::clone() const void ContFuncDistFrom::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt_start, pnt_end); + replace_helper(this, which, v, pnt_start, pnt_end); } std::vector ContFuncDistFrom::Serialize() const @@ -1858,7 +1859,7 @@ std::unique_ptr ContFuncEither::clone() const void ContFuncEither::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, dir1, dir2, pnt); + replace_helper(this, which, v, dir1, dir2, pnt); } std::vector ContFuncEither::Serialize() const @@ -1931,7 +1932,7 @@ std::unique_ptr ContFuncOpp::clone() const void ContFuncOpp::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, dir); + replace_helper(this, which, v, dir); } std::vector ContFuncOpp::Serialize() const @@ -2006,7 +2007,7 @@ std::unique_ptr ContFuncStep::clone() const void ContFuncStep::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, blksize, pnt); + replace_helper(this, which, v, numbeats, blksize, pnt); } std::vector ContFuncStep::Serialize() const @@ -2320,7 +2321,7 @@ std::unique_ptr ContProcCM::clone() const void ContProcCM::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt1, pnt2, stps, dir1, dir2, numbeats); + replace_helper(this, which, v, pnt1, pnt2, stps, dir1, dir2, numbeats); } std::vector ContProcCM::Serialize() const @@ -2438,7 +2439,7 @@ std::unique_ptr ContProcDMCM::clone() const void ContProcDMCM::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt1, pnt2, numbeats); + replace_helper(this, which, v, pnt1, pnt2, numbeats); } std::vector ContProcDMCM::Serialize() const @@ -2542,7 +2543,7 @@ std::unique_ptr ContProcDMHS::clone() const void ContProcDMHS::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt); + replace_helper(this, which, v, pnt); } std::vector ContProcDMHS::Serialize() const @@ -2621,7 +2622,7 @@ std::unique_ptr ContProcEven::clone() const void ContProcEven::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, stps, pnt); + replace_helper(this, which, v, stps, pnt); } std::vector ContProcEven::Serialize() const @@ -2708,7 +2709,7 @@ std::unique_ptr ContProcEWNS::clone() const void ContProcEWNS::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt); + replace_helper(this, which, v, pnt); } std::vector ContProcEWNS::Serialize() const @@ -2879,7 +2880,7 @@ std::unique_ptr ContProcFountain::clone() const void ContProcFountain::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, dir1, dir2, stepsize1, stepsize2, pnt); + replace_helper(this, which, v, dir1, dir2, stepsize1, stepsize2, pnt); } std::vector ContProcFountain::Serialize() const @@ -2982,7 +2983,7 @@ std::unique_ptr ContProcFM::clone() const void ContProcFM::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, stps, dir); + replace_helper(this, which, v, stps, dir); } std::vector ContProcFM::Serialize() const @@ -3058,7 +3059,7 @@ std::unique_ptr ContProcFMTO::clone() const void ContProcFMTO::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt); + replace_helper(this, which, v, pnt); } static inline Coord::units roundcoord(Coord::units a, Coord::units mod) @@ -3150,7 +3151,7 @@ std::unique_ptr ContProcGrid::clone() const void ContProcGrid::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, grid); + replace_helper(this, which, v, grid); } std::vector ContProcGrid::Serialize() const @@ -3243,7 +3244,7 @@ std::unique_ptr ContProcHSCM::clone() const void ContProcHSCM::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt1, pnt2, numbeats); + replace_helper(this, which, v, pnt1, pnt2, numbeats); } std::vector ContProcHSCM::Serialize() const @@ -3346,7 +3347,7 @@ std::unique_ptr ContProcHSDM::clone() const void ContProcHSDM::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt); + replace_helper(this, which, v, pnt); } std::vector ContProcHSDM::Serialize() const @@ -3416,7 +3417,7 @@ std::unique_ptr ContProcMagic::clone() const void ContProcMagic::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt); + replace_helper(this, which, v, pnt); } std::vector ContProcMagic::Serialize() const @@ -3525,7 +3526,7 @@ std::unique_ptr ContProcMarch::clone() const void ContProcMarch::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, stpsize, stps, dir, facedir); + replace_helper(this, which, v, stpsize, stps, dir, facedir); } std::vector ContProcMarch::Serialize() const @@ -3613,7 +3614,7 @@ std::unique_ptr ContProcMT::clone() const void ContProcMT::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, numbeats, dir); + replace_helper(this, which, v, numbeats, dir); } std::vector ContProcMT::Serialize() const @@ -3686,7 +3687,7 @@ std::unique_ptr ContProcMTRM::clone() const void ContProcMTRM::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, dir); + replace_helper(this, which, v, dir); } std::vector ContProcMTRM::Serialize() const @@ -3771,7 +3772,7 @@ std::unique_ptr ContProcNSEW::clone() const void ContProcNSEW::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, pnt); + replace_helper(this, which, v, pnt); } std::vector ContProcNSEW::Serialize() const @@ -3865,7 +3866,7 @@ std::unique_ptr ContProcRotate::clone() const void ContProcRotate::replace(ContToken const* which, std::unique_ptr v) { - replace_helper(this, which, v, ang, stps, pnt); + replace_helper(this, which, v, ang, stps, pnt); } std::vector ContProcRotate::Serialize() const diff --git a/src/core/cont.h b/src/core/cont.h index 0cb3abfa..7597bebe 100644 --- a/src/core/cont.h +++ b/src/core/cont.h @@ -321,6 +321,7 @@ class ContValueAdd : public ContValue { } private: + static constexpr auto NumParts = 2; std::unique_ptr val1, val2; }; @@ -348,6 +349,7 @@ class ContValueSub : public ContValue { } private: + static constexpr auto NumParts = 2; std::unique_ptr val1, val2; }; @@ -375,6 +377,7 @@ class ContValueMult : public ContValue { } private: + static constexpr auto NumParts = 2; std::unique_ptr val1, val2; }; @@ -402,6 +405,7 @@ class ContValueDiv : public ContValue { } private: + static constexpr auto NumParts = 2; std::unique_ptr val1, val2; }; @@ -428,6 +432,7 @@ class ContValueNeg : public ContValue { } private: + static constexpr auto NumParts = 1; std::unique_ptr val; }; @@ -512,6 +517,7 @@ class ContFuncDir : public ContValue { } private: + static constexpr auto NumParts = 1; std::unique_ptr pnt; }; @@ -539,6 +545,7 @@ class ContFuncDirFrom : public ContValue { } private: + static constexpr auto NumParts = 2; std::unique_ptr pnt_start, pnt_end; }; @@ -565,6 +572,7 @@ class ContFuncDist : public ContValue { } private: + static constexpr auto NumParts = 1; std::unique_ptr pnt; }; @@ -592,6 +600,7 @@ class ContFuncDistFrom : public ContValue { } private: + static constexpr auto NumParts = 2; std::unique_ptr pnt_start, pnt_end; }; @@ -619,6 +628,7 @@ class ContFuncEither : public ContValue { } private: + static constexpr auto NumParts = 3; std::unique_ptr dir1, dir2; std::unique_ptr pnt; }; @@ -646,6 +656,7 @@ class ContFuncOpp : public ContValue { } private: + static constexpr auto NumParts = 1; std::unique_ptr dir; }; @@ -673,6 +684,7 @@ class ContFuncStep : public ContValue { } private: + static constexpr auto NumParts = 3; std::unique_ptr numbeats, blksize; std::unique_ptr pnt; }; @@ -732,6 +744,7 @@ class ContProcSet : public ContProcedure { } private: + static constexpr auto NumParts = 2; std::unique_ptr var; std::unique_ptr val; }; @@ -782,6 +795,7 @@ class ContProcCM : public ContProcedure { } private: + static constexpr auto NumParts = 6; std::unique_ptr pnt1, pnt2; std::unique_ptr stps, dir1, dir2, numbeats; }; @@ -810,6 +824,7 @@ class ContProcDMCM : public ContProcedure { } private: + static constexpr auto NumParts = 3; std::unique_ptr pnt1, pnt2; std::unique_ptr numbeats; }; @@ -838,6 +853,7 @@ class ContProcDMHS : public ContProcedure { } private: + static constexpr auto NumParts = 1; std::unique_ptr pnt; }; @@ -865,6 +881,7 @@ class ContProcEven : public ContProcedure { } private: + static constexpr auto NumParts = 2; std::unique_ptr stps; std::unique_ptr pnt; }; @@ -893,6 +910,7 @@ class ContProcEWNS : public ContProcedure { } private: + static constexpr auto NumParts = 1; std::unique_ptr pnt; }; @@ -936,6 +954,7 @@ class ContProcFountain : public ContProcedure { } private: + static constexpr auto NumParts = 5; std::unique_ptr dir1, dir2; std::unique_ptr stepsize1, stepsize2; std::unique_ptr pnt; @@ -965,6 +984,7 @@ class ContProcFM : public ContProcedure { } private: + static constexpr auto NumParts = 2; std::unique_ptr stps, dir; }; @@ -992,6 +1012,7 @@ class ContProcFMTO : public ContProcedure { } private: + static constexpr auto NumParts = 1; std::unique_ptr pnt; }; @@ -1019,6 +1040,7 @@ class ContProcGrid : public ContProcedure { } private: + static constexpr auto NumParts = 1; std::unique_ptr grid; }; @@ -1046,6 +1068,7 @@ class ContProcHSCM : public ContProcedure { } private: + static constexpr auto NumParts = 3; std::unique_ptr pnt1, pnt2; std::unique_ptr numbeats; }; @@ -1074,6 +1097,7 @@ class ContProcHSDM : public ContProcedure { } private: + static constexpr auto NumParts = 1; std::unique_ptr pnt; }; @@ -1101,6 +1125,7 @@ class ContProcMagic : public ContProcedure { } private: + static constexpr auto NumParts = 1; std::unique_ptr pnt; }; @@ -1140,6 +1165,7 @@ class ContProcMarch : public ContProcedure { } private: + static constexpr auto NumParts = 4; std::unique_ptr stpsize, stps, dir, facedir; }; @@ -1167,6 +1193,7 @@ class ContProcMT : public ContProcedure { } private: + static constexpr auto NumParts = 2; std::unique_ptr numbeats, dir; }; @@ -1194,6 +1221,7 @@ class ContProcMTRM : public ContProcedure { } private: + static constexpr auto NumParts = 1; std::unique_ptr dir; }; @@ -1221,6 +1249,7 @@ class ContProcNSEW : public ContProcedure { } private: + static constexpr auto NumParts = 1; std::unique_ptr pnt; }; @@ -1248,6 +1277,7 @@ class ContProcRotate : public ContProcedure { } private: + static constexpr auto NumParts = 3; std::unique_ptr ang, stps; std::unique_ptr pnt; };