From 9dd9c9557cdf26fe2a5e52322dafcc1f65aca45b Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Fri, 13 Nov 2020 15:13:05 -0600 Subject: [PATCH] Abort hook functions on any result other than `OK` Instead of only aborting hook functions if a handler returns `EVENT_CONSUMED`, only continue abortable hooks if a handler returns `OK`. For existing core plugins, this shouldn't make any difference because none of them use the `ERROR` return value. Also rename `shouldAbortOnConsumedEvent` to better match the new conditional. Signed-off-by: Michael Richters --- src/kaleidoscope/event_handlers.h | 6 +++--- src/kaleidoscope/hooks.cpp | 2 +- src/kaleidoscope/hooks.h | 2 +- src/kaleidoscope_internal/event_dispatch.h | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/kaleidoscope/event_handlers.h b/src/kaleidoscope/event_handlers.h index 29b73d29..535d4e61 100644 --- a/src/kaleidoscope/event_handlers.h +++ b/src/kaleidoscope/event_handlers.h @@ -27,7 +27,7 @@ // OPERATION once for each event handler defined herein with the following // parameters: // -// HOOK_NAME, SHOULD_ABORT_ON_CONSUMED_EVENT, SIGNATURE, ARGS_LIST, ... +// HOOK_NAME, SHOULD_EXIT_IF_RESULT_NOT_OK, SIGNATURE, ARGS_LIST, ... // // Any additional parameters that are added to an invokation // of _FOR_EACH_EVENT_HANDLER are passed through to OP. @@ -72,8 +72,8 @@ // Plugins' event handlers are called in the same order as the plugins // are passed to the KALEIDOSCOPE_INIT_PLUGINS(...) macro within the // sketch. For some handlers it is desirable to not call subsequent -// plugins' handlers once a plugin's handler returned the value -// kaleidoscope::EventHandlerResult::EVENT_CONSUMED. To enable this +// plugins' handlers once a plugin's handler returned a value other +// than kaleidoscope::EventHandlerResult::OK. To enable this, // pass the abortable flag value _ABORTABLE, _NOT_ABORTABLE otherwise. // // template parameter type list: diff --git a/src/kaleidoscope/hooks.cpp b/src/kaleidoscope/hooks.cpp index 015837f5..c99a0032 100644 --- a/src/kaleidoscope/hooks.cpp +++ b/src/kaleidoscope/hooks.cpp @@ -32,7 +32,7 @@ namespace kaleidoscope { #define INSTANTIATE_WEAK_HOOK_FUNCTION( \ HOOK_NAME, HOOK_VERSION, DEPRECATION_TAG, \ - SHOULD_ABORT_ON_CONSUMED_EVENT, \ + SHOULD_EXIT_IF_RESULT_NOT_OK, \ TMPL_PARAM_TYPE_LIST, TMPL_PARAM_LIST, TMPL_DUMMY_ARGS_LIST, \ SIGNATURE, ARGS_LIST) __NL__ \ __NL__ \ diff --git a/src/kaleidoscope/hooks.h b/src/kaleidoscope/hooks.h index abd6f682..d59ffccf 100644 --- a/src/kaleidoscope/hooks.h +++ b/src/kaleidoscope/hooks.h @@ -78,7 +78,7 @@ class Hooks { #define DEFINE_WEAK_HOOK_FUNCTION( \ HOOK_NAME, HOOK_VERSION, DEPRECATION_TAG, \ - SHOULD_ABORT_ON_CONSUMED_EVENT, \ + SHOULD_EXIT_IF_RESULT_NOT_OK, \ TMPL_PARAM_TYPE_LIST, TMPL_PARAM_LIST, TMPL_DUMMY_ARGS_LIST, \ SIGNATURE, ARGS_LIST) __NL__ \ __NL__ \ diff --git a/src/kaleidoscope_internal/event_dispatch.h b/src/kaleidoscope_internal/event_dispatch.h index 5211e86d..747dc270 100644 --- a/src/kaleidoscope_internal/event_dispatch.h +++ b/src/kaleidoscope_internal/event_dispatch.h @@ -80,7 +80,7 @@ #define _REGISTER_EVENT_HANDLER( \ HOOK_NAME, HOOK_VERSION, DEPRECATION_TAG, \ - SHOULD_ABORT_ON_CONSUMED_EVENT, \ + SHOULD_EXIT_IF_RESULT_NOT_OK, \ TMPL_PARAM_TYPE_LIST, TMPL_PARAM_LIST, TMPL_DUMMY_ARGS_LIST, \ SIGNATURE, ARGS_LIST) __NL__ \ __NL__ \ @@ -116,8 +116,8 @@ MAKE_TEMPLATE_SIGNATURE(UNWRAP TMPL_PARAM_TYPE_LIST) __NL__ \ struct _NAME4(EventHandler_, HOOK_NAME, _v, HOOK_VERSION) { __NL__ \ __NL__ \ - static bool shouldAbortOnConsumedEvent() { __NL__ \ - return SHOULD_ABORT_ON_CONSUMED_EVENT; __NL__ \ + static bool shouldExitIfResultNotOk() { __NL__ \ + return SHOULD_EXIT_IF_RESULT_NOT_OK; __NL__ \ } __NL__ \ __NL__ \ template