Browse Source

Remove dependency on the Generator class by explicitly passing the needed services.

pull/1/head
triton 13 years ago
parent
commit
0302622b00
  1. 2
      src/Generator/Generators/CLI/CLIHelpers.cs
  2. 3
      src/Generator/Generators/CLI/CLIMarshal.cs
  3. 12
      src/Generator/Generators/CLI/CLITypePrinter.cs

2
src/Generator/Generators/CLI/CLIHelpers.cs

@ -137,7 +137,7 @@ namespace Cxxi.Generators.CLI
public CLIGenerator(Generator generator) public CLIGenerator(Generator generator)
{ {
Generator = generator; Generator = generator;
typePrinter = new CLITypePrinter(generator); typePrinter = new CLITypePrinter(TypeMapDatabase, Library);
Type.TypePrinter = typePrinter; Type.TypePrinter = typePrinter;
} }

3
src/Generator/Generators/CLI/CLIMarshal.cs

@ -187,7 +187,8 @@ namespace Cxxi.Generators.CLI
private string ToCLITypeName(Declaration decl) private string ToCLITypeName(Declaration decl)
{ {
var typePrinter = new CLITypePrinter(Generator); var typePrinter = new CLITypePrinter(Generator.TypeMapDatabase,
Generator.Library);
return typePrinter.VisitDeclaration(decl); return typePrinter.VisitDeclaration(decl);
} }

12
src/Generator/Generators/CLI/CLITypePrinter.cs

@ -6,13 +6,13 @@ namespace Cxxi.Generators.CLI
{ {
public class CLITypePrinter : ITypeVisitor<string>, IDeclVisitor<string> public class CLITypePrinter : ITypeVisitor<string>, IDeclVisitor<string>
{ {
public Cxxi.Generators.Generator Generator { get; set; } private ITypeMapDatabase TypeMapDatabase;
public Library Library { get; set; } public Library Library { get; set; }
public CLITypePrinter(Cxxi.Generators.Generator generator) public CLITypePrinter(ITypeMapDatabase database, Library library)
{ {
Generator = generator; TypeMapDatabase = database;
Library = generator.Library; Library = library;
} }
public string VisitTagType(TagType tag, TypeQualifiers quals) public string VisitTagType(TagType tag, TypeQualifiers quals)
@ -153,7 +153,7 @@ namespace Cxxi.Generators.CLI
return null; return null;
TypeMap typeMap = null; TypeMap typeMap = null;
if (Generator.TypeMapDatabase.FindTypeMap(decl, out typeMap)) if (TypeMapDatabase.FindTypeMap(decl, out typeMap))
{ {
return typeMap.Signature(); return typeMap.Signature();
} }
@ -174,7 +174,7 @@ namespace Cxxi.Generators.CLI
var decl = template.Template.TemplatedDecl; var decl = template.Template.TemplatedDecl;
TypeMap typeMap = null; TypeMap typeMap = null;
if (Generator.TypeMapDatabase.FindTypeMap(decl, out typeMap)) if (TypeMapDatabase.FindTypeMap(decl, out typeMap))
{ {
typeMap.Declaration = decl; typeMap.Declaration = decl;
typeMap.Type = template; typeMap.Type = template;

Loading…
Cancel
Save