Browse Source

Marked incomplete class template specialisations and ignored them later.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/685/head
Dimitar Dobrev 10 years ago
parent
commit
d41609eafb
  1. 24
      src/CppParser/Parser.cpp
  2. 2
      src/Generator/Passes/ResolveIncompleteDeclsPass.cs
  3. 12
      tests/CSharp/CSharp.Tests.cs

24
src/CppParser/Parser.cpp

@ -1103,7 +1103,19 @@ Parser::WalkClassTemplateSpecialization(const clang::ClassTemplateSpecialization
} }
if (CTS->isCompleteDefinition()) if (CTS->isCompleteDefinition())
{
WalkRecordCXX(CTS, TS); WalkRecordCXX(CTS, TS);
}
else
{
TS->IsIncomplete = true;
if (CTS->getDefinition())
{
auto Complete = WalkDeclaration(CTS->getDefinition(), /*CanBeDefinition=*/true);
if (!Complete->IsIncomplete)
TS->CompleteDeclaration = Complete;
}
}
return TS; return TS;
} }
@ -1141,7 +1153,19 @@ Parser::WalkClassTemplatePartialSpecialization(const clang::ClassTemplatePartial
} }
if (CTS->isCompleteDefinition()) if (CTS->isCompleteDefinition())
{
WalkRecordCXX(CTS, TS); WalkRecordCXX(CTS, TS);
}
else
{
TS->IsIncomplete = true;
if (CTS->getDefinition())
{
auto Complete = WalkDeclaration(CTS->getDefinition(), /*CanBeDefinition=*/true);
if (!Complete->IsIncomplete)
TS->CompleteDeclaration = Complete;
}
}
return TS; return TS;
} }

2
src/Generator/Passes/ResolveIncompleteDeclsPass.cs

@ -25,7 +25,7 @@ namespace CppSharp.Passes
template.TemplatedDecl = template.TemplatedDecl.CompleteDeclaration ?? template.TemplatedDecl; template.TemplatedDecl = template.TemplatedDecl.CompleteDeclaration ?? template.TemplatedDecl;
// store all spesializations in the real template class because ClassTemplateDecl only forwards // store all spesializations in the real template class because ClassTemplateDecl only forwards
foreach (var specialization in template.Specializations.Where( foreach (var specialization in template.Specializations.Where(
s => !template.TemplatedClass.Specializations.Contains(s))) s => !s.IsIncomplete && !template.TemplatedClass.Specializations.Contains(s)))
template.TemplatedClass.Specializations.Add(specialization); template.TemplatedClass.Specializations.Add(specialization);
return true; return true;

12
tests/CSharp/CSharp.Tests.cs

@ -537,9 +537,9 @@ public unsafe class CSharpTests : GeneratorTestFixture
{ {
typeof(CSharp.IndependentFields.Internal), typeof(CSharp.IndependentFields.Internal),
typeof(CSharp.DependentValueFields.Internal_bool), typeof(CSharp.DependentValueFields.Internal_bool),
typeof(CSharp.DependentValueFields.Internal_float), //typeof(CSharp.DependentValueFields.Internal_float),
typeof(CSharp.DependentPointerFields.Internal), typeof(CSharp.DependentPointerFields.Internal),
typeof(CSharp.DependentValueFields.Internal_Ptr), //typeof(CSharp.DependentValueFields.Internal_Ptr),
typeof(CSharp.HasDefaultTemplateArgument.Internal_int_IndependentFields_int) typeof(CSharp.HasDefaultTemplateArgument.Internal_int_IndependentFields_int)
}) })
{ {
@ -548,11 +548,11 @@ public unsafe class CSharpTests : GeneratorTestFixture
var fieldOffset = (FieldOffsetAttribute) independentFields[0].GetCustomAttribute(typeof(FieldOffsetAttribute)); var fieldOffset = (FieldOffsetAttribute) independentFields[0].GetCustomAttribute(typeof(FieldOffsetAttribute));
Assert.That(fieldOffset.Value, Is.EqualTo(0)); Assert.That(fieldOffset.Value, Is.EqualTo(0));
} }
foreach (var internalType in new[] foreach (var internalType in new Type[]
{ {
typeof(CSharp.TwoTemplateArgs.Internal_Ptr), //typeof(CSharp.TwoTemplateArgs.Internal_Ptr),
typeof(CSharp.TwoTemplateArgs.Internal_intPtr_int), //typeof(CSharp.TwoTemplateArgs.Internal_intPtr_int),
typeof(CSharp.TwoTemplateArgs.Internal_intPtr_float) //typeof(CSharp.TwoTemplateArgs.Internal_intPtr_float)
}) })
{ {
var independentFields = internalType.GetFields(); var independentFields = internalType.GetFields();

Loading…
Cancel
Save