Browse Source

Generate valid C# for forwarded specializations

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1635/head
Dimitar Dobrev 4 years ago
parent
commit
e2d0dce8ba
  1. 5
      src/Generator/AST/Utils.cs
  2. 14
      tests/NamespacesBase/NamespacesBase.h
  3. 3
      tests/NamespacesDerived/Independent.h
  4. 4
      tests/NamespacesDerived/NamespacesDerived.cpp
  5. 3
      tests/NamespacesDerived/NamespacesDerived.h

5
src/Generator/AST/Utils.cs

@ -151,7 +151,8 @@ namespace CppSharp.AST
ClassTemplateSpecialization specialization, TemplateArgument a, ITypeMapDatabase typeMaps) ClassTemplateSpecialization specialization, TemplateArgument a, ITypeMapDatabase typeMaps)
{ {
if (a.Type.Type == null || if (a.Type.Type == null ||
IsTypeExternal(specialization.TranslationUnit.Module, a.Type.Type)) IsTypeExternal(
specialization.TemplatedDecl.TemplatedDecl.TranslationUnit.Module, a.Type.Type))
return true; return true;
var typeIgnoreChecker = new TypeIgnoreChecker(typeMaps); var typeIgnoreChecker = new TypeIgnoreChecker(typeMaps);
@ -178,7 +179,7 @@ namespace CppSharp.AST
{ {
if (type.TryGetDeclaration(out Declaration declaration)) if (type.TryGetDeclaration(out Declaration declaration))
{ {
ClassTemplateSpecialization specialization = null; ClassTemplateSpecialization specialization;
do do
{ {
specialization = declaration as ClassTemplateSpecialization; specialization = declaration as ClassTemplateSpecialization;

14
tests/NamespacesBase/NamespacesBase.h

@ -80,8 +80,22 @@ class DLL_API TemplateWithIndependentFields
{ {
public: public:
void useDependentPointer(const T* t); void useDependentPointer(const T* t);
const T& constField() const;
private:
T* t = new T;
}; };
template <typename T>
const T& TemplateWithIndependentFields<T>::constField() const
{
return *t;
}
template <typename T>
void TemplateWithIndependentFields<T>::useDependentPointer(const T* t)
{
}
class DLL_API HasVirtualInCore class DLL_API HasVirtualInCore
{ {
public: public:

3
tests/NamespacesDerived/Independent.h

@ -0,0 +1,3 @@
class Derived;
template<typename T> class TemplateWithIndependentFields;
typedef TemplateWithIndependentFields<Derived*> ForwardedInIndependentHeader;

4
tests/NamespacesDerived/NamespacesDerived.cpp

@ -110,3 +110,7 @@ bool operator<<(const Base& b, const char* str)
{ {
return false; return false;
} }
void forceUseSpecializations(ForwardedInIndependentHeader value)
{
}

3
tests/NamespacesDerived/NamespacesDerived.h

@ -1,5 +1,6 @@
#include "../Tests.h" #include "../Tests.h"
#include "../NamespacesBase/NamespacesBase.h" #include "../NamespacesBase/NamespacesBase.h"
#include "Independent.h"
// Namespace clashes with NamespacesBase.OverlappingNamespace // Namespace clashes with NamespacesBase.OverlappingNamespace
// Test whether qualified names turn out right. // Test whether qualified names turn out right.
@ -168,3 +169,5 @@ public:
*/ */
class LinphoneAddress {}; class LinphoneAddress {};
}; };
DLL_API void forceUseSpecializations(ForwardedInIndependentHeader value);

Loading…
Cancel
Save