<font face="tahoma,sans-serif"><div><font face="tahoma,sans-serif">Cédric,</font></div><div><font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif">Your suggestion is quite reasonable, however in your scenario you must load the shared object / library into memory and execute code in order to enumerate the metadata.  You will incur all the performance penalties for loading shared libraries for executable purposes, such as rebasing, etc.  A particularly useful scenario for reflection is to scan a directory of libraries and determine available features or plugins, that would be quite costly if they all had to be dynamically loaded.  It would be fairly easy to abstract the reading of the metadata from a specific data section.</font></div>
<div><font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif">My scenario still does not require changes to LLVM or the C++ language, only changes to Clang to generate the metadata.</font></div>
<div><font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif">Good discussion, either way, as it would make it easy to generate scriptable C++ libraries in a non-invasive way.</font></div><div><font face="tahoma,sans-serif"><br>
</font></div><div><font face="tahoma,sans-serif">Cheers,</font></div><div><font face="tahoma,sans-serif"><br>Stu</font></div><br clear="all"></font><span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse;color:rgb(80, 0, 80)"><strong><span style="color:rgb(153, 204, 255)">Stuart Carnie, CTO</span></strong><br>
<span style="color:rgb(255, 102, 0)"><strong><a href="http://manomio.com/" style="color:rgb(255, 102, 0)" target="_blank">manomio</a> | in retro we trust!</strong></span></span><br>
<br><br><div class="gmail_quote">On Mon, Dec 13, 2010 at 12:12 PM, Cédric Venet <span dir="ltr"><<a href="mailto:cedric.venet@laposte.net">cedric.venet@laposte.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
<br>
Le 13/12/2010 19:37, Stuart Carnie a écrit :<br>
<div class="im">> Static reflection seems to be very limited.  Reflection is a powerful<br>
> mechanism for being able to analyse a 3rd party executable or dynamic<br>
> library and interact with it at runtime, dynamically invoking APIs.<br>
<br>
</div>Static reflection is useful, but I agree it is a (completly) different<br>
problem. However, your proposal still seems quite complex and invasive.<br>
Why not juste store the reflection data in C++ structures and expose<br>
them by the mean of global const static object?<br>
<br>
something like:<br>
<br>
**** input<br>
<div class="im">struct Foo<br>
{<br>
   void f();<br>
   int a;<br>
};<br>
<br>
</div>**** generated by clang<br>
// Contain functions for decoding the reflexion information<br>
struct reflection::class_data_base  {<br>
   void EnumMembers(Fct callback);<br>
   int GetValue(const char* name);<br>
   void Call(const char* name);<br>
   //...<br>
};<br>
// for name mangling<br>
struct reflection::class_data<Foo>:reflection::class_data_base {<br>
   static const int num_members=2;<br>
   // obviously pseudo code :)<br>
   static const datatable=[ "f", &f, "a", &a ... ];<br>
};<br>
<br>
<br>
This would allow to not modify llvm and C++ code could be generated by<br>
clang for other compiler. Clang does not need to generate the reflexion<br>
code, it could create an ast or codegen it directly.<br>
<br>
This would also make it portable, no need to access metadata in an<br>
executable...<br>
<br>
Hope this makes sense.<br>
Anyways just my two cents. Good luck on your project, it is really<br>
interesting and useful (especially with the rise of fast scripting<br>
language).<br>
<br>
regards,<br>
<font color="#888888">Cédric<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br>