mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-03 21:44:33 +00:00 
			
		
		
		
	Hadrons: type names are demangled
This commit is contained in:
		@@ -250,7 +250,7 @@ std::string Environment::getModuleType(const unsigned int address) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasModule(address))
 | 
			
		||||
    {
 | 
			
		||||
        return module_[address].type->name();
 | 
			
		||||
        return typeName(module_[address].type);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
@@ -473,7 +473,7 @@ std::string Environment::getObjectType(const unsigned int address) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasRegisteredObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        return object_[address].type->name();
 | 
			
		||||
        return typeName(object_[address].type);
 | 
			
		||||
    }
 | 
			
		||||
    else if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
@@ -689,8 +689,7 @@ void Environment::printContent(void)
 | 
			
		||||
    for (unsigned int i = 0; i < module_.size(); ++i)
 | 
			
		||||
    {
 | 
			
		||||
        LOG(Message) << std::setw(4) << i << ": "
 | 
			
		||||
                     << getModuleName(i) << " ("
 | 
			
		||||
                     << getModuleType(i) << ")" << std::endl;
 | 
			
		||||
                     << getModuleName(i) << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
    LOG(Message) << "Objects: " << std::endl;
 | 
			
		||||
    for (unsigned int i = 0; i < object_.size(); ++i)
 | 
			
		||||
 
 | 
			
		||||
@@ -63,3 +63,18 @@ std::string Hadrons::sizeString(long unsigned int bytes)
 | 
			
		||||
    
 | 
			
		||||
    return std::string(buf);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// type utilities //////////////////////////////////////////////////////////////
 | 
			
		||||
constexpr unsigned int maxNameSize = 1024u;
 | 
			
		||||
 | 
			
		||||
std::string Hadrons::typeName(const std::type_info *info)
 | 
			
		||||
{
 | 
			
		||||
    char        *buf;
 | 
			
		||||
    std::string name;
 | 
			
		||||
    
 | 
			
		||||
    buf  = abi::__cxa_demangle(info->name(), nullptr, nullptr, nullptr);
 | 
			
		||||
    name = buf;
 | 
			
		||||
    free(buf);
 | 
			
		||||
    
 | 
			
		||||
    return name;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -31,6 +31,7 @@ directory.
 | 
			
		||||
#include <set>
 | 
			
		||||
#include <stack>
 | 
			
		||||
#include <Grid/Grid.h>
 | 
			
		||||
#include <cxxabi.h>
 | 
			
		||||
 | 
			
		||||
#define BEGIN_HADRONS_NAMESPACE \
 | 
			
		||||
namespace Grid {\
 | 
			
		||||
@@ -56,11 +57,6 @@ using Grid::operator<<;
 | 
			
		||||
BEGIN_HADRONS_NAMESPACE
 | 
			
		||||
 | 
			
		||||
// type aliases
 | 
			
		||||
//typedef FermionOperator<FIMPL> FMat;
 | 
			
		||||
//typedef FIMPL::FermionField    FermionField;
 | 
			
		||||
//typedef FIMPL::PropagatorField PropagatorField;
 | 
			
		||||
//typedef std::function<void(FermionField &, const FermionField &)> SolverFn;
 | 
			
		||||
 | 
			
		||||
#define TYPE_ALIASES(FImpl, suffix)\
 | 
			
		||||
typedef FermionOperator<FImpl>                       FMat##suffix;             \
 | 
			
		||||
typedef typename FImpl::FermionField                 FermionField##suffix;     \
 | 
			
		||||
@@ -120,34 +116,33 @@ private:\
 | 
			
		||||
// pretty size formating
 | 
			
		||||
std::string sizeString(long unsigned int bytes);
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
std::string typeName(const T &x)
 | 
			
		||||
{
 | 
			
		||||
    std::string name(typeid(x).name());
 | 
			
		||||
 | 
			
		||||
    return name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
std::string typeName(void)
 | 
			
		||||
{
 | 
			
		||||
    std::string name(typeid(T).name());
 | 
			
		||||
 | 
			
		||||
    return name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// type utilities
 | 
			
		||||
template <typename T>
 | 
			
		||||
const std::type_info * typeIdPt(const T &x)
 | 
			
		||||
{
 | 
			
		||||
    return &typeid(x);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::string typeName(const std::type_info *info);
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
const std::type_info * typeName(void)
 | 
			
		||||
const std::type_info * typeIdPt(void)
 | 
			
		||||
{
 | 
			
		||||
    return &typeid(T);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
std::string typeName(const T &x)
 | 
			
		||||
{
 | 
			
		||||
    return typeName(typeIdPt(x));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
std::string typeName(void)
 | 
			
		||||
{
 | 
			
		||||
    return typeName(typeIdPt<T>());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
END_HADRONS_NAMESPACE
 | 
			
		||||
 | 
			
		||||
#endif // Hadrons_Global_hpp_
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user