Browse Source

Fixed the generated C# for specialisations with an ignored specialisation as an arg.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1015/head
Dimitar Dobrev 8 years ago
parent
commit
4bfece6ab9
  1. 2
      src/Generator/Library.cs
  2. 22
      src/Generator/Passes/CheckIgnoredDecls.cs
  3. 1
      tests/CSharp/CSharp.cs
  4. 4
      tests/CSharp/CSharpTemplates.cpp
  5. 6
      tests/CSharp/CSharpTemplates.h

2
src/Generator/Library.cs

@ -185,7 +185,7 @@ namespace CppSharp @@ -185,7 +185,7 @@ namespace CppSharp
public static void IgnoreClassWithName(this ASTContext context, string name)
{
foreach (var @class in context.FindClass(name))
@class.GenerationKind = GenerationKind.Internal;
@class.ExplicitlyIgnore();
}
public static void SetClassAsOpaque(this ASTContext context, string name)

22
src/Generator/Passes/CheckIgnoredDecls.cs

@ -37,7 +37,7 @@ namespace CppSharp.Passes @@ -37,7 +37,7 @@ namespace CppSharp.Passes
injectedClasses.Add(@class);
if (!@class.IsDependent)
return false;
return true;
if (Options.GenerateClassTemplates)
IgnoreUnsupportedTemplates(@class);
@ -49,6 +49,26 @@ namespace CppSharp.Passes @@ -49,6 +49,26 @@ namespace CppSharp.Passes
return true;
}
public override bool VisitClassTemplateSpecializationDecl(ClassTemplateSpecialization specialization)
{
if (!base.VisitClassTemplateSpecializationDecl(specialization))
return false;
Declaration decl = null;
if (specialization.Arguments.Any(a =>
a.Type.Type?.TryGetDeclaration(out decl) == true))
{
decl.Visit(this);
if (decl.Ignore)
{
specialization.ExplicitlyIgnore();
return false;
}
}
return true;
}
public override bool VisitDeclaration(Declaration decl)
{
if (AlreadyVisited(decl))

1
tests/CSharp/CSharp.cs

@ -39,6 +39,7 @@ namespace CppSharp.Tests @@ -39,6 +39,7 @@ namespace CppSharp.Tests
ctx.SetClassAsValueType("QRect");
ctx.SetClassAsValueType("StructTestArrayTypeFromTypedef");
ctx.IgnoreClassWithName("IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor");
ctx.IgnoreClassWithName("Ignored");
var macroRegex = new Regex("(MY_MACRO_TEST_.*)");
var list = (from unit in ctx.TranslationUnits

4
tests/CSharp/CSharpTemplates.cpp

@ -131,6 +131,10 @@ void forceUseSpecializations(IndependentFields<int> _1, IndependentFields<bool> @@ -131,6 +131,10 @@ void forceUseSpecializations(IndependentFields<int> _1, IndependentFields<bool>
{
}
void hasIgnoredParam(DependentValueFields<IndependentFields<Ignored>> ii)
{
}
DependentValueFields<double> specialiseReturnOnly()
{
return DependentValueFields<double>();

6
tests/CSharp/CSharpTemplates.h

@ -18,6 +18,10 @@ class DLL_API T2 @@ -18,6 +18,10 @@ class DLL_API T2
{
};
class DLL_API Ignored
{
};
template <typename T>
class DLL_API IndependentFields : public T1
{
@ -507,6 +511,8 @@ void forceUseSpecializations(IndependentFields<int> _1, IndependentFields<bool> @@ -507,6 +511,8 @@ void forceUseSpecializations(IndependentFields<int> _1, IndependentFields<bool>
TemplateWithIndexer<T2*> _12, TemplateDerivedFromRegularDynamic<RegularDynamic> _13,
IndependentFields<OnlySpecialisedInTypeArg<double>> _14, std::string s);
void hasIgnoredParam(DependentValueFields<IndependentFields<Ignored>> ii);
DLL_API DependentValueFields<double> specialiseReturnOnly();
// force the symbols for the template instantiations because we do not have the auto-compilation for the generated C++ source

Loading…
Cancel
Save