Skip to content

Commit

Permalink
Generate valid C# for forwarded specializations
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information
ddobrev committed Sep 18, 2021
1 parent c36145b commit e2d0dce
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Generator/AST/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ private static bool UnsupportedTemplateArgument(
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);
Expand All @@ -178,7 +179,7 @@ private static ClassTemplateSpecialization GetParentSpecialization(Type type)
{
if (type.TryGetDeclaration(out Declaration declaration))
{
ClassTemplateSpecialization specialization = null;
ClassTemplateSpecialization specialization;
do
{
specialization = declaration as ClassTemplateSpecialization;
Expand Down
14 changes: 14 additions & 0 deletions tests/NamespacesBase/NamespacesBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions tests/NamespacesDerived/Independent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Derived;
template<typename T> class TemplateWithIndependentFields;
typedef TemplateWithIndependentFields<Derived*> ForwardedInIndependentHeader;
4 changes: 4 additions & 0 deletions tests/NamespacesDerived/NamespacesDerived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ bool operator<<(const Base& b, const char* str)
{
return false;
}

void forceUseSpecializations(ForwardedInIndependentHeader value)
{
}
3 changes: 3 additions & 0 deletions tests/NamespacesDerived/NamespacesDerived.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -168,3 +169,5 @@ class TestComments
*/
class LinphoneAddress {};
};

DLL_API void forceUseSpecializations(ForwardedInIndependentHeader value);

0 comments on commit e2d0dce

Please sign in to comment.