My gut tells me that if it isn't already available, then it will be difficult as the instantiation has to occur for the final compilation, but that must be occurring in a later phase of compilation than the one where the XML file is generated. Their is also a good chance that the instantiation depends on information that isn't available until after the XML file is generated (things like overload candidates found during argument dependent look-up). I am not very familiar with clang's code or structure so this is just speculation, perhaps a query on clangs developers list might give you more insight into what options you may have.<br>
<br><div class="gmail_quote">On Tue, May 8, 2012 at 3:22 PM, Ondrej Kolacek <span dir="ltr"><<a href="mailto:natris1@gmail.com" target="_blank">natris1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
I do not have the code right here but if I understood your question<br>
correctly, you are asking whether the "generic" structures of the<br>
template are dumped into xml while the "specialization" is printed<br>
incomplete. Yes, xml dump of the structure containing stuff like "this<br>
template has parameter typename T" is present. But I do not dare to<br>
use the dump of the template's generic structure for doing the<br>
template parameter substitution within my code as this looks<br>
nontrivial, very error prone, and not all the necessary information<br>
for the substitution is currently available in XML.<br>
<br>
I currently plan to try to somehow hack the parser to call the<br>
function which instantiates templates from some convenient place,<br>
although whether I will be able to find such a place and the correct<br>
function I am not certain. This is why I have tried to find some<br>
alternate solution via this mail.<br>
<span class="HOEnZb"><font color="#888888"><br>
Ondrej<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, May 8, 2012 at 1:03 AM, Nathan Jeffords <<a href="mailto:blunted2night@gmail.com">blunted2night@gmail.com</a>> wrote:<br>
> Is the original definition of the template available in the XML file, not<br>
> just the reference to the specific instantiations (i.e.<br>
> IMyEnumerator<int>).<br>
><br>
><br>
> On Mon, May 7, 2012 at 12:08 PM, Ondrej Kolacek <<a href="mailto:natris1@gmail.com">natris1@gmail.com</a>> wrote:<br>
>><br>
>> (another try from different mail account; I hope I was able to clarify<br>
>> my issue better. )<br>
>><br>
>> Hello,<br>
>> I am working on a tool which takes c++ header files of a C++ DLL and<br>
>> based on "interfaces" defined in them generates csharp classes and<br>
>> glue layer for interop. For analyzing the c++ code I am currently<br>
>> using clang, which parses the headers and writes output into xml via<br>
>> -ast-print-xml (yes, this unfortunately means that it is a very old<br>
>> version of clang). I then use these xml files to generate the csharp<br>
>> code. Since the header files are written in consistent style, it works<br>
>> pretty well.<br>
>><br>
>> But new version of headers contains templates. Nothing fancy, usually<br>
>> stuff like:<br>
>> template <typename T><br>
>> IMyEnumerator {<br>
>> virtual HRESULT GetCurrent(T*item) = 0;<br>
>> };<br>
>> class IWhateverInterface {<br>
>> virtual IMyEnumerator<int> & GetEnumerator() = 0;<br>
>> };<br>
>> And here lies the problem - since the template IMyEnumerator<int> is<br>
>> only used in this declaration, this template specialization is not<br>
>> instantiated and the XML does not contain full CXXRecord of the class.<br>
>> I however need to know the full structure of the type because I need<br>
>> to generate the glue layer for the enumerator.<br>
>><br>
>> It seems to me that this would be quite a common problem for similar<br>
>> tools and someone might have stumbled upon it already, and because of<br>
>> this I'd like to ask: is there any clean way how to force<br>
>> instantiation of templates that do not strictly have to be<br>
>> instantiated? Because if it isn't, this means that I will either have<br>
>> to somehow analyze the headers and generate code which forces the<br>
>> instantiation (which is not really trivial) or try to hack the code<br>
>> somehow to force the instantiation (probably possible but certainly<br>
>> not pretty).<br>
>><br>
>> NOTE: one example of code which forces the instantiation is<br>
>> class Dummy : public IMyEnumerator<int><br>
>> {<br>
>> };<br>
>><br>
>> Thank you for any idea,<br>
>> Ondrej<br>
><br>
><br>
</div></div></blockquote></div><br>