diff --git a/src/proc/control/command-setup.cpp b/src/proc/control/command-setup.cpp index e02adf56e..6a1dc98f4 100644 --- a/src/proc/control/command-setup.cpp +++ b/src/proc/control/command-setup.cpp @@ -36,6 +36,7 @@ #include "lib/error.hpp" //#include "lib/symbol.hpp" #include "include/logging.h" +#include "include/lifecycle.h" //#include "lib/format-string.hpp" #include "proc/control/command-setup.hpp" #include "proc/control/command-instance-manager.hpp" @@ -53,6 +54,8 @@ using std::get; using std::function; using std::move; using lib::Symbol; +using lumiera::LifecycleHook; +using lumiera::ON_GLOBAL_INIT; //using util::cStr; //using util::_Fmt; @@ -117,11 +120,16 @@ namespace control { return *this; } - + size_t + CommandSetup::pendingCnt() + { + return pendingCmdDefinitions.size(); + } + + void CommandSetup::invokeDefinitionClosures() { - size_t cnt=0; while (not pendingCmdDefinitions.empty()) { CmdDefEntry& entry = pendingCmdDefinitions.back(); @@ -131,16 +139,13 @@ namespace control { INFO (command, "defining Command(%s)...", cmdID.c()); CommandDef def(cmdID); buildDefinition(def); - ++cnt; pendingCmdDefinitions.pop_back(); } - return cnt; } - - size_t - CommandSetup::pendingCnt() - { - return pendingCmdDefinitions.size(); + + namespace { // automatically invoke static command definitions + + LifecycleHook schedule_ (ON_GLOBAL_INIT, &CommandSetup::invokeDefinitionClosures); } diff --git a/src/proc/control/command-setup.hpp b/src/proc/control/command-setup.hpp index 4d0e86f5b..65ed9336c 100644 --- a/src/proc/control/command-setup.hpp +++ b/src/proc/control/command-setup.hpp @@ -105,7 +105,7 @@ namespace control { CommandSetup& operator= (DefinitionClosure); /** @internal empty the definition queue and invoke definitions */ - static size_t invokeDefinitionClosures(); + static void invokeDefinitionClosures(); /** diagnostics / test */ static size_t pendingCnt(); diff --git a/tests/core/proc/control/command-setup-test.cpp b/tests/core/proc/control/command-setup-test.cpp index a2eca56c8..f4044f97f 100644 --- a/tests/core/proc/control/command-setup-test.cpp +++ b/tests/core/proc/control/command-setup-test.cpp @@ -194,9 +194,8 @@ namespace test { { CHECK (isnil (testString)); - size_t cnt = CommandSetup::invokeDefinitionClosures(); + CommandSetup::invokeDefinitionClosures(); CHECK (CommandSetup::pendingCnt() == 0); - CHECK (cnt == 3); CHECK (testString == "Ichthyostega wuz here"); // the closure for the first entry did "something pointless", diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index a3207a8a1..ef00d073e 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -11916,7 +11916,7 @@ - + @@ -11947,8 +11947,7 @@ - - + @@ -11974,9 +11973,10 @@ - - - + + + + @@ -12010,11 +12010,17 @@ - - + + + + + + + + + + - -