mono / CppSharp

Tools and libraries to glue C/C++ APIs to high-level languages
MIT License
3.14k stars 517 forks source link

QVector not properly qualified in internal fields in QtGui #490

Closed ddobrev closed 9 years ago

ddobrev commented 9 years ago

To reproduce, run Qt# and try compiling the resulting QtGui.cs. You'll see that, for example, the internal field "m_values" of QInputMethodQueryEvent does not have its QVector type fully qualified. Similar to https://github.com/mono/CppSharp/issues/489, parsing just "qevent.h" works properly unlike the whole QtGui. The problem is that QVector itself - that is, the templated declaration of QVector - is parsed as being part of "qregion.h" (QtGui) while the correct header is "qvector.h" (QtCore). My guess is that some forward declaration is not resolved but taken directly instead thus ending up as the translation unit of QVector.

ddobrev commented 9 years ago

This bug is only exposed when ignored fields are generated. Since the generation of ignored fields is going to be removed, I created a branch called "incorrect_trunit_test" with a test exposing the issue. Whenever ready to work on it, one should check that branch out and run NamespaceDerived.Gen.

The problem is that forward declarations of templates:

template class TemplateClass;

is considered the templated class of template specialisations, that is, the forward declaration is not resolved. This in turn causes the templated declaration to be considered located in an incorrect translation unit which in turn causes incorrect or incomplete printing of the qualified name of the type.

My personal guess about the root of this issue is that GetDeclUSR, used in WalkClassTemplate, generated the same USR for the forward declaration and for the type itself.

ddobrev commented 9 years ago

Fixed by f754263ab50d84f03eda81ee82272eebcfb29896.