Browse Source

Add `ScopeKind` to base `TypePrinter`.

pull/1177/head
Joao Matos 7 years ago committed by João Matos
parent
commit
579df276e4
  1. 4
      src/CppParser/Bootstrap/Bootstrap.cs
  2. 10
      src/Generator.Tests/AST/TestAST.cs
  3. 5
      src/Generator/Generators/C/CppTypePrinter.cs
  4. 2
      src/Generator/Generators/CSharp/CSharpSourcesExtensions.cs
  5. 2
      src/Generator/Passes/SymbolsCodeGenerator.cs
  6. 2
      src/Generator/Types/TypeMapDatabase.cs

4
src/CppParser/Bootstrap/Bootstrap.cs

@ -91,7 +91,7 @@ namespace CppSharp @@ -91,7 +91,7 @@ namespace CppSharp
ctx.Options.GeneratorKind = GeneratorKind.CPlusPlus;
var nativeCodeGen = new NativeParserCodeGenerator(ctx);
nativeCodeGen.CTypePrinter.PrintScopeKind = TypePrintScopeKind.Local;
nativeCodeGen.CTypePrinter.ScopeKind = TypePrintScopeKind.Local;
nativeCodeGen.GenerateFilePreamble(CommentKind.BCPL);
nativeCodeGen.NewLine();
@ -134,7 +134,7 @@ namespace CppSharp @@ -134,7 +134,7 @@ namespace CppSharp
ctx.Options.GeneratorKind = GeneratorKind.CPlusPlus;
var nativeCodeGen = new NativeParserCodeGenerator(ctx);
nativeCodeGen.CTypePrinter.PrintScopeKind = TypePrintScopeKind.Local;
nativeCodeGen.CTypePrinter.ScopeKind = TypePrintScopeKind.Local;
nativeCodeGen.GenerateFilePreamble(CommentKind.BCPL);
nativeCodeGen.NewLine();

10
src/Generator.Tests/AST/TestAST.cs

@ -460,7 +460,7 @@ namespace CppSharp.Generator.Tests.AST @@ -460,7 +460,7 @@ namespace CppSharp.Generator.Tests.AST
[Test]
public void TestPrintingConstPointerWithConstType()
{
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified };
var cppTypePrinter = new CppTypePrinter { ScopeKind = TypePrintScopeKind.Qualified };
var builtin = new BuiltinType(PrimitiveType.Char);
var pointee = new QualifiedType(builtin, new TypeQualifiers { IsConst = true });
var pointer = new QualifiedType(new PointerType(pointee), new TypeQualifiers { IsConst = true });
@ -472,7 +472,7 @@ namespace CppSharp.Generator.Tests.AST @@ -472,7 +472,7 @@ namespace CppSharp.Generator.Tests.AST
public void TestPrintingSpecializationWithConstValue()
{
var template = AstContext.FindDecl<ClassTemplate>("TestSpecializationArguments").First();
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified };
var cppTypePrinter = new CppTypePrinter { ScopeKind = TypePrintScopeKind.Qualified };
Assert.That(template.Specializations.Last().Visit(cppTypePrinter).Type,
Is.EqualTo("TestSpecializationArguments<const TestASTEnumItemByName>"));
}
@ -515,7 +515,7 @@ namespace CppSharp.Generator.Tests.AST @@ -515,7 +515,7 @@ namespace CppSharp.Generator.Tests.AST
[Test]
public void TestVolatile()
{
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified };
var cppTypePrinter = new CppTypePrinter { ScopeKind = TypePrintScopeKind.Qualified };
var builtin = new BuiltinType(PrimitiveType.Char);
var pointee = new QualifiedType(builtin, new TypeQualifiers { IsConst = true, IsVolatile = true });
var type = pointee.Visit(cppTypePrinter).Type;
@ -533,7 +533,7 @@ namespace CppSharp.Generator.Tests.AST @@ -533,7 +533,7 @@ namespace CppSharp.Generator.Tests.AST
public void TestPrintNestedInSpecialization()
{
var template = AstContext.FindDecl<ClassTemplate>("TestTemplateClass").First();
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified };
var cppTypePrinter = new CppTypePrinter { ScopeKind = TypePrintScopeKind.Qualified };
Assert.That(template.Specializations[3].Classes.First().Visit(cppTypePrinter).Type,
Is.EqualTo("TestTemplateClass<Math::Complex>::NestedInTemplate"));
}
@ -542,7 +542,7 @@ namespace CppSharp.Generator.Tests.AST @@ -542,7 +542,7 @@ namespace CppSharp.Generator.Tests.AST
public void TestPrintQualifiedSpecialization()
{
var functionWithSpecializationArg = AstContext.FindFunction("functionWithSpecializationArg").First();
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified };
var cppTypePrinter = new CppTypePrinter { ScopeKind = TypePrintScopeKind.Qualified };
Assert.That(functionWithSpecializationArg.Parameters[0].Visit(cppTypePrinter).Type,
Is.EqualTo("const TestTemplateClass<int>"));
}

5
src/Generator/Generators/C/CppTypePrinter.cs

@ -16,7 +16,6 @@ namespace CppSharp.Generators.C @@ -16,7 +16,6 @@ namespace CppSharp.Generators.C
public class CppTypePrinter : TypePrinter
{
public CppTypePrintFlavorKind PrintFlavorKind { get; set; }
public TypePrintScopeKind PrintScopeKind { get; set; }
public bool PrintLogicalNames { get; set; }
public bool PrintTypeQualifiers { get; set; }
public bool PrintTypeModifiers { get; set; }
@ -25,7 +24,7 @@ namespace CppSharp.Generators.C @@ -25,7 +24,7 @@ namespace CppSharp.Generators.C
public CppTypePrinter()
{
PrintFlavorKind = CppTypePrintFlavorKind.Cpp;
PrintScopeKind = TypePrintScopeKind.GlobalQualified;
ScopeKind = TypePrintScopeKind.GlobalQualified;
PrintTypeQualifiers = true;
PrintTypeModifiers = true;
}
@ -370,7 +369,7 @@ namespace CppSharp.Generators.C @@ -370,7 +369,7 @@ namespace CppSharp.Generators.C
public override TypePrinterResult VisitDeclaration(Declaration decl)
{
return GetDeclName(decl, PrintScopeKind);
return GetDeclName(decl, ScopeKind);
}
public override TypePrinterResult VisitTranslationUnit(TranslationUnit unit)

2
src/Generator/Generators/CSharp/CSharpSourcesExtensions.cs

@ -98,7 +98,7 @@ namespace CppSharp.Generators.CSharp @@ -98,7 +98,7 @@ namespace CppSharp.Generators.CSharp
var names = new List<string> { mapped.OriginalName };
foreach (TypePrintScopeKind kind in Enum.GetValues(typeof(TypePrintScopeKind)))
{
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = kind };
var cppTypePrinter = new CppTypePrinter { ScopeKind = kind };
names.Add(mapped.Visit(cppTypePrinter));
}
foreach (var name in names.Where(context.TypeMaps.TypeMaps.ContainsKey))

2
src/Generator/Passes/SymbolsCodeGenerator.cs

@ -305,7 +305,7 @@ namespace CppSharp.Passes @@ -305,7 +305,7 @@ namespace CppSharp.Passes
private CppTypePrinter cppTypePrinter = new CppTypePrinter
{
PrintScopeKind = TypePrintScopeKind.Qualified
ScopeKind = TypePrintScopeKind.Qualified
};
private int functionCount;
}

2
src/Generator/Types/TypeMapDatabase.cs

@ -93,7 +93,7 @@ namespace CppSharp.Types @@ -93,7 +93,7 @@ namespace CppSharp.Types
new[] { TypePrintScopeKind.Local, TypePrintScopeKind.Qualified })
{
typePrinter.ResolveTypedefs = resolveTypeDefs;
typePrinter.PrintScopeKind = typePrintScopeKind;
typePrinter.ScopeKind = typePrintScopeKind;
if (FindTypeMap(type.Visit(typePrinter), out typeMap))
{
typeMap.Type = type;

Loading…
Cancel
Save