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

14
tests/NamespacesBase/NamespacesBase.h

@ -80,8 +80,22 @@ class DLL_API TemplateWithIndependentFields @@ -80,8 +80,22 @@ class DLL_API TemplateWithIndependentFields
{
public:
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
{
public:

3
tests/NamespacesDerived/Independent.h

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

3
tests/NamespacesDerived/NamespacesDerived.h

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

Loading…
Cancel
Save