From dccc41f15668e94e36d544521bf15effb32c0f3b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 30 Jun 2015 02:31:36 +0200 Subject: [PATCH] EntryID(#865): switch ID generation to the newly defined generic ID functions ...first step to get rid of the proc::asset dependency --- src/lib/idi/genfunc.cpp | 2 +- src/lib/idi/genfunc.hpp | 8 ++++---- src/proc/asset/entry-id.hpp | 25 ++++++++++++------------- src/proc/asset/struct-scheme.hpp | 10 ---------- 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/lib/idi/genfunc.cpp b/src/lib/idi/genfunc.cpp index 76ca64e7b..bfcf7415f 100644 --- a/src/lib/idi/genfunc.cpp +++ b/src/lib/idi/genfunc.cpp @@ -40,7 +40,7 @@ namespace test{ // see test-helper.cpp namespace idi { - namespace { // generic entry points / integration helpers... + namespace format { // generic entry points / integration helpers... using lib::test::demangleCxx; diff --git a/src/lib/idi/genfunc.hpp b/src/lib/idi/genfunc.hpp index 53f760674..657f34d7c 100644 --- a/src/lib/idi/genfunc.hpp +++ b/src/lib/idi/genfunc.hpp @@ -57,7 +57,7 @@ namespace idi { using lib::HashVal; using std::string; - namespace { // integration helpers... + namespace format { // integration helpers... string demangled_innermost_component (const char* rawName); string demangled_sanitised_name (const char* rawName); @@ -75,7 +75,7 @@ namespace idi { inline string typeSymbol() { - return demangled_innermost_component (typeid(TY).name()); + return format::demangled_innermost_component (typeid(TY).name()); } /** Complete unique type identifier @@ -87,7 +87,7 @@ namespace idi { inline string typeFullID() { - return demangled_sanitised_name (typeid(TY).name()); + return format::demangled_sanitised_name (typeid(TY).name()); } template @@ -117,7 +117,7 @@ namespace idi { generateSymbolicID() { static TypedCounter instanceCounter; - return instance_formatter (namePrefix(), instanceCounter.inc()); + return format::instance_formatter (namePrefix(), instanceCounter.inc()); } /** diff --git a/src/proc/asset/entry-id.hpp b/src/proc/asset/entry-id.hpp index d4bc7b6db..d22e0d3a8 100644 --- a/src/proc/asset/entry-id.hpp +++ b/src/proc/asset/entry-id.hpp @@ -61,6 +61,8 @@ namespace asset { using std::string; using std::ostream; + using lib::idi::generateSymbolicID; + using lib::idi::getTypeHash; /** @@ -72,9 +74,12 @@ namespace asset { */ namespace idi { - using lib::hash::LuidH; - using lib::HashVal; + } + using lib::hash::LuidH; + using lib::HashVal; + + namespace { /** build up a hash value, packaged as LUID. * @param sym symbolic ID-string to be hashed @@ -131,9 +136,9 @@ namespace asset { * encoded into a hash seed. Thus even the same symbolicID * generates differing hash-IDs for different type parameters */ - BareEntryID (string const& symbolID, idi::HashVal seed =0) + BareEntryID (string const& symbolID, HashVal seed =0) : symbol_(util::sanitise(symbolID)) - , hash_(idi::buildHash (symbol_, seed)) + , hash_(buildHash (symbol_, seed)) { } public: @@ -201,7 +206,7 @@ namespace asset { /** case-1: auto generated symbolic ID */ EntryID() - : BareEntryID (idi::generateSymbolID(), getTypeHash()) /////////////TICKET #565 : how to organise access; this is not thread safe + : BareEntryID (generateSymbolicID(), getTypeHash()) { } /** case-2: explicitly specify a symbolic ID to use. @@ -210,7 +215,7 @@ namespace asset { */ explicit EntryID (string const& symbolID) - : BareEntryID (symbolID, getTypeHash()) + : BareEntryID (symbolID, getTypeHash()) { } @@ -228,12 +233,6 @@ namespace asset { return Asset::Ident (this->getSym(), cat); } - static idi::HashVal - getTypeHash() - { - return hash_value (Category (STRUCT, idi::StructTraits::catFolder())); - } - /** @return true if the upcast would yield exactly the same * tuple (symbol,type) as was used on original definition @@ -243,7 +242,7 @@ namespace asset { static bool canRecast (BareEntryID const& bID) { - return bID.getHash() == idi::buildHash (bID.getSym(), getTypeHash()); + return bID.getHash() == buildHash (bID.getSym(), getTypeHash()); } static EntryID diff --git a/src/proc/asset/struct-scheme.hpp b/src/proc/asset/struct-scheme.hpp index 5730d08b6..34b2bc581 100644 --- a/src/proc/asset/struct-scheme.hpp +++ b/src/proc/asset/struct-scheme.hpp @@ -148,16 +148,6 @@ namespace asset{ - template - inline string - generateSymbolID() - { - static uint i=0; - static format namePattern ("%s.%03d"); - ////////////////////////////////////////////////////////////////////////////////TICKET #166 : needs to be pushed down into a *.cpp - - return str(namePattern % StructTraits::namePrefix() % (++i) ); //////////TICKET #565 : how to organise access; this ought to be thread safe (-> EntryID ) - } }}} // namespace asset::idi