Browse Source

Generate valid C# for fields with types system template specializations

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1641/head
Dimitar Dobrev 4 years ago
parent
commit
0b8f252d1b
  1. 5
      src/Generator/Passes/MarkUsedClassInternalsPass.cs
  2. 4
      src/Generator/Passes/StripUnusedSystemTypesPass.cs
  3. 2
      tests/CSharp/CSharp.h

5
src/Generator/Passes/MarkUsedClassInternalsPass.cs

@ -57,6 +57,11 @@ namespace CppSharp.Passes
MarkUsedFieldTypes(decl, visitedDeclarationContexts); MarkUsedFieldTypes(decl, visitedDeclarationContexts);
} }
foreach (var @base in @class.Bases.Where(
b => b.IsClass && b.Class.Ignore && b.Class.Fields.Count > 0))
{
@base.Class.GenerationKind = GenerationKind.Internal;
}
} }
} }
} }

4
src/Generator/Passes/StripUnusedSystemTypesPass.cs

@ -40,7 +40,8 @@ namespace CppSharp.Passes
private bool TryMarkType(Type desugared) private bool TryMarkType(Type desugared)
{ {
var tagType = desugared as TagType; var templateType = desugared as TemplateSpecializationType;
var tagType = desugared as TagType ?? templateType?.Desugared.Type as TagType;
if (tagType != null) if (tagType != null)
{ {
var specialization = tagType.Declaration as ClassTemplateSpecialization; var specialization = tagType.Declaration as ClassTemplateSpecialization;
@ -56,7 +57,6 @@ namespace CppSharp.Passes
return true; return true;
} }
var templateType = desugared as TemplateSpecializationType;
if (templateType != null) if (templateType != null)
{ {
var template = templateType.Template; var template = templateType.Template;

2
tests/CSharp/CSharp.h

@ -5,6 +5,7 @@
#include <vector> #include <vector>
#include <limits> #include <limits>
#include <string> #include <string>
#include <mutex>
#include "AnotherUnit.h" #include "AnotherUnit.h"
#include "ExcludedUnit.hpp" #include "ExcludedUnit.hpp"
#include "CSharpTemplates.h" #include "CSharpTemplates.h"
@ -201,6 +202,7 @@ protected:
AbstractProprietor(int i); AbstractProprietor(int i);
int m_value; int m_value;
long m_property; long m_property;
std::mutex m_mutex;
}; };
class DLL_API Proprietor : public AbstractProprietor class DLL_API Proprietor : public AbstractProprietor

Loading…
Cancel
Save