Browse Source

Generate valid C# for independent specialisations with nested fields

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
update-llvm
Dimitar Dobrev 4 years ago
parent
commit
1acb23813d
  1. 2
      src/AST/ClassExtensions.cs
  2. 6
      tests/NamespacesBase/NamespacesBase.h
  3. 1
      tests/NamespacesDerived/NamespacesDerived.Tests.cs
  4. 2
      tests/NamespacesDerived/NamespacesDerived.h

2
src/AST/ClassExtensions.cs

@ -269,7 +269,7 @@ namespace CppSharp.AST
if (desugared is TemplateParameterType) if (desugared is TemplateParameterType)
return true; return true;
var tagType = desugared as TagType; var tagType = desugared as TagType;
if (tagType?.IsDependent == true) if (tagType?.Declaration is Class @class && @class.HasDependentValueFieldInLayout())
return true; return true;
var templateType = desugared as TemplateSpecializationType; var templateType = desugared as TemplateSpecializationType;
if (templateType?.Arguments.Any( if (templateType?.Arguments.Any(

6
tests/NamespacesBase/NamespacesBase.h

@ -79,6 +79,12 @@ public:
private: private:
T field; T field;
}; };
private:
union
{
int i;
float* f;
};
}; };
template <typename T> template <typename T>

1
tests/NamespacesDerived/NamespacesDerived.Tests.cs

@ -15,7 +15,6 @@ public class NamespaceDerivedTests
using (new DerivedFromSecondaryBaseInDependency()) { } using (new DerivedFromSecondaryBaseInDependency()) { }
using (var der2 = new Derived2()) using (var der2 = new Derived2())
using (der2.LocalTypedefSpecialization) { } using (der2.LocalTypedefSpecialization) { }
Assert.That(typeof(Derived2).Assembly.GetTypes().Any(t => t.FullName.Contains("Std.Vector")), Is.True);
} }
[Test] [Test]

2
tests/NamespacesDerived/NamespacesDerived.h

@ -62,6 +62,7 @@ public:
TemplateClass<int> getTemplate(); TemplateClass<int> getTemplate();
IndependentFields<int> getIndependentSpecialization(); IndependentFields<int> getIndependentSpecialization();
IndependentFields<void*> getPointerOnlySpecialization() { return IndependentFields<void*>(); }
typedef DependentFields<int> LocalTypedefSpecialization; typedef DependentFields<int> LocalTypedefSpecialization;
LocalTypedefSpecialization getLocalTypedefSpecialization(); LocalTypedefSpecialization getLocalTypedefSpecialization();
Abstract* getAbstract(); Abstract* getAbstract();
@ -71,6 +72,7 @@ private:
TemplateClass<DependentFields<Derived>> nestedSpecialization; TemplateClass<DependentFields<Derived>> nestedSpecialization;
IndependentFields<int> independentSpecialization; IndependentFields<int> independentSpecialization;
IndependentFields<Derived> independentExternalSpecialization; IndependentFields<Derived> independentExternalSpecialization;
IndependentFields<Derived*> independentExternalSpecializationPointer;
IndependentFields<Derived>::Nested nestedInExternalSpecialization; IndependentFields<Derived>::Nested nestedInExternalSpecialization;
std::unordered_map<int, Derived> externalSpecializationOnly; std::unordered_map<int, Derived> externalSpecializationOnly;
}; };

Loading…
Cancel
Save