From df68cd510d48a2204b46385deadcc39923fcf842 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 25 Jul 2018 12:20:31 +0200 Subject: [PATCH] Display a useful error when using the old-style API Override the copy constructor of `combo_t`, so that we can display an error when initializing using the old-style API. Fixes #8. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/MagicCombo.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Kaleidoscope/MagicCombo.h b/src/Kaleidoscope/MagicCombo.h index 22184ba7..38e669a2 100644 --- a/src/Kaleidoscope/MagicCombo.h +++ b/src/Kaleidoscope/MagicCombo.h @@ -31,6 +31,13 @@ } \ } +#define _MAGICCOMBO_API_CHANGE \ + "The MagicCombo API changed in an incompatible way, you will need to\n" \ + "upgrade.\n" \ + "\n" \ + "Please see the `UPGRADING.md` document shipped with the source:\n" \ + " https://github.com/keyboardio/Kaleidoscope-MagicCombo/blob/master/UPGRADING.md" + namespace kaleidoscope { class MagicCombo : public kaleidoscope::Plugin { @@ -43,8 +50,15 @@ class MagicCombo : public kaleidoscope::Plugin { typedef struct combo_t { uint32_t left_hand, right_hand; - private: - combo_t(byte left, byte right) {} + template + struct always_false { + enum { value = false }; + }; + + template + combo_t(T l, T r) { + static_assert(always_false::value, _DEPRECATE(_MAGICCOMBO_API_CHANGE)); + } } combo_t; MagicCombo(void) {}