www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Finding out names in shared libraries

reply Ozan <ozan.sueel gmail.com> writes:
Hi


If I want to use a class or a function in a shared library, it is 
necessary to use funny names like 
"D7myclass10getMyClassFZC7myclass7MyClass".

Is it possible to get a list of all the names in shared library? 
What is the schema behind these names? Is there a listing for 
"D7", "10", "FZC7", "7" and so on?


Regards, Ozan
Mar 23 2016
next sibling parent Ozan <ozan.sueel gmail.com> writes:
On Wednesday, 23 March 2016 at 15:17:18 UTC, Ozan wrote:
 If I want to use a class or a function in a shared library, it 
 is necessary to use funny names like 
 "D7myclass10getMyClassFZC7myclass7MyClass".

 Is it possible to get a list of all the names in shared 
 library? What is the schema behind these names? Is there a 
 listing for "D7", "10", "FZC7", "7" and so on?
Solved in the core.demangle module... The demangle module converts mangled D symbols to a representation similar to what would have existed in code. Regards, Ozan
Mar 23 2016
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2016-03-23 16:17, Ozan wrote:
 Hi


 If I want to use a class or a function in a shared library, it is
 necessary to use funny names like
 "D7myclass10getMyClassFZC7myclass7MyClass".

 Is it possible to get a list of all the names in shared library? What is
 the schema behind these names? Is there a listing for "D7", "10",
 "FZC7", "7" and so on?
Not exactly sure what you need. But it's possible to get all classes at runtime like this [1]. For functions, there's really no pretty way to do that. You can either implement runtime reflection using compile time reflection, which will most likely require you to modify the code you want to inspect. Or you can inspect the symbol table in the binary/shared library, which is a bit complicated and platform dependent. [1] https://github.com/D-Programming-Language/druntime/blob/master/src/object.d#L973 -- /Jacob Carlborg
Mar 23 2016