Rename PBD::symbol_demangle and some variable names to improve readability
Rename PBD::symbol_demangle to demangle_symbol so the transitive verb is infront of the object. Rename some local variables and fix documentation.
This commit is contained in:
parent
5f4f89fb39
commit
36fa670309
@ -24,44 +24,44 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
PBD::symbol_demangle (const std::string& l)
|
PBD::demangle_symbol (const std::string& mangled_symbol)
|
||||||
{
|
{
|
||||||
#if defined(__GLIBCXX__)
|
#if defined(__GLIBCXX__)
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
char* realname = abi::__cxa_demangle (l.c_str(), 0, 0, &status);
|
char* realname = abi::__cxa_demangle (mangled_symbol.c_str(), 0, 0, &status);
|
||||||
std::string d (realname);
|
std::string demangled_symbol (realname);
|
||||||
free (realname);
|
free (realname);
|
||||||
return d;
|
return demangled_symbol;
|
||||||
} catch (std::exception) {
|
} catch (std::exception) {
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return l;
|
return mangled_symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
PBD::demangle (std::string const & l)
|
PBD::demangle (std::string const& str)
|
||||||
{
|
{
|
||||||
std::string::size_type const b = l.find_first_of ("(");
|
std::string::size_type const b = str.find_first_of ("(");
|
||||||
|
|
||||||
if (b == std::string::npos) {
|
if (b == std::string::npos) {
|
||||||
return symbol_demangle (l);
|
return demangle_symbol (str);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string::size_type const p = l.find_last_of ("+");
|
std::string::size_type const p = str.find_last_of ("+");
|
||||||
if (p == std::string::npos) {
|
if (p == std::string::npos) {
|
||||||
return symbol_demangle (l);
|
return demangle_symbol (str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p - b) <= 1) {
|
if ((p - b) <= 1) {
|
||||||
return symbol_demangle (l);
|
return demangle_symbol (str);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const fn = l.substr (b + 1, p - b - 1);
|
std::string const symbol = str.substr (b + 1, p - b - 1);
|
||||||
|
|
||||||
return symbol_demangle (fn);
|
return demangle_symbol (symbol);
|
||||||
}
|
}
|
||||||
|
@ -54,17 +54,17 @@ namespace PBD
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param a mangled symbol/name
|
* @param symbol a mangled symbol/name
|
||||||
* @return a demangled symbol/name
|
* @return a demangled symbol/name
|
||||||
*/
|
*/
|
||||||
LIBPBD_API std::string symbol_demangle(const std::string&);
|
LIBPBD_API std::string demangle_symbol(const std::string& symbol);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param a string containing a mangled symbol/name
|
* @param str a string containing a mangled symbol/name
|
||||||
* @return a string with the mangled symbol/name replaced with a demangled
|
* @return a string with the mangled symbol/name replaced with a demangled
|
||||||
* name
|
* name
|
||||||
*/
|
*/
|
||||||
LIBPBD_API std::string demangle(const std::string&);
|
LIBPBD_API std::string demangle(const std::string& str);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user