From 4ddd3b86d15b63742cf5b0a4352815a39e0804b2 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 5 Oct 2017 09:46:16 +0200 Subject: [PATCH] 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)