[core] Detach demangle() from type_info
Hi Peter, I can see you already extracted demangle() to boost/core. Great, thanks! However I'd prefer it to be detached from type_info. This tool would be useful with different kinds of symbols, like function and variable names, not just type_info. So it better accept a string as an argument and not type_info. demangled_name() should probably be in core/typeinfo.hpp. And regarding typeinfo.hpp. Aren't we duplicating Boost.TypeIndex here? PS: I was also planning to create pull requests to other libraries to use demangle from Core. These are Exception, Units, TypeIndex and Log, AFAIK. Do you plan to do this? If not, I could.
Andrey Semashev wrote:
Hi Peter,
I can see you already extracted demangle() to boost/core. Great, thanks!
However I'd prefer it to be detached from type_info. This tool would be useful with different kinds of symbols, like function and variable names, not just type_info. So it better accept a string as an argument and not type_info. demangled_name() should probably be in core/typeinfo.hpp.
'demangle' does accept a string as the argument - it's just in core::detail. demangled_name, which is typeinfo-specific, needs to forego demangling when RTTI is off, because then core::typeinfo returns an already demangled sort-of name using __PRETTY_FUNCTION__. We can lift demangle() to core:: if you like. I wasn't sure about that so I left it in detail.
And regarding typeinfo.hpp. Aren't we duplicating Boost.TypeIndex here?
Maybe. I use typeinfo.hpp in lightweight_test_trait.hpp though, and the less dependencies a test header has, the better, because a compile error in a dependency causes all the tests in the world to fail. Which is undesirable. (That's also why I split the _trait part from lightweight_test.) Plus, typeinfo.hpp was already present, as detail/sp_typeinfo.hpp, I just renamed it.
PS: I was also planning to create pull requests to other libraries to use demangle from Core. These are Exception, Units, TypeIndex and Log, AFAIK. Do you plan to do this? If not, I could.
Do go ahead with these, once we sort out the namespace question.
On Friday 06 June 2014 22:56:41 Peter Dimov wrote:
Andrey Semashev wrote:
Hi Peter,
I can see you already extracted demangle() to boost/core. Great, thanks!
However I'd prefer it to be detached from type_info. This tool would be useful with different kinds of symbols, like function and variable names, not just type_info. So it better accept a string as an argument and not type_info. demangled_name() should probably be in core/typeinfo.hpp.
'demangle' does accept a string as the argument - it's just in core::detail.
demangled_name, which is typeinfo-specific, needs to forego demangling when RTTI is off, because then core::typeinfo returns an already demangled sort-of name using __PRETTY_FUNCTION__.
We can lift demangle() to core:: if you like. I wasn't sure about that so I left it in detail.
Yes, please. I would also appreciate if using demangle() would not impose a
dependency on typeinfo.hpp. That would mean one of:
1. Move demangled_name() to typeinfo.hpp. Rename demangled_name.hpp to
demangle.hpp. Include demangle.hpp in typeinfo.hpp and remove #include
And regarding typeinfo.hpp. Aren't we duplicating Boost.TypeIndex here?
Maybe. I use typeinfo.hpp in lightweight_test_trait.hpp though, and the less dependencies a test header has, the better, because a compile error in a dependency causes all the tests in the world to fail. Which is undesirable. (That's also why I split the _trait part from lightweight_test.)
Plus, typeinfo.hpp was already present, as detail/sp_typeinfo.hpp, I just renamed it.
Ok, I see.
2014-06-06 23:56 GMT+04:00 Peter Dimov
Andrey Semashev wrote:
And regarding typeinfo.hpp. Aren't we duplicating Boost.TypeIndex here?
Maybe. I use typeinfo.hpp in lightweight_test_trait.hpp though, and the less dependencies a test header has, the better, because a compile error in a dependency causes all the tests in the world to fail. Which is undesirable. (That's also why I split the _trait part from lightweight_test.)
Plus, typeinfo.hpp was already present, as detail/sp_typeinfo.hpp, I just renamed it.
I've planed TypeIndex to be a fixed version of detail/sp_typeinfo.hpp (workarounds for compilers, names demangling, hashing ...). Currently TypeIndex is on level 8 because of the dependency to functiona/hash_fwd.hpp (it's sad). After this release of Boost I was planning to push patches to different submodules and fix the usage of typeids all around the Boost using the TypeIndex library (of course after dropping the dependency to Functional somehow). However I'd prefer it to be detached from type_info. This tool would be
useful with different kinds of symbols, like function and variable names, not just type_info. So it better accept a string as an argument and not type_info. demangled_name() should probably be in core/typeinfo.hpp.
Do not move it into the typeinfo.hpp. This file will be deprecated or replaced with TypeIndex soon. It's better to keep it separate. -- Best regards, Antony Polukhin
On Saturday 07 June 2014 00:29:57 Antony Polukhin wrote:
2014-06-06 23:56 GMT+04:00 Peter Dimov
: Andrey Semashev wrote:
However I'd prefer it to be detached from type_info. This tool would be
useful with different kinds of symbols, like function and variable names, not just type_info. So it better accept a string as an argument and not type_info. demangled_name() should probably be in core/typeinfo.hpp.
Do not move it into the typeinfo.hpp. This file will be deprecated or replaced with TypeIndex soon. It's better to keep it separate.
demangled_name() is just a helper function that forwards core::typeinfo::name() to demangle(). In case if core::typeinfo is replaced with Boost.TypeIndex then there's no use for it. demangle(), on the other hand, can be useful without it, and it should stay.
participants (3)
-
Andrey Semashev
-
Antony Polukhin
-
Peter Dimov