Skip to content

Commit 579df27

Browse files
committed
Add ScopeKind to base TypePrinter.
1 parent f642cef commit 579df27

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

src/CppParser/Bootstrap/Bootstrap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private void GenerateExpr(BindingContext ctx)
9191

9292
ctx.Options.GeneratorKind = GeneratorKind.CPlusPlus;
9393
var nativeCodeGen = new NativeParserCodeGenerator(ctx);
94-
nativeCodeGen.CTypePrinter.PrintScopeKind = TypePrintScopeKind.Local;
94+
nativeCodeGen.CTypePrinter.ScopeKind = TypePrintScopeKind.Local;
9595
nativeCodeGen.GenerateFilePreamble(CommentKind.BCPL);
9696
nativeCodeGen.NewLine();
9797

@@ -134,7 +134,7 @@ private void GenerateStmt(BindingContext ctx)
134134
ctx.Options.GeneratorKind = GeneratorKind.CPlusPlus;
135135

136136
var nativeCodeGen = new NativeParserCodeGenerator(ctx);
137-
nativeCodeGen.CTypePrinter.PrintScopeKind = TypePrintScopeKind.Local;
137+
nativeCodeGen.CTypePrinter.ScopeKind = TypePrintScopeKind.Local;
138138
nativeCodeGen.GenerateFilePreamble(CommentKind.BCPL);
139139
nativeCodeGen.NewLine();
140140

src/Generator.Tests/AST/TestAST.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ public void TestOriginalNamesOfSpecializations()
460460
[Test]
461461
public void TestPrintingConstPointerWithConstType()
462462
{
463-
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified };
463+
var cppTypePrinter = new CppTypePrinter { ScopeKind = TypePrintScopeKind.Qualified };
464464
var builtin = new BuiltinType(PrimitiveType.Char);
465465
var pointee = new QualifiedType(builtin, new TypeQualifiers { IsConst = true });
466466
var pointer = new QualifiedType(new PointerType(pointee), new TypeQualifiers { IsConst = true });
@@ -472,7 +472,7 @@ public void TestPrintingConstPointerWithConstType()
472472
public void TestPrintingSpecializationWithConstValue()
473473
{
474474
var template = AstContext.FindDecl<ClassTemplate>("TestSpecializationArguments").First();
475-
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified };
475+
var cppTypePrinter = new CppTypePrinter { ScopeKind = TypePrintScopeKind.Qualified };
476476
Assert.That(template.Specializations.Last().Visit(cppTypePrinter).Type,
477477
Is.EqualTo("TestSpecializationArguments<const TestASTEnumItemByName>"));
478478
}
@@ -515,7 +515,7 @@ public void TestFunctionSpecializationInfo()
515515
[Test]
516516
public void TestVolatile()
517517
{
518-
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified };
518+
var cppTypePrinter = new CppTypePrinter { ScopeKind = TypePrintScopeKind.Qualified };
519519
var builtin = new BuiltinType(PrimitiveType.Char);
520520
var pointee = new QualifiedType(builtin, new TypeQualifiers { IsConst = true, IsVolatile = true });
521521
var type = pointee.Visit(cppTypePrinter).Type;
@@ -533,7 +533,7 @@ public void TestFindFunctionInNamespace()
533533
public void TestPrintNestedInSpecialization()
534534
{
535535
var template = AstContext.FindDecl<ClassTemplate>("TestTemplateClass").First();
536-
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified };
536+
var cppTypePrinter = new CppTypePrinter { ScopeKind = TypePrintScopeKind.Qualified };
537537
Assert.That(template.Specializations[3].Classes.First().Visit(cppTypePrinter).Type,
538538
Is.EqualTo("TestTemplateClass<Math::Complex>::NestedInTemplate"));
539539
}
@@ -542,7 +542,7 @@ public void TestPrintNestedInSpecialization()
542542
public void TestPrintQualifiedSpecialization()
543543
{
544544
var functionWithSpecializationArg = AstContext.FindFunction("functionWithSpecializationArg").First();
545-
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified };
545+
var cppTypePrinter = new CppTypePrinter { ScopeKind = TypePrintScopeKind.Qualified };
546546
Assert.That(functionWithSpecializationArg.Parameters[0].Visit(cppTypePrinter).Type,
547547
Is.EqualTo("const TestTemplateClass<int>"));
548548
}

src/Generator/Generators/C/CppTypePrinter.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public enum CppTypePrintFlavorKind
1616
public class CppTypePrinter : TypePrinter
1717
{
1818
public CppTypePrintFlavorKind PrintFlavorKind { get; set; }
19-
public TypePrintScopeKind PrintScopeKind { get; set; }
2019
public bool PrintLogicalNames { get; set; }
2120
public bool PrintTypeQualifiers { get; set; }
2221
public bool PrintTypeModifiers { get; set; }
@@ -25,7 +24,7 @@ public class CppTypePrinter : TypePrinter
2524
public CppTypePrinter()
2625
{
2726
PrintFlavorKind = CppTypePrintFlavorKind.Cpp;
28-
PrintScopeKind = TypePrintScopeKind.GlobalQualified;
27+
ScopeKind = TypePrintScopeKind.GlobalQualified;
2928
PrintTypeQualifiers = true;
3029
PrintTypeModifiers = true;
3130
}
@@ -370,7 +369,7 @@ public TypePrinterResult GetDeclName(Declaration declaration, TypePrintScopeKind
370369

371370
public override TypePrinterResult VisitDeclaration(Declaration decl)
372371
{
373-
return GetDeclName(decl, PrintScopeKind);
372+
return GetDeclName(decl, ScopeKind);
374373
}
375374

376375
public override TypePrinterResult VisitTranslationUnit(TranslationUnit unit)

src/Generator/Generators/CSharp/CSharpSourcesExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private static void DisableSingleTypeMap(Class mapped, BindingContext context)
9898
var names = new List<string> { mapped.OriginalName };
9999
foreach (TypePrintScopeKind kind in Enum.GetValues(typeof(TypePrintScopeKind)))
100100
{
101-
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = kind };
101+
var cppTypePrinter = new CppTypePrinter { ScopeKind = kind };
102102
names.Add(mapped.Visit(cppTypePrinter));
103103
}
104104
foreach (var name in names.Where(context.TypeMaps.TypeMaps.ContainsKey))

src/Generator/Passes/SymbolsCodeGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private static Stack<string> GenerateNamespace(Function function)
305305

306306
private CppTypePrinter cppTypePrinter = new CppTypePrinter
307307
{
308-
PrintScopeKind = TypePrintScopeKind.Qualified
308+
ScopeKind = TypePrintScopeKind.Qualified
309309
};
310310
private int functionCount;
311311
}

src/Generator/Types/TypeMapDatabase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public bool FindTypeMap(Type type, out TypeMap typeMap)
9393
new[] { TypePrintScopeKind.Local, TypePrintScopeKind.Qualified })
9494
{
9595
typePrinter.ResolveTypedefs = resolveTypeDefs;
96-
typePrinter.PrintScopeKind = typePrintScopeKind;
96+
typePrinter.ScopeKind = typePrintScopeKind;
9797
if (FindTypeMap(type.Visit(typePrinter), out typeMap))
9898
{
9999
typeMap.Type = type;

0 commit comments

Comments
 (0)