clean-up(#985): unify various type-indicating helpers

over time, we got quite a jungle with all those
shome-me-the-type-of helper functions.

Reduced and unified all those into
- typeString : a human readable, slightly simplified full type
- typeSymbol : a single word identifier, extracted lexically from the type

note: this changeset causes a lot of tests to break,
since we're using unmangeled type-IDs pretty much everywhere now.
Beore fixing those, I'll have to implement a better simplification
scheme for the "human readable" type names....
This commit is contained in:
Fischlurch 2016-01-08 08:20:59 +01:00
parent 99c478768c
commit 615f112f5c
30 changed files with 218 additions and 218 deletions

View file

@ -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<FA>
, 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<FA>(interfaceName_for_Log))
: displayName_(interfaceName_for_Log? string(interfaceName_for_Log)
: util::typeStr<FA>())
{
__checkLifecycle();
Accessor<FA>::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<FA>::implProxy_ = 0;
}
};

View file

@ -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 <cxxabi.h>
@ -55,6 +56,8 @@
#include <string>
//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; }

View file

@ -42,10 +42,10 @@
#ifndef LIB_FORMAT_OBJ_H
#define LIB_FORMAT_OBJ_H
#include <string>
#include "lib/meta/trait.hpp"
#include <boost/lexical_cast.hpp>
#include <string>
namespace std { // forward declaration to avoid including <iostream>
@ -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<std::string> (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<typename TY>
inline std::string
typedString (TY const& val) noexcept
try {
std::string repr = StringConv<TY>::invoke (val);
return 0 == repr.rfind("«", 0)? repr
: "«"+typeStr(val)+"»|"+repr;
}
catch(...)
{ return FAILURE_INDICATOR; }
} // namespace util
#endif /*LIB_FORMAT_OBJ_H*/

View file

@ -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)
{

View file

@ -359,7 +359,7 @@ namespace util {
static void
dump (const char* cString, Implementation& impl)
{
format (cString? cString : "", impl);
format (cString? cString : FAILURE_INDICATOR, impl);
}
};

View file

@ -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<typename TY>
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<typename TY>
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)+"»";
}

View file

@ -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

View file

@ -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<typename TY>
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<typename TY>
@ -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<typename TY>
inline HashVal
getTypeHash()
{
Literal rawTypeName (typeid(TY).name());
return hash_value (rawTypeName);
return typeid(TY).hash_code();
}

View file

@ -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<typename TY>
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<typename TY>
inline std::string
typeSymbol (TY const* obj =nullptr)
{
auto mangledType = obj? typeid(*obj).name()
: typeid(TY).name();
return primaryTypeComponent (mangledType);
}
template<typename TY>
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<typename X>
@ -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;

View file

@ -160,10 +160,10 @@ namespace lib {
if (BASE::get())
return util::StringConv<TAR>::invoke (this->operator*());
else
return "⟂ P<"+meta::typeStr(this->get())+">";
return "⟂ P<"+meta::typeStr<TAR>()+">";
}
catch(...)
{ return ""; }
{ return meta::FAILURE_INDICATOR; }

View file

@ -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<XX>().c_str());
TRACE (memory, "allocate «%s»", util::typeStr<XX>().c_str());
XX * newStorage = CustomAllocator<XX>::allocate (1);
COUNTER::template incrementCount<XX>();
return newStorage;
@ -161,7 +161,7 @@ namespace lib {
void
releaseSlot (XX* entry)
{
TRACE (memory, "release %s", util::tyStr<XX>().c_str());
TRACE (memory, "release «%s»", util::typeStr<XX>().c_str());
CustomAllocator<XX>::deallocate (entry, 1);
COUNTER::template decrementCount<XX>();
}
@ -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<XX> (entry);
}

View file

@ -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 <boost/algorithm/string.hpp>
#include <memory>
#include <iostream>
#include <sstream>
#include <string>
#include <memory>
#include <vector>
#include <map>
@ -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<string, Launcher*> TestMap;
typedef shared_ptr<TestMap> 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());

View file

@ -37,6 +37,7 @@
#include <string>
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;
}

View file

@ -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<typename T>
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<typename T>
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<typename TY>
string
tyAbbr()
{
string typeStr = demangleCxx (showType<TY>());
size_t pos = typeStr.rfind("::");
if (pos != string::npos)
typeStr = typeStr.substr(pos+2);
return typeStr;
}
template<typename TY>
string
tyAbbr(TY&&)
{
return tyAbbr<TY>();
}
/** 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<typename T>
inline string
showSizeof(const char* name=0)
showSizeof (T const* obj =0, const char* name =0)
{
return showSizeof (sizeof (T), showType<T> (name));
return showSizeof (obj? sizeof(*obj) : sizeof(T),
name? name : util::typeStr(obj));
}
template<typename T>
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<typename T>
inline string
showSizeof(T *obj, const char* name=0)
showSizeof (const char* name)
{
return obj? showSizeof (*obj, name)
: showSizeof<T> (name);
return showSizeof<T> (nullptr, name);
}
@ -173,7 +125,7 @@ namespace test{
{
return " :---#"
+ boost::lexical_cast<string>(1 + sizeof...(xs))
+ " -- Type: " + showType<X>()
+ " -- Type: " + util::typeStr(x)
+ " " + showRefKind<X>()
+ " Address* " + boost::lexical_cast<string>(&x)
+ "\n"

View file

@ -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<XX>().c_str());
TRACE (memory, "allocate «%s»", util::typeStr<XX>().c_str());
void* space = new char[sizeof(XX)];
allocCnt_.inc<XX>();
return Slot<XX> (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<XX>().c_str());
TRACE (memory, "release «%s»", util::typeStr<XX>().c_str());
typedef char Storage[sizeof(XX)];
delete[] reinterpret_cast<Storage*> (entry);
allocCnt_.dec<XX>();
@ -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<XX> (entry);
}

View file

@ -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();

View file

@ -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 <type_traits>
@ -497,13 +498,7 @@ namespace lib {
template<typename TY>
Variant<TYPES>::Buff<TY>::operator string() const
{
#ifndef LIB_FORMAT_UTIL_H
return string("-?-")+typeid(TY).name()+"-?-";
#else
return util::str (this->access(),
(util::tyStr<TY>()+"|").c_str())
#endif
;
return util::typedString (this->access());
}

View file

@ -29,6 +29,7 @@
#include <typeinfo>
using util::_Fmt;
using lib::meta::typeStr;
namespace proc {
namespace mobject {
@ -51,7 +52,7 @@ namespace mobject {
Placement<MObject>::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()

View file

@ -5,12 +5,12 @@ TESTING "Test support and helpers" ./test-suite --group=common
TEST "Test support functions" TestHelper_test <<END
out: [a-z0-9]{80}$
out: Displaying types and sizes....
out: sizeof..theUniverse.+ = 42
out: sizeof..just a char.+ = 1
out: sizeof.+lib.+test.+test.+Murpf.+ = 1
out: sizeof.+lib.+test.+test.+Wrmrmpft.+ = 2
out: sizeof.+lib.+test.+test.+Wrmrmpft.+ = 3
out: sizeof.+lib.+test.+test.+Wrmrmpft.+Murpf.+ = 1
out: sizeof..everything.+ = 42
END

View file

@ -32,7 +32,7 @@
using lumiera::error::LUMIERA_ERROR_ASSERTION;
using util::isSameObject;
using lib::test::showType;
using util::typeStr;
using std::rand;
@ -96,7 +96,7 @@ namespace test{
{
DIX digxel;
CHECK (0 == digxel);
cout << showType(digxel) << "--empty--"<<digxel;
cout << typeStr(digxel) << "--empty--"<<digxel;
digxel = testval;
cout << "--(val="<<testval<<")--"<<digxel;

View file

@ -37,8 +37,8 @@
#include <string>
#include <limits>
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<TAR>()
<< "\t <--feed--- " << showType<SRC>()
cout << "Test-Case. Target=" << typeStr<TAR>()
<< "\t <--feed--- " << typeStr<SRC>()
<< endl;
// test subject

View file

@ -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();
}
};

View file

@ -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));

View file

@ -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 << "-----"<<STRINGIFY(_F_NAME_)<<"---" << showType<_F_TYPE_>() << endl;
cout << "-----"<<STRINGIFY(_F_NAME_)<<"---" << util::typeStr<_F_TYPE_>() << endl;
namespace {

View file

@ -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; }

View file

@ -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();
}

View file

@ -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 <string>
#include <iostream>
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));

View file

@ -69,9 +69,10 @@ namespace test{
{
Outer<Space> 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;
}
};

View file

@ -94,12 +94,13 @@ namespace test{
CHECK (2 == sizeof (rmpf2));
CHECK (3 == sizeof (rmpf3));
cout << showSizeof((size_t)42, "theUniverse") << endl;
cout << showSizeof<char>("just a char") << endl;
cout << showSizeof(murpf) << endl;
cout << showSizeof(rmpf1) << endl;
cout << showSizeof(rmpf2) << endl;
cout << showSizeof<Wrmpf3>() << endl;
cout << showSizeof<char>("just a char") << endl;
cout << showSizeof(murpf) << endl;
cout << showSizeof(rmpf1) << endl;
cout << showSizeof(rmpf2) << endl;
cout << showSizeof<Wrmpf3>() << endl;
cout << showSizeof(size_t(24),
string{"everything"}) << endl;
Wrmpf1 *p1 = &rmpf1;
Wrmpf1 *p2 = 0;

View file

@ -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<I>()
cout << "--------"<< typeStr<I>()
<< "--------"<< range<<"/"<<scale<<endl;
for (I i=range; i >=-range; --i)
showWrap (i, scale);