From 646a9d65f9a5f69e279b78f25bf39802a7e6548a Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 5 Oct 2017 09:24:17 +0200 Subject: [PATCH 1/4] Add a deprecation message to the _hook_use functions To make it easier to migrate, add a hint that tells us what to use instead. Signed-off-by: Gergely Nagy --- src/Kaleidoscope.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Kaleidoscope.h b/src/Kaleidoscope.h index 85ae047c..5a27c9db 100644 --- a/src/Kaleidoscope.h +++ b/src/Kaleidoscope.h @@ -120,6 +120,7 @@ extern Kaleidoscope_ Kaleidoscope; "layer.getState") /* -- DEPRECATED aliases; remove them when there are no more users. -- */ - -void event_handler_hook_use(Kaleidoscope_::eventHandlerHook hook) __attribute__((deprecated)); -void loop_hook_use(Kaleidoscope_::loopHook hook) __attribute__((deprecated)); +void event_handler_hook_use(Kaleidoscope_::eventHandlerHook hook) +__attribute__((deprecated("Use Kaleidoscope.useEventHandlerHook instead"))); +void loop_hook_use(Kaleidoscope_::loopHook hook) +__attribute__((deprecated("Use Kaleidoscope.useLoopHook instead"))); From 1025957eaaef8960378f23e3487a7d548bd88126 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 5 Oct 2017 09:25:24 +0200 Subject: [PATCH 2/4] Deprecate Kaleidoscope.setup(keymap_count) We do not use `keymap_count` anymore, so deprecate this variant of the setup function, with a message that also tells the user that `KEYMAP_SIZE` is deprecated too. Signed-off-by: Gergely Nagy --- src/Kaleidoscope.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Kaleidoscope.h b/src/Kaleidoscope.h index 5a27c9db..1da08a09 100644 --- a/src/Kaleidoscope.h +++ b/src/Kaleidoscope.h @@ -46,7 +46,8 @@ class Kaleidoscope_ { public: Kaleidoscope_(void); - void setup(const byte keymap_count) { + void setup(const byte keymap_count) + __attribute__((deprecated("The keymap_count argument (and the KEYMAP_SIZE macro) are unused, and can be safely removed."))) { setup(); } void setup(void); From 952ef25177a0ff76406f98b44e1216334cfa0607 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 5 Oct 2017 09:36:47 +0200 Subject: [PATCH 3/4] Deprecate KEYMAP_SIZE too This was only ever used for `Kaleidoscope.setup()`, and while the variant that takes an argument is deprecated, and emits a warning already, we can do the same for `KEYMAP_SIZE` too. This does set the const to 0, so if used anywhere else than `Kaleidoscope.setup()`, it will have undesired side-effects. But as far as I saw, it was never used elsewhere, thus, this change should be safe. Signed-off-by: Gergely Nagy --- src/Kaleidoscope.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Kaleidoscope.h b/src/Kaleidoscope.h index 1da08a09..338fc8b2 100644 --- a/src/Kaleidoscope.h +++ b/src/Kaleidoscope.h @@ -33,7 +33,8 @@ extern HARDWARE_IMPLEMENTATION KeyboardHardware; #define VERSION "locally-built" #endif -#define KEYMAP_SIZE (sizeof(keymaps) / ROWS / COLS / sizeof(Key)) +const uint8_t KEYMAP_SIZE +__attribute__((deprecated("Kaleidoscope.setup() does not require KEYMAP_SIZE anymore."))) = 0; #define USE_PLUGINS(plugins...) Kaleidoscope.use(plugins) From 4ddd3b86d15b63742cf5b0a4352815a39e0804b2 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 5 Oct 2017 09:46:16 +0200 Subject: [PATCH 4/4] Deprecate USE_PLUGINS `Kaleidoscope.use` is a much better interface, therefore deprecate USE_PLUGINS. We do this by creating a wrapper function, `__USE_PLUGINS` that will call `Kaleidoscope.use` under the hood, but has a deprecated attribute attached. We then make the `USE_PLUGINS` macro call this function. We do this because we want to make sure that the list is NULL-terminated, and for that, we need the macro. Signed-off-by: Gergely Nagy --- src/Kaleidoscope.cpp | 11 +++++++++++ src/Kaleidoscope.h | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Kaleidoscope.cpp b/src/Kaleidoscope.cpp index 33fd00be..f4502920 100644 --- a/src/Kaleidoscope.cpp +++ b/src/Kaleidoscope.cpp @@ -144,3 +144,14 @@ void event_handler_hook_use(Kaleidoscope_::eventHandlerHook hook) { void loop_hook_use(Kaleidoscope_::loopHook hook) { Kaleidoscope.useLoopHook(hook); } + +void __USE_PLUGINS(KaleidoscopePlugin *plugin, ...) { + va_list ap; + + Kaleidoscope.use(plugin); + + va_start(ap, plugin); + while ((plugin = (KaleidoscopePlugin *)va_arg(ap, KaleidoscopePlugin *)) != NULL) + Kaleidoscope.use(plugin); + va_end(ap); +} diff --git a/src/Kaleidoscope.h b/src/Kaleidoscope.h index 338fc8b2..23ebbaf6 100644 --- a/src/Kaleidoscope.h +++ b/src/Kaleidoscope.h @@ -36,8 +36,6 @@ extern HARDWARE_IMPLEMENTATION KeyboardHardware; const uint8_t KEYMAP_SIZE __attribute__((deprecated("Kaleidoscope.setup() does not require KEYMAP_SIZE anymore."))) = 0; -#define USE_PLUGINS(plugins...) Kaleidoscope.use(plugins) - class KaleidoscopePlugin { public: virtual void begin(void) = 0; @@ -122,7 +120,13 @@ extern Kaleidoscope_ Kaleidoscope; "layer.getState") /* -- DEPRECATED aliases; remove them when there are no more users. -- */ + void event_handler_hook_use(Kaleidoscope_::eventHandlerHook hook) __attribute__((deprecated("Use Kaleidoscope.useEventHandlerHook instead"))); void loop_hook_use(Kaleidoscope_::loopHook hook) __attribute__((deprecated("Use Kaleidoscope.useLoopHook instead"))); + +void __USE_PLUGINS(KaleidoscopePlugin *plugin, ...) +__attribute__((deprecated("Use Kaleidoscope.use(...) instead"))); + +#define USE_PLUGINS(...) __USE_PLUGINS(__VA_ARGS__, NULL)