Is the original definition of the template available in the XML file, not just the reference to the specific instantiations (i.e. 
IMyEnumerator<int>).<br><br><div class="gmail_quote">On Mon, May 7, 2012 at 12:08 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">(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>
</blockquote></div><br>