mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 05:54:32 +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))
 | 
					    if (hasModule(address))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return module_[address].type->name();
 | 
					        return typeName(module_[address].type);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -473,7 +473,7 @@ std::string Environment::getObjectType(const unsigned int address) const
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    if (hasRegisteredObject(address))
 | 
					    if (hasRegisteredObject(address))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return object_[address].type->name();
 | 
					        return typeName(object_[address].type);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if (hasObject(address))
 | 
					    else if (hasObject(address))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -689,8 +689,7 @@ void Environment::printContent(void)
 | 
				
			|||||||
    for (unsigned int i = 0; i < module_.size(); ++i)
 | 
					    for (unsigned int i = 0; i < module_.size(); ++i)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        LOG(Message) << std::setw(4) << i << ": "
 | 
					        LOG(Message) << std::setw(4) << i << ": "
 | 
				
			||||||
                     << getModuleName(i) << " ("
 | 
					                     << getModuleName(i) << std::endl;
 | 
				
			||||||
                     << getModuleType(i) << ")" << std::endl;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    LOG(Message) << "Objects: " << std::endl;
 | 
					    LOG(Message) << "Objects: " << std::endl;
 | 
				
			||||||
    for (unsigned int i = 0; i < object_.size(); ++i)
 | 
					    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);
 | 
					    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 <set>
 | 
				
			||||||
#include <stack>
 | 
					#include <stack>
 | 
				
			||||||
#include <Grid/Grid.h>
 | 
					#include <Grid/Grid.h>
 | 
				
			||||||
 | 
					#include <cxxabi.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define BEGIN_HADRONS_NAMESPACE \
 | 
					#define BEGIN_HADRONS_NAMESPACE \
 | 
				
			||||||
namespace Grid {\
 | 
					namespace Grid {\
 | 
				
			||||||
@@ -56,11 +57,6 @@ using Grid::operator<<;
 | 
				
			|||||||
BEGIN_HADRONS_NAMESPACE
 | 
					BEGIN_HADRONS_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// type aliases
 | 
					// 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)\
 | 
					#define TYPE_ALIASES(FImpl, suffix)\
 | 
				
			||||||
typedef FermionOperator<FImpl>                       FMat##suffix;             \
 | 
					typedef FermionOperator<FImpl>                       FMat##suffix;             \
 | 
				
			||||||
typedef typename FImpl::FermionField                 FermionField##suffix;     \
 | 
					typedef typename FImpl::FermionField                 FermionField##suffix;     \
 | 
				
			||||||
@@ -120,34 +116,33 @@ private:\
 | 
				
			|||||||
// pretty size formating
 | 
					// pretty size formating
 | 
				
			||||||
std::string sizeString(long unsigned int bytes);
 | 
					std::string sizeString(long unsigned int bytes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <typename T>
 | 
					// type utilities
 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <typename T>
 | 
					template <typename T>
 | 
				
			||||||
const std::type_info * typeIdPt(const T &x)
 | 
					const std::type_info * typeIdPt(const T &x)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return &typeid(x);
 | 
					    return &typeid(x);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::string typeName(const std::type_info *info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <typename T>
 | 
					template <typename T>
 | 
				
			||||||
const std::type_info * typeName(void)
 | 
					const std::type_info * typeIdPt(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return &typeid(T);
 | 
					    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
 | 
					END_HADRONS_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // Hadrons_Global_hpp_
 | 
					#endif // Hadrons_Global_hpp_
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user