diff --git a/src/common/interface-facade-link.hpp b/src/common/interface-facade-link.hpp index 4e91f16b8..2811043ac 100644 --- a/src/common/interface-facade-link.hpp +++ b/src/common/interface-facade-link.hpp @@ -51,7 +51,7 @@ #include "lib/error.hpp" -#include "lib/test/test-helper.hpp" +#include "lib/meta/util.hpp" #include "include/interfaceproxy.hpp" #include "lib/symbol.hpp" @@ -85,7 +85,7 @@ namespace facade { : protected Accessor , boost::noncopyable { - Literal displayName_; + string displayName_; void __checkLifecycle () @@ -97,16 +97,17 @@ namespace facade { public: InterfaceFacadeLink(FA& serviceImpl, Literal interfaceName_for_Log=0) - : displayName_(lib::test::showType(interfaceName_for_Log)) + : displayName_(interfaceName_for_Log? string(interfaceName_for_Log) + : util::typeStr()) { __checkLifecycle(); Accessor::implProxy_ = &serviceImpl; - INFO (interface, "interface %s opened", displayName_.c()); + INFO (interface, "interface %s opened", displayName_.c_str()); } ~InterfaceFacadeLink() { - INFO (interface, "closing interface %s...", displayName_.c()); + INFO (interface, "closing interface %s...", displayName_.c_str()); Accessor::implProxy_ = 0; } }; diff --git a/src/lib/format-obj.cpp b/src/lib/format-obj.cpp index 9c34ecfae..1b4068244 100644 --- a/src/lib/format-obj.cpp +++ b/src/lib/format-obj.cpp @@ -45,6 +45,7 @@ //#include "lib/format-string.hpp" #include "lib/unique-malloc-owner.hpp" #include "lib/symbol.hpp" +#include "lib/util.hpp" #ifdef __GNUG__ #include @@ -55,6 +56,8 @@ #include //using util::_Fmt; +using util::removePrefix; +using util::removeSuffix; using std::string; @@ -73,6 +76,13 @@ namespace { // hard-wired configuration for debugging output.... namespace lib { namespace meta { + // pre-allocated failure indicators, which can be returned failsafe. + + extern const std::string FAILURE_INDICATOR = "↯"; + extern const std::string VOID_INDICATOR = "void"; + + + #ifdef __GNUG__ /** * \par Implementation notes @@ -141,13 +151,38 @@ apologies for that." + string humanReadableTypeID (Literal rawType) { string typeName = demangleCxx (rawType); + removePrefix (typeName, "const "); + removeSuffix (typeName, " const*"); return typeName; } + + string + primaryTypeComponent (Literal rawType) + { + string typeStr = demangleCxx (rawType); + size_t end = typeStr.rfind("<"); + size_t pos = typeStr.rfind("::", end); + if (pos != string::npos) + typeStr = (end==string::npos? typeStr.substr(pos+2) + : typeStr.substr(pos+2, end-pos-2)); + return typeStr; + } + + + string + sanitisedFullTypeName(lib::Literal rawName) + { + return util::sanitise (demangleCxx (rawName)); + } + + + }}// namespace lib::meta @@ -187,7 +222,7 @@ namespace util { return buffer.str(); } catch(...) - { return "↯"; } + { return FAILURE_INDICATOR; } string @@ -199,7 +234,7 @@ namespace util { return buffer.str(); } catch(...) - { return "↯"; } + { return FAILURE_INDICATOR; } /** @note show only the trailing X bytes of any address */ @@ -225,7 +260,7 @@ namespace util { return buffer.str(); } catch(...) - { return "↯"; } + { return FAILURE_INDICATOR; } diff --git a/src/lib/format-obj.hpp b/src/lib/format-obj.hpp index f33826a16..07c30ab2c 100644 --- a/src/lib/format-obj.hpp +++ b/src/lib/format-obj.hpp @@ -42,10 +42,10 @@ #ifndef LIB_FORMAT_OBJ_H #define LIB_FORMAT_OBJ_H +#include #include "lib/meta/trait.hpp" #include -#include namespace std { // forward declaration to avoid including @@ -65,19 +65,10 @@ namespace lib { namespace meta { - /** reverse the effect of C++ name mangling. - * @return string in language-level form of a C++ type or object name, - * or a string with the original input if demangling fails. - * @warning implementation relies on the cross vendor C++ ABI in use - * by GCC and compatible compilers, so portability is limited. - * The implementation is accessed through libStdC++ - * Name representation in emitted object code and type IDs is - * essentially an implementation detail and subject to change. - */ std::string demangleCxx (lib::Literal rawName); - - std::string humanReadableTypeID (lib::Literal); + std::string primaryTypeComponent (lib::Literal); + std::string sanitisedFullTypeName(lib::Literal); }}// namespace lib::meta @@ -113,7 +104,7 @@ namespace util { static std::string invoke (X const& val) noexcept try { return boost::lexical_cast (val); } - catch(...) { return "↯"; } + catch(...) { return FAILURE_INDICATOR; } }; /** explicit specialisation to control precision of double values. @@ -160,6 +151,23 @@ namespace util { } + /** + * indicate type and possibly a (custom) conversion to string + * @return human readable type name '|' string representation. + * or just the type, when no string representation available + */ + template + inline std::string + typedString (TY const& val) noexcept + try { + std::string repr = StringConv::invoke (val); + return 0 == repr.rfind("«", 0)? repr + : "«"+typeStr(val)+"»|"+repr; + } + catch(...) + { return FAILURE_INDICATOR; } + + } // namespace util #endif /*LIB_FORMAT_OBJ_H*/ diff --git a/src/lib/format-string.cpp b/src/lib/format-string.cpp index bea186abb..30f2481f0 100644 --- a/src/lib/format-string.cpp +++ b/src/lib/format-string.cpp @@ -160,9 +160,9 @@ namespace util { catch (boost::io::too_many_args& argErr) { - WARN (progress, "Format: excess argument '%s' of type %s ignored." + WARN (progress, "Format: excess argument '%s' of type «%s» ignored." , cStr(str(val)) - , cStr(tyStr(val))); + , cStr(typeStr(val))); } catch (std::exception& failure) { diff --git a/src/lib/format-string.hpp b/src/lib/format-string.hpp index 6d9ddc6fa..bf8bf6358 100644 --- a/src/lib/format-string.hpp +++ b/src/lib/format-string.hpp @@ -359,7 +359,7 @@ namespace util { static void dump (const char* cString, Implementation& impl) { - format (cString? cString : "↯", impl); + format (cString? cString : FAILURE_INDICATOR, impl); } }; diff --git a/src/lib/format-util.hpp b/src/lib/format-util.hpp index 29d176d0d..b2ef70355 100644 --- a/src/lib/format-util.hpp +++ b/src/lib/format-util.hpp @@ -25,8 +25,9 @@ ** Collection of small helpers and convenience shortcuts for diagnostics & formatting. ** - util::str() performs a failsafe to-String conversion, thereby preferring a ** built-in conversion operator, falling back to just a mangled type string. - ** - util::tyStr() generates a string corresponding to the type of the given object. - ** Currently just implemented through the mangled RTTI type string + ** - util::join() generates an enumerating string from elements + ** of an arbitrary sequence or iterable. Elements will be passed + ** through our [generic string conversion](\ref util::toString) ** ** @see FormatHelper_test ** @see [frontend for boost::format, printf-style](format-string.hpp) @@ -147,25 +148,6 @@ namespace util { }; }//(End) guards/helpers - - /** @return a string denoting the type. */ - template - inline string - tyStr (const TY* obj=0) - { - auto mangledType = obj? typeid(obj).name() - : typeid(TY).name(); - string typeName = lib::meta::demangleCxx (mangledType); - removePrefix (typeName, "const "); - removeSuffix (typeName, " const*"); - return "«"+ typeName +"»"; - } - - template - inline string - tyStr (TY const& ref) - { return tyStr(&ref); } - /** try to get an object converted to string. * A custom/standard conversion to string is used, @@ -186,7 +168,7 @@ namespace util { return string(prefix) + res; else return fallback? string(fallback) - : tyStr(val); + : "«"+typeStr(val)+"»"; } diff --git a/src/lib/idi/genfunc.cpp b/src/lib/idi/genfunc.cpp index d94626064..a1b5d4be3 100644 --- a/src/lib/idi/genfunc.cpp +++ b/src/lib/idi/genfunc.cpp @@ -40,27 +40,6 @@ namespace idi { namespace format { // generic entry points / integration helpers... - using lib::meta::demangleCxx; - - string - demangled_innermost_component (const char* rawName) - { - string typeStr = demangleCxx (rawName); - size_t end = typeStr.rfind("<"); - size_t pos = typeStr.rfind("::", end); - if (pos != string::npos) - typeStr = (end==string::npos? typeStr.substr(pos+2) - : typeStr.substr(pos+2, end-pos-2)); - return typeStr; - } - - string - demangled_sanitised_name (const char* rawName) - { - return util::sanitise (demangleCxx (rawName)); - } - - string instance_format (string const& prefix, size_t instanceNr) { @@ -79,5 +58,4 @@ namespace idi { - }} // namespace lib::idi diff --git a/src/lib/idi/genfunc.hpp b/src/lib/idi/genfunc.hpp index a9f6dac70..b0b35f987 100644 --- a/src/lib/idi/genfunc.hpp +++ b/src/lib/idi/genfunc.hpp @@ -55,14 +55,19 @@ namespace lib { +namespace meta{ + std::string demangleCxx (lib::Literal rawName); + std::string humanReadableTypeID (lib::Literal); + std::string primaryTypeComponent (lib::Literal); + std::string sanitisedFullTypeName(lib::Literal); +}// implemented in format-obj.cpp + namespace idi { using lib::HashVal; using std::string; namespace format { // integration helpers... - string demangled_innermost_component (const char* rawName); - string demangled_sanitised_name (const char* rawName); string instance_format (string const& prefix, size_t instanceNr); string instance_hex_format (string const& prefix, size_t instanceNr); @@ -74,12 +79,14 @@ namespace idi { /** Short readable type identifier, not necessarily unique or complete. * @return the innermost component of the demangled C++ type name. * Usually, this is the bare name without any namespaces. + * @note this function is also defined in lib/meta/util.hpp, + * both delegating to the same implementation */ template inline string typeSymbol() { - return format::demangled_innermost_component (typeid(TY).name()); + return lib::meta::primaryTypeComponent (typeid(TY).name()); } /** Complete unique type identifier @@ -91,7 +98,7 @@ namespace idi { inline string typeFullID() { - return format::demangled_sanitised_name (typeid(TY).name()); + return lib::meta::sanitisedFullTypeName (typeid(TY).name()); } template @@ -139,14 +146,13 @@ namespace idi { } /** - * @return a boost hash value, based on the full (mangled) C++ type name + * @return a standard hash value, based on the full (mangled) C++ type name */ template inline HashVal getTypeHash() { - Literal rawTypeName (typeid(TY).name()); - return hash_value (rawTypeName); + return typeid(TY).hash_code(); } diff --git a/src/lib/meta/util.hpp b/src/lib/meta/util.hpp index 0a823dc8e..8bd135120 100644 --- a/src/lib/meta/util.hpp +++ b/src/lib/meta/util.hpp @@ -190,9 +190,31 @@ namespace meta { */ std::string humanReadableTypeID (lib::Literal); + /** extract core name component from a raw type spec + * @return simple identifier possibly "the" type + * @warning implemented lexically, not necessarily correct! + */ + std::string primaryTypeComponent (lib::Literal); + + /** build a sanitised ID from full type name */ + std::string sanitisedFullTypeName(lib::Literal); + + /** reverse the effect of C++ name mangling. + * @return string in language-level form of a C++ type or object name, + * or a string with the original input if demangling fails. + * @warning implementation relies on the cross vendor C++ ABI in use + * by GCC and compatible compilers, so portability is limited. + * The implementation is accessed through libStdC++ + * Name representation in emitted object code and type IDs is + * essentially an implementation detail and subject to change. + */ std::string demangleCxx (lib::Literal rawName); + extern const std::string FAILURE_INDICATOR; + extern const std::string VOID_INDICATOR; + + /** failsafe human readable type display * @return string representing the C++ type. @@ -211,12 +233,12 @@ namespace meta { inline std::string typeStr (TY const* obj =nullptr) noexcept try { - auto mangledType = obj? typeid(obj).name() + auto mangledType = obj? typeid(*obj).name() : typeid(TY).name(); return humanReadableTypeID (mangledType); } catch(...) - { return "↯"; } + { return FAILURE_INDICATOR; } template inline std::string @@ -225,13 +247,44 @@ namespace meta { return typeStr (&ref); } + inline std::string + typeStr (void const*) noexcept + { + return VOID_INDICATOR; + } + + + + + /** simple expressive symbol to designate a type + * @return single word identifier, derived from the + * full type name, not necessarily correct or unique + */ + template + inline std::string + typeSymbol (TY const* obj =nullptr) + { + auto mangledType = obj? typeid(*obj).name() + : typeid(TY).name(); + return primaryTypeComponent (mangledType); + } + + template + inline std::string + typeSymbol (TY const& ref) + { + return typeSymbol (&ref); + } + }}// namespace lib::meta + namespace util { using lib::meta::typeStr; + using lib::meta::FAILURE_INDICATOR; /** failsafe invocation of custom string conversion. @@ -251,7 +304,7 @@ namespace util { static std::string invoke (X const& x) noexcept try { return "«"+typeStr(x)+"»"; } - catch(...) { return "↯"; } + catch(...) { return FAILURE_INDICATOR; } }; template @@ -260,7 +313,7 @@ namespace util { static std::string invoke (X const& val) noexcept try { return std::string(val); } - catch(...) { return "↯"; } + catch(...) { return FAILURE_INDICATOR; } }; // NOTE: this is meant to be extensible; diff --git a/src/lib/p.hpp b/src/lib/p.hpp index 1858f8d4c..aed836011 100644 --- a/src/lib/p.hpp +++ b/src/lib/p.hpp @@ -160,10 +160,10 @@ namespace lib { if (BASE::get()) return util::StringConv::invoke (this->operator*()); else - return "⟂ P<"+meta::typeStr(this->get())+">"; + return "⟂ P<"+meta::typeStr()+">"; } catch(...) - { return "↯"; } + { return meta::FAILURE_INDICATOR; } diff --git a/src/lib/simple-allocator.hpp b/src/lib/simple-allocator.hpp index b05911b7a..6e3d3b3a1 100644 --- a/src/lib/simple-allocator.hpp +++ b/src/lib/simple-allocator.hpp @@ -49,7 +49,7 @@ #include "lib/error.hpp" #include "lib/meta/generator.hpp" #include "lib/meta/typelist-util.hpp" -#include "lib/format-util.hpp" +#include "lib/meta/util.hpp" #include "lib/typed-counter.hpp" #include "include/logging.h" @@ -151,7 +151,7 @@ namespace lib { XX * allocateSlot () { - TRACE (memory, "allocate %s", util::tyStr().c_str()); + TRACE (memory, "allocate «%s»", util::typeStr().c_str()); XX * newStorage = CustomAllocator::allocate (1); COUNTER::template incrementCount(); return newStorage; @@ -161,7 +161,7 @@ namespace lib { void releaseSlot (XX* entry) { - TRACE (memory, "release %s", util::tyStr().c_str()); + TRACE (memory, "release «%s»", util::typeStr().c_str()); CustomAllocator::deallocate (entry, 1); COUNTER::template decrementCount(); } @@ -278,8 +278,8 @@ namespace lib { catch(...) { lumiera_err errorID = lumiera_error(); - WARN (common_dbg, "dtor of %s failed: %s", util::tyStr(entry).c_str() - , errorID ); + WARN (common_dbg, "dtor of «%s» failed: %s", util::typeStr(entry).c_str() + , errorID ); } releaseSlot (entry); } diff --git a/src/lib/test/suite.cpp b/src/lib/test/suite.cpp index 32b121daf..44283aec3 100644 --- a/src/lib/test/suite.cpp +++ b/src/lib/test/suite.cpp @@ -24,7 +24,7 @@ #include "include/logging.h" #include "lib/hash-standard.hpp" -#include "lib/test/test-helper.hpp" +#include "lib/format-cout.hpp" #include "lib/test/suite.hpp" #include "lib/test/run.hpp" #include "lib/cmdline.hpp" @@ -33,8 +33,8 @@ #include #include -#include #include +#include #include #include #include @@ -43,9 +43,6 @@ namespace test { using std::map; - using std::cout; - using std::cerr; - using std::endl; using std::vector; using std::shared_ptr; using boost::algorithm::trim; @@ -53,8 +50,7 @@ namespace test { using util::cStr; using util::isnil; using util::contains; - using lib::test::showType; - using lib::meta::demangleCxx; + using util::typeStr; typedef map TestMap; typedef shared_ptr PTestMap; @@ -176,14 +172,14 @@ namespace test { { try { - INFO (test, "++------------------- invoking TEST: %s", cStr(demangleCxx(showType(theTest)))); + INFO (test, "++------------------- invoking TEST: %s", cStr(typeStr (theTest))); theTest.run (cmdline); return Suite::TEST_OK; } catch (lumiera::Error& failure) { lumiera_err errorID = lumiera_error(); // reset error flag - cerr << "*** Test Failure " << demangleCxx(showType(theTest)) << endl; + cerr << "*** Test Failure " << theTest << endl; cerr << "*** : " << failure.what() << endl; ERROR (test, "Error state %s", errorID); WARN (progress, "Caught exception %s", failure.what()); diff --git a/src/lib/test/test-helper.cpp b/src/lib/test/test-helper.cpp index fc1eaaaa5..52f0fbbfa 100644 --- a/src/lib/test/test-helper.cpp +++ b/src/lib/test/test-helper.cpp @@ -37,6 +37,7 @@ #include +using util::_Fmt; using std::string; namespace lib { @@ -44,10 +45,10 @@ namespace test{ string - showSizeof (size_t siz, const char* name) + showSizeof (size_t siz, string name) { - static util::_Fmt fmt ("sizeof( %s ) %|30t|= %3d"); - return string (fmt % (name? name:"?") % siz); + static _Fmt fmt{"sizeof( %s ) %|30t|= %3d"}; + return fmt % name % siz; } diff --git a/src/lib/test/test-helper.hpp b/src/lib/test/test-helper.hpp index 91e95def8..483076019 100644 --- a/src/lib/test/test-helper.hpp +++ b/src/lib/test/test-helper.hpp @@ -23,10 +23,10 @@ /** @file test-helper.hpp ** A collection of frequently used helper functions to support unit testing. - ** Mostly, these are diagnostics helpers to produce readable output, especially - ** for types. Some of these support meta programming to figure out the \em actual + ** Some are test data generators, some are diagnostics helpers to produce readable + ** output. Some of these support meta programming to figure out the \em actual ** reference kind (value, lvalue, rvalue) of a template parameter instantiation. - ** For GNU compatible compilers, we provide here also an interface to the internal + ** For GNU compatible compilers, we expose also the interface to the internal ** ABI for [demangling type names](\ref demangleCxx). ** ** @note this header is included into a large number of tests. @@ -61,84 +61,36 @@ namespace test{ - /** get a sensible display for a type or object - * @param obj object of the type in question - * @param name optional name to be used literally - * @return either the literal name without any further magic, - * or the result of compile-time or run time - * type identification as implemented by the compiler. - * @deprecated 1/2016 to be replaced by lib::typeString (from \ref format-obj.hpp= - */ - template - inline Literal - showType (T const& obj, Literal name=0) - { - return name? name : Literal(typeid(obj).name()); - } - - /** get a sensible display for a type - * @param name optional name to be used literally - * @return either the literal name without any further magic, - * or the result of compile-time or run time - * type identification as implemented by the compiler. - * @deprecated 1/2016 to be replaced by lib::typeString (from \ref format-obj.hpp= - */ - template - inline Literal - showType (Literal name=0) - { - return name? name : Literal(typeid(T).name()); - } - - - - /** short yet distinct name identifying the given type. - * @return demangled type-id without any scopes. */ - template - string - tyAbbr() - { - string typeStr = demangleCxx (showType()); - size_t pos = typeStr.rfind("::"); - if (pos != string::npos) - typeStr = typeStr.substr(pos+2); - return typeStr; - } - - template - string - tyAbbr(TY&&) - { - return tyAbbr(); - } - /** for printing sizeof(). * prints the given size and name literally, without any further magic */ string - showSizeof (size_t siz, const char* name); + showSizeof (size_t siz, string name); - /** for printing sizeof(), trying to figure out the type name automatically */ + /** for printing sizeof(), possibly figuring out the type name automatically + * @param name when given, this name will be used for display, + * instead of auto detecting the type + */ template inline string - showSizeof(const char* name=0) + showSizeof (T const* obj =0, const char* name =0) { - return showSizeof (sizeof (T), showType (name)); + return showSizeof (obj? sizeof(*obj) : sizeof(T), + name? name : util::typeStr(obj)); } template inline string - showSizeof(T const& obj, const char* name=0) + showSizeof (T const& obj, const char* name=0) { - return showSizeof (sizeof (obj), showType (obj,name)); + return showSizeof (&obj, name); } template inline string - showSizeof(T *obj, const char* name=0) + showSizeof (const char* name) { - return obj? showSizeof (*obj, name) - : showSizeof (name); + return showSizeof (nullptr, name); } @@ -173,7 +125,7 @@ namespace test{ { return " :---#" + boost::lexical_cast(1 + sizeof...(xs)) - + " -- Type: " + showType() + + " -- Type: " + util::typeStr(x) + " " + showRefKind() + " Address* " + boost::lexical_cast(&x) + "\n" diff --git a/src/lib/typed-allocation-manager.hpp b/src/lib/typed-allocation-manager.hpp index 1c8ddcb93..a9b2c6f18 100644 --- a/src/lib/typed-allocation-manager.hpp +++ b/src/lib/typed-allocation-manager.hpp @@ -67,7 +67,7 @@ #define LIB_TYPED_ALLOCATION_MANAGER_H #include "lib/error.hpp" -#include "lib/format-util.hpp" +#include "lib/meta/util.hpp" #include "lib/typed-counter.hpp" #include "include/logging.h" @@ -265,7 +265,7 @@ namespace lib { allocateSlot () { ////////////////////////////////////////////////TICKET #231 :redirect to the corresponding pool allocator - TRACE (memory, "allocate %s", util::tyStr().c_str()); + TRACE (memory, "allocate «%s»", util::typeStr().c_str()); void* space = new char[sizeof(XX)]; allocCnt_.inc(); return Slot (this, space); @@ -276,7 +276,7 @@ namespace lib { releaseSlot (void* entry) { ////////////////////////////////////////////////TICKET #231 :redirect to the corresponding pool allocator - TRACE (memory, "release %s", util::tyStr().c_str()); + TRACE (memory, "release «%s»", util::typeStr().c_str()); typedef char Storage[sizeof(XX)]; delete[] reinterpret_cast (entry); allocCnt_.dec(); @@ -296,8 +296,8 @@ namespace lib { catch(...) { lumiera_err errorID = lumiera_error(); - WARN (command_dbg, "dtor of %s failed: %s", util::tyStr(entry).c_str() - , errorID ); + WARN (command_dbg, "dtor of «%s» failed: %s", util::typeStr(entry).c_str() + , errorID ); } releaseSlot (entry); } diff --git a/src/lib/util.cpp b/src/lib/util.cpp index 95fb59791..93dd48103 100644 --- a/src/lib/util.cpp +++ b/src/lib/util.cpp @@ -46,7 +46,7 @@ namespace util { string - sanitise (const string& org) + sanitise (string const& org) { string res (trim_right_copy_if(org, !isValid )); string::iterator j = res.begin(); diff --git a/src/lib/variant.hpp b/src/lib/variant.hpp index 6c7db32ae..75c57b1d6 100644 --- a/src/lib/variant.hpp +++ b/src/lib/variant.hpp @@ -83,6 +83,7 @@ #include "lib/meta/typelist-util.hpp" #include "lib/meta/generator.hpp" #include "lib/meta/virtual-copy-support.hpp" +#include "lib/format-obj.hpp" #include "lib/util.hpp" #include @@ -497,13 +498,7 @@ namespace lib { template Variant::Buff::operator string() const { -#ifndef LIB_FORMAT_UTIL_H - return string("-?-")+typeid(TY).name()+"-?-"; -#else - return util::str (this->access(), - (util::tyStr()+"|").c_str()) -#endif - ; + return util::typedString (this->access()); } diff --git a/src/proc/mobject/placement.cpp b/src/proc/mobject/placement.cpp index e20efa4dc..6b9cabfa8 100644 --- a/src/proc/mobject/placement.cpp +++ b/src/proc/mobject/placement.cpp @@ -29,6 +29,7 @@ #include using util::_Fmt; +using lib::meta::typeStr; namespace proc { namespace mobject { @@ -51,7 +52,7 @@ namespace mobject { Placement::operator string () const { return _Fmt{"Placement<%s> %|50T.| use-cnt=%u ID(%x) adr=%p pointee=%p"} - % typeid(*get()).name() % use_count() + % typeStr(this->get()) % use_count() % (size_t)getID() % (void*)this % (void*)get() diff --git a/tests/00support.tests b/tests/00support.tests index 81a663368..d8ae934a4 100644 --- a/tests/00support.tests +++ b/tests/00support.tests @@ -5,12 +5,12 @@ TESTING "Test support and helpers" ./test-suite --group=common TEST "Test support functions" TestHelper_test < #include -using lib::test::showType; using boost::lexical_cast; +using util::typeStr; using util::isnil; using std::string; @@ -414,8 +414,8 @@ namespace test{ void performTestSequence(TimeValue const& org, TimeValue const& c) { - cout << "Test-Case. Target=" << showType() - << "\t <--feed--- " << showType() + cout << "Test-Case. Target=" << typeStr() + << "\t <--feed--- " << typeStr() << endl; // test subject diff --git a/tests/library/dependency-factory-test.cpp b/tests/library/dependency-factory-test.cpp index cc99532ef..95ed39890 100644 --- a/tests/library/dependency-factory-test.cpp +++ b/tests/library/dependency-factory-test.cpp @@ -23,7 +23,7 @@ #include "lib/test/run.hpp" -#include "lib/test/test-helper.hpp" +#include "lib/format-obj.hpp" #include "lib/util.hpp" #include "lib/depend.hpp" @@ -57,7 +57,7 @@ namespace test{ virtual operator string() const { - return showType(*this) + return util::typeStr(this) + TestTargetObj::operator string(); } }; diff --git a/tests/library/diff/generic-tree-mutator-test.cpp b/tests/library/diff/generic-tree-mutator-test.cpp index fec2b805f..251b682d8 100644 --- a/tests/library/diff/generic-tree-mutator-test.cpp +++ b/tests/library/diff/generic-tree-mutator-test.cpp @@ -37,8 +37,7 @@ using std::string; //using std::vector; //using std::swap; -using lib::test::showType; -using lib::meta::demangleCxx; +using util::typeStr; namespace lib { @@ -96,7 +95,7 @@ namespace test{ }); cout << "concrete TreeMutator size=" << sizeof(mutator) - << " type="<< demangleCxx (showType (mutator)) + << " type="<< typeStr(mutator) << endl; CHECK (isnil (localData)); diff --git a/tests/library/iter-adapter-stl-test.cpp b/tests/library/iter-adapter-stl-test.cpp index 980e72d1a..9ee927efa 100644 --- a/tests/library/iter-adapter-stl-test.cpp +++ b/tests/library/iter-adapter-stl-test.cpp @@ -23,7 +23,6 @@ #include "lib/test/run.hpp" -#include "lib/test/test-helper.hpp" #include "lib/test/test-coll.hpp" #include "lib/format-cout.hpp" #include "lib/util.hpp" @@ -54,7 +53,7 @@ namespace test{ /** print descriptive separator to STDOUT */ #define PRINT_FUNC(_F_NAME_, _F_TYPE_) \ - cout << "-----"<() << endl; + cout << "-----"<() << endl; namespace { diff --git a/tests/library/meta/access-casted-test.cpp b/tests/library/meta/access-casted-test.cpp index 5e791114d..9381ed9a4 100644 --- a/tests/library/meta/access-casted-test.cpp +++ b/tests/library/meta/access-casted-test.cpp @@ -69,7 +69,6 @@ namespace test { , E { }; - using lib::test::tyAbbr; ostream& operator<< (ostream& s, const B& b) { return s << "B{} adr="<<&b; } ostream& operator<< (ostream& s, const D& d) { return s << "D{} adr="<<&d; } diff --git a/tests/library/meta/virtual-copy-support-test.cpp b/tests/library/meta/virtual-copy-support-test.cpp index d3a644588..eda331d68 100644 --- a/tests/library/meta/virtual-copy-support-test.cpp +++ b/tests/library/meta/virtual-copy-support-test.cpp @@ -47,17 +47,10 @@ namespace test { namespace { // Test fixture... - class Interface; - - /** helper: shortened type display */ - string - typeID(Interface const& obj) - { - return lib::test::tyAbbr(obj); - } - int _CheckSum_ = 0; + class Interface; + /** Interface for the Virtual copy operations. * @remarks we define this explicitly here for the tests solely. @@ -116,7 +109,7 @@ namespace test { virtual operator string() const override { return _Fmt("Sub|%s|%d|-%s") - % typeID(*this) + % util::typeStr(this) % i % access(); } diff --git a/tests/library/symbol-test.cpp b/tests/library/symbol-test.cpp index 46a2295f0..62bbb1ea6 100644 --- a/tests/library/symbol-test.cpp +++ b/tests/library/symbol-test.cpp @@ -22,18 +22,18 @@ #include "lib/test/run.hpp" -#include "lib/util.hpp" #include "lib/test/test-helper.hpp" +#include "lib/format-cout.hpp" +#include "lib/util.hpp" #include "lib/symbol.hpp" +#include -#include - -using std::cout; -using std::endl; -using util::isnil; +using util::typeStr; using util::isSameObject; +using util::isnil; +using std::string; @@ -76,8 +76,8 @@ namespace test{ CHECK (li2 != li3); CHECK (li3 != li2); - cout << showType(li1 + string("ce")) << endl; - cout << showType(string("minus " +li1)) << endl; + cout << typeStr (li1 + string("ce")) << endl; + cout << typeStr (string("minus " +li1)) << endl; cout << li2+string("..") << string("..")+li2 << endl; CHECK (hash_value(li1) == hash_value(li2)); diff --git a/tests/library/test/test-helper-demangling-test.cpp b/tests/library/test/test-helper-demangling-test.cpp index 6bee8c2a3..00b56a5e9 100644 --- a/tests/library/test/test-helper-demangling-test.cpp +++ b/tests/library/test/test-helper-demangling-test.cpp @@ -69,9 +69,10 @@ namespace test{ { Outer ship; auto magic = &ship.phantom; + auto rawType = typeid(magic).name(); - cout << showType(magic) << endl; - cout << demangleCxx(showType(magic)) << endl; + cout << rawType << endl; + cout << demangleCxx(rawType) << endl; } }; diff --git a/tests/library/test/test-helper-test.cpp b/tests/library/test/test-helper-test.cpp index 61aefa304..5bec0bee4 100644 --- a/tests/library/test/test-helper-test.cpp +++ b/tests/library/test/test-helper-test.cpp @@ -94,12 +94,13 @@ namespace test{ CHECK (2 == sizeof (rmpf2)); CHECK (3 == sizeof (rmpf3)); - cout << showSizeof((size_t)42, "theUniverse") << endl; - cout << showSizeof("just a char") << endl; - cout << showSizeof(murpf) << endl; - cout << showSizeof(rmpf1) << endl; - cout << showSizeof(rmpf2) << endl; - cout << showSizeof() << endl; + cout << showSizeof("just a char") << endl; + cout << showSizeof(murpf) << endl; + cout << showSizeof(rmpf1) << endl; + cout << showSizeof(rmpf2) << endl; + cout << showSizeof() << endl; + cout << showSizeof(size_t(24), + string{"everything"}) << endl; Wrmpf1 *p1 = &rmpf1; Wrmpf1 *p2 = 0; diff --git a/tests/library/util-floorwrap-test.cpp b/tests/library/util-floorwrap-test.cpp index 20e6e2908..e0eee28f1 100644 --- a/tests/library/util-floorwrap-test.cpp +++ b/tests/library/util-floorwrap-test.cpp @@ -32,7 +32,7 @@ using ::Test; using boost::lexical_cast; -using lib::test::showType; +using util::typeStr; using util::floorwrap; @@ -74,7 +74,7 @@ namespace test { void checkWrap (I range, I scale) { - cout << "--------"<< showType() + cout << "--------"<< typeStr() << "--------"<< range<<"/"<=-range; --i) showWrap (i, scale);