Commands: add automatic registration ON_GLOBAL_INIT
...which makes the unit test PASS
This commit is contained in:
parent
49102ff18f
commit
e7d24febee
4 changed files with 32 additions and 22 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -11916,7 +11916,7 @@
|
|||
<node CREATED="1489781923640" ID="ID_241861600" MODIFIED="1489781930043" TEXT="kommentierbar (Doxygen)"/>
|
||||
<node CREATED="1489785114574" ID="ID_241665479" MODIFIED="1489785123487" TEXT="nur unsichtbare Magie"/>
|
||||
</node>
|
||||
<node CREATED="1489785137083" ID="ID_1466955376" MODIFIED="1489785144694" TEXT="Möglichkeiten">
|
||||
<node CREATED="1489785137083" FOLDED="true" ID="ID_1466955376" MODIFIED="1490927752773" TEXT="Möglichkeiten">
|
||||
<node CREATED="1489785163216" ID="ID_1992894903" MODIFIED="1489785168547" TEXT="zu Fuß...">
|
||||
<node CREATED="1489785199131" ID="ID_111396262" MODIFIED="1489785207662" TEXT="ID-Konstanten im Header deklarieren"/>
|
||||
<node CREATED="1489785208298" ID="ID_315886293" MODIFIED="1489785222188" TEXT="ID-Konstanten in der jeweiligen translation-Unit definieren"/>
|
||||
|
|
@ -11947,8 +11947,7 @@
|
|||
</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1489789880260" ID="ID_768121026" MODIFIED="1489789887822" TEXT="Template-Spezialisierung?">
|
||||
|
|
@ -11974,9 +11973,10 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1489791729957" ID="ID_1986771449" MODIFIED="1489811251908" TEXT="kombinierte Magie">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node CREATED="1489791798116" ID="ID_197500257" MODIFIED="1489791804727" TEXT="Definitions-Klasse">
|
||||
<node CREATED="1489791729957" ID="ID_1986771449" MODIFIED="1490927727826" TEXT="kombinierte Magie">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1489791798116" ID="ID_197500257" MODIFIED="1490927767187" TEXT="Definitions-Klasse">
|
||||
<icon BUILTIN="idea"/>
|
||||
<node CREATED="1489791805675" ID="ID_1517636242" MODIFIED="1489811237752" TEXT="ist konvertierbar nach Literal">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
|
|
@ -12010,11 +12010,17 @@
|
|||
</node>
|
||||
</node>
|
||||
<node CREATED="1489811274588" ID="ID_1635051629" MODIFIED="1489811278807" TEXT="Mechanismus">
|
||||
<node CREATED="1489811285746" ID="ID_1726037509" MODIFIED="1489811319093" TEXT="CommandSetup">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1489811285746" ID="ID_1726037509" MODIFIED="1490927663610" TEXT="CommandSetup">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1489811291313" ID="ID_1780064476" MODIFIED="1490927667601" TEXT="Makro COMMAND_DEFINITION">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1489811304111" ID="ID_1976451454" MODIFIED="1490927673243" TEXT="Build-Generierung">
|
||||
<icon BUILTIN="hourglass"/>
|
||||
<node CREATED="1490927680004" ID="ID_1456638216" MODIFIED="1490927687183" TEXT="auf "später" vertagt"/>
|
||||
<node CREATED="1490927702128" ID="ID_1355040899" MODIFIED="1490927711041" TEXT="wenn die händische Pflege zum Problem wird"/>
|
||||
</node>
|
||||
<node CREATED="1489811291313" ID="ID_1780064476" MODIFIED="1489811302099" TEXT="Makro COMMAND_DEFINITION"/>
|
||||
<node CREATED="1489811304111" ID="ID_1976451454" MODIFIED="1489811316290" TEXT="Build-Generierung"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue