Can we extract informatin by providing assembly or Exe PDB?

Hello,
If I need to extract information like (Class,functions their types) and every thing that PDB contains. Can I provide Reflex some EXE or PDB and then can extract all info wotever I required.

I dont want to take advatange of Reflex as provising it static code and in same Exe I ther’s code which parse that code and take extract every info which I required.

I have one assembly(Exe,PDB or DLL) of which I need to parse(extract every info such as function,classes, in/out parameters of functions) I should call such a function of Reflex which will take assembly(PDB,EXE or DLL )as parameter and should give every thing which’s contained in it.

Regards
Usman

Hi Usman,

Sorry, but ROOT doesn’t provide such kind of tool…

Cheers, Bertrand.

[quote=“bellenot”]Hi Usman,

Sorry, but ROOT doesn’t provide such kind of tool…

Cheers, Bertrand.[/quote]

So What kind of reflection it just provide…? In .NET you always provide assembly or Exe or something like that and then you expect something to take from that hidden code(from assembly) info. like how much function that assembly contains? what type of classes and function it has and what type of parameter those functions take.

I dont think any use of reflection for static code which you always need to write FIRST and then provide u’r driver programe to extract info from that CODE(which’s also that part of that Exe)is a good way to have.

Hi,

We indeed would also prefer to not have to rely on instrumenting the library, however due to the way the C++ standard is designed (to reduce at much as possible the amount of ‘waste’ in an executable and never ‘pay’ for something you do not use), an optimized library or executed do not have all the necessary information to extract proper reflection information. (It might be plausible in case of debug library but this is not the general case).

So we need a helper utility (rootcint or genreflex) to produce this information. Note that the only input really required are the header file defining the content of your executable and/or library. The result source file can be compiled and linked independently (or in addition) of the library it described.

See for example root.cern.ch/drupal/content/reflex

Cheers,
Philippe.

Hello Phillippe,
So do you think that rootcint or genreflex will solve my poblem? You are very right that runtime reflection always required some instruments that guides how to take information at runtime, declare types at runtime and finally able to call methods of certain type at runtime.This is meta data that house kept.

Do you think that If I need to call methods of Exe/Lib , it would accept that Exe/Lib and generate meta data(instruments) inorder to do proper reflection on that Exe/Lib?

I need this one to be done. And I am using Root as last resort to go.

Regards
Usman

[quote]Do you think that If I need to call methods of Exe/Lib , it would accept that Exe/Lib and generate meta data(instruments) inorder to do proper reflection on that Exe/Lib?[/quote]rootcint and genreflex must see the header files (and only the header files) describing the library in order to be able to generate the proper source code (that you then need to compile and link) necessary to have proper introspection. As I mentioned the libraries created by a C++ compiler (especially in optimized mode) do NOT contains enough information to do this generation.

Cheers,
Philippe.

I have an idea…
If some how the library to which I need to use (Call its methods at run time), If I generate dictionary set for all of its headers somehow , then will I be able to use reflex for calling methods at runtime of that library…

Generating dictionaries overhead of specific library can be beard , as this practice once a while I need to do this, and after that I can use reflection according to my needs at any time.

exactly :slight_smile:

I am trying to do that.

But not even a single and simplistic .h header file compiled successfully and always dictionary failed to be produced. I have tested with simplistic header file, but always some error fails the compilation process, some times it unable to locate included headers or sometime any strange syntax error makes the compilation process fails.

I have dozens of COM/Win32 header files those corresponds some shared library or Exe, What will happen will all of those if I go for this approach to be work.

One needs to see your real application goal to be able to make a good advice. It is hard to do that blindly.

However, . . . How many methods / functions your want to be able to invoke ? Is it crucial for you to preserve the original Win32/COM interface?
Can you think about your own “wrapper “/ “façade” / “proxy” class with the bunch of the methods calling what you need from COM/Win32 header and create the RootCint dictionary for your class only? It is assumed that your class has no “external” include statements at all.

This way RooCint doesn’t “see” any Win32/COM/MFC/.Net headers and you will get the functionality you need with no overhead. In theory, you can create a simple script to generate such class from your COM/Win32 headers on the top of RootCint automatically. (This is how the original stand-alone CINT is complemented with the third party packages).