Symbol-Table hack: the disease starts to spread (#158)
we need a real symbol table implementation, so we can assemble symbols and then intern them. This was the whole purpose of inventing the class Symbol
This commit is contained in:
parent
97d7a6804e
commit
3dcd84232c
4 changed files with 35 additions and 27 deletions
|
|
@ -42,8 +42,12 @@ extern "C" {
|
|||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <deque>
|
||||
|
||||
using std::size_t;
|
||||
using std::string;
|
||||
using boost::hash_combine;
|
||||
|
||||
|
||||
|
|
@ -85,4 +89,21 @@ namespace lib {
|
|||
|
||||
|
||||
|
||||
namespace { // quick-n-dirty symbol table implementation
|
||||
|
||||
/** @warning grows eternally, never shrinks */
|
||||
std::deque<string> idStringBuffer; ////////////////////////////////TICKET #158 replace by symbol table
|
||||
}
|
||||
|
||||
/** @internal quick-n-dirty hack, used as workaround for creating command-IDs on the fly */
|
||||
Symbol
|
||||
internedString (string&& idString)
|
||||
{
|
||||
idStringBuffer.emplace_back (std::forward<string> (idString));
|
||||
return Symbol (idStringBuffer.back().c_str());
|
||||
}
|
||||
/////////////////////////////////////(End)symbol-table hack
|
||||
|
||||
|
||||
|
||||
} // namespace lib
|
||||
|
|
|
|||
|
|
@ -167,7 +167,19 @@ namespace lib {
|
|||
const char* symP (sym);
|
||||
return symP + str;
|
||||
}
|
||||
|
||||
|
||||
/* ===== temporary symbol table workaround ===== */
|
||||
|
||||
/** place the string persistently in memory.
|
||||
* @todo temporary workaround, shall be replaced by lib::Symbol implementation ///////////////TICKET #157 maintain symbol table for interned strings
|
||||
* @return a C-String marked as lib::Symbol, pointing
|
||||
* to the permanent location in heap memory.
|
||||
* @warning eternally growing, please look away...
|
||||
* @see symbol-impl.cpp implementation
|
||||
*/
|
||||
Symbol internedString (std::string&& idString);
|
||||
|
||||
|
||||
} // namespace lib
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -62,15 +62,6 @@ namespace test{
|
|||
using lib::Symbol;
|
||||
|
||||
|
||||
/** place the string persistently in memory.
|
||||
* @internal used as workaround for creating command-IDs on the fly
|
||||
* @todo temporary workaround, shall be replaced by lib::Symbol implementation ///////////////TICKET #157 maintain symbol table for interned strings
|
||||
* @return a C-String marked as lib::Literal, pointing
|
||||
* to the permanent location in heap memory.
|
||||
* @see \ref test-nexus.cpp implementation
|
||||
*/
|
||||
Symbol internedString (string&& idString);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -130,7 +121,7 @@ namespace test{
|
|||
fabricateNewInstance (lib::test::EventLog const& invocationLog)
|
||||
{
|
||||
log_ = invocationLog;
|
||||
return proc::control::CommandDef(internedString (uniqueTypeInstance()))
|
||||
return proc::control::CommandDef(lib::internedString (uniqueTypeInstance()))
|
||||
.operation(PlaceholderCommand::operate)
|
||||
.captureUndo(PlaceholderCommand::capture)
|
||||
.undoOperation(PlaceholderCommand::undo);
|
||||
|
|
|
|||
|
|
@ -89,22 +89,6 @@ using util::_Fmt;
|
|||
namespace gui {
|
||||
namespace test{
|
||||
|
||||
namespace { // quick-n-dirty symbol table implementation
|
||||
|
||||
/** @warning grows eternally, never shrinks */
|
||||
std::deque<string> idStringBuffer; ////////////////////////////////TICKET #158 replace by symbol table
|
||||
}
|
||||
|
||||
Symbol
|
||||
internedString (string&& idString)
|
||||
{
|
||||
idStringBuffer.emplace_back (std::forward<string> (idString));
|
||||
return Symbol (idStringBuffer.back().c_str());
|
||||
}
|
||||
////////////////////////(End)symbol-table hack
|
||||
|
||||
|
||||
|
||||
|
||||
namespace { // internal details
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue