Browse Source

Rename type map database in binding context.

pull/700/head
Joao Matos 9 years ago
parent
commit
098ff73e52
  1. 6
      src/Generator/BindingContext.cs
  2. 4
      src/Generator/Generators/CLI/CLIHeaders.cs
  3. 16
      src/Generator/Generators/CLI/CLIMarshal.cs
  4. 2
      src/Generator/Generators/CLI/CLISources.cs
  5. 2
      src/Generator/Generators/CLI/CLITypePrinter.cs
  6. 8
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  7. 12
      src/Generator/Generators/CSharp/CSharpSources.cs
  8. 2
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs
  9. 2
      src/Generator/Passes/Pass.cs

6
src/Generator/BindingContext.cs

@ -17,7 +17,7 @@ namespace CppSharp.Generators
public ParserTargetInfo TargetInfo { get; set; } public ParserTargetInfo TargetInfo { get; set; }
public SymbolContext Symbols { get; private set; } public SymbolContext Symbols { get; private set; }
public TypeMapDatabase TypeDatabase { get; private set; } public TypeMapDatabase TypeMaps { get; private set; }
public PassBuilder<TranslationUnitPass> TranslationUnitPasses { get; private set; } public PassBuilder<TranslationUnitPass> TranslationUnitPasses { get; private set; }
public PassBuilder<GeneratorOutputPass> GeneratorOutputPasses { get; private set; } public PassBuilder<GeneratorOutputPass> GeneratorOutputPasses { get; private set; }
@ -36,8 +36,8 @@ namespace CppSharp.Generators
Symbols = new SymbolContext(); Symbols = new SymbolContext();
Delegates = new Dictionary<Function, DelegatesPass.DelegateDefinition>(); Delegates = new Dictionary<Function, DelegatesPass.DelegateDefinition>();
TypeDatabase = new TypeMapDatabase(); TypeMaps = new TypeMapDatabase();
TypeDatabase.SetupTypeMaps(Options.GeneratorKind); TypeMaps.SetupTypeMaps(Options.GeneratorKind);
TranslationUnitPasses = new PassBuilder<TranslationUnitPass>(this); TranslationUnitPasses = new PassBuilder<TranslationUnitPass>(this);
GeneratorOutputPasses = new PassBuilder<GeneratorOutputPass>(this); GeneratorOutputPasses = new PassBuilder<GeneratorOutputPass>(this);

4
src/Generator/Generators/CLI/CLIHeaders.cs

@ -52,7 +52,7 @@ namespace CppSharp.Generators.CLI
public void GenerateIncludeForwardRefs() public void GenerateIncludeForwardRefs()
{ {
var typeReferenceCollector = new CLITypeReferenceCollector(Context.TypeDatabase, var typeReferenceCollector = new CLITypeReferenceCollector(Context.TypeMaps,
Context.Options); Context.Options);
typeReferenceCollector.Process(TranslationUnit, filterNamespaces: false); typeReferenceCollector.Process(TranslationUnit, filterNamespaces: false);
@ -131,7 +131,7 @@ namespace CppSharp.Generators.CLI
public void GenerateForwardRefs() public void GenerateForwardRefs()
{ {
var typeReferenceCollector = new CLITypeReferenceCollector(Context.TypeDatabase, var typeReferenceCollector = new CLITypeReferenceCollector(Context.TypeMaps,
Context.Options); Context.Options);
typeReferenceCollector.Process(TranslationUnit); typeReferenceCollector.Process(TranslationUnit);

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

@ -20,7 +20,7 @@ namespace CppSharp.Generators.CLI
public override bool VisitType(Type type, TypeQualifiers quals) public override bool VisitType(Type type, TypeQualifiers quals)
{ {
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.Type = type; typeMap.Type = type;
typeMap.CLIMarshalToManaged(Context); typeMap.CLIMarshalToManaged(Context);
@ -155,7 +155,7 @@ namespace CppSharp.Generators.CLI
} }
TypeMap typeMap = null; TypeMap typeMap = null;
Context.Context.TypeDatabase.FindTypeMap(pointee, out typeMap); Context.Context.TypeMaps.FindTypeMap(pointee, out typeMap);
Class @class; Class @class;
if (pointee.TryGetClass(out @class) && typeMap == null) if (pointee.TryGetClass(out @class) && typeMap == null)
@ -237,7 +237,7 @@ namespace CppSharp.Generators.CLI
var decl = typedef.Declaration; var decl = typedef.Declaration;
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.Type = typedef; typeMap.Type = typedef;
typeMap.CLIMarshalToManaged(Context); typeMap.CLIMarshalToManaged(Context);
@ -262,7 +262,7 @@ namespace CppSharp.Generators.CLI
TypeQualifiers quals) TypeQualifiers quals)
{ {
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(template, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(template, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.Type = template; typeMap.Type = template;
typeMap.CLIMarshalToManaged(Context); typeMap.CLIMarshalToManaged(Context);
@ -426,7 +426,7 @@ namespace CppSharp.Generators.CLI
public override bool VisitType(Type type, TypeQualifiers quals) public override bool VisitType(Type type, TypeQualifiers quals)
{ {
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.Type = type; typeMap.Type = type;
typeMap.CLIMarshalToNative(Context); typeMap.CLIMarshalToNative(Context);
@ -611,7 +611,7 @@ namespace CppSharp.Generators.CLI
var decl = typedef.Declaration; var decl = typedef.Declaration;
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.CLIMarshalToNative(Context); typeMap.CLIMarshalToNative(Context);
return typeMap.IsValueType; return typeMap.IsValueType;
@ -647,7 +647,7 @@ namespace CppSharp.Generators.CLI
TypeQualifiers quals) TypeQualifiers quals)
{ {
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(template, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(template, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.Type = template; typeMap.Type = template;
typeMap.CLIMarshalToNative(Context); typeMap.CLIMarshalToNative(Context);
@ -693,7 +693,7 @@ namespace CppSharp.Generators.CLI
private void MarshalRefClass(Class @class) private void MarshalRefClass(Class @class)
{ {
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(@class, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(@class, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.CLIMarshalToNative(Context); typeMap.CLIMarshalToNative(Context);
return; return;

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

@ -60,7 +60,7 @@ namespace CppSharp.Generators.CLI
{ {
PushBlock(CLIBlockKind.IncludesForwardReferences); PushBlock(CLIBlockKind.IncludesForwardReferences);
var typeReferenceCollector = new CLITypeReferenceCollector(Context.TypeDatabase, Context.Options); var typeReferenceCollector = new CLITypeReferenceCollector(Context.TypeMaps, Context.Options);
typeReferenceCollector.Process(TranslationUnit, filterNamespaces: false); typeReferenceCollector.Process(TranslationUnit, filterNamespaces: false);
var includes = new SortedSet<string>(StringComparer.InvariantCulture); var includes = new SortedSet<string>(StringComparer.InvariantCulture);

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

@ -28,7 +28,7 @@ namespace CppSharp.Generators.CLI
public BindingContext Context { get; private set; } public BindingContext Context { get; private set; }
public DriverOptions Options { get { return Context.Options; } } public DriverOptions Options { get { return Context.Options; } }
public TypeMapDatabase TypeMapDatabase { get { return Context.TypeDatabase; } } public TypeMapDatabase TypeMapDatabase { get { return Context.TypeMaps; } }
public CLITypePrinter(BindingContext context) public CLITypePrinter(BindingContext context)
{ {

8
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -64,7 +64,7 @@ namespace CppSharp.Generators.CSharp
public override bool VisitType(Type type, TypeQualifiers quals) public override bool VisitType(Type type, TypeQualifiers quals)
{ {
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.Type = type; typeMap.Type = type;
typeMap.CSharpMarshalToManaged(Context); typeMap.CSharpMarshalToManaged(Context);
@ -77,7 +77,7 @@ namespace CppSharp.Generators.CSharp
public override bool VisitDeclaration(Declaration decl) public override bool VisitDeclaration(Declaration decl)
{ {
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.Declaration = decl; typeMap.Declaration = decl;
typeMap.CSharpMarshalToManaged(Context); typeMap.CSharpMarshalToManaged(Context);
@ -382,7 +382,7 @@ namespace CppSharp.Generators.CSharp
public override bool VisitType(Type type, TypeQualifiers quals) public override bool VisitType(Type type, TypeQualifiers quals)
{ {
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.Type = type; typeMap.Type = type;
typeMap.CSharpMarshalToNative(Context); typeMap.CSharpMarshalToNative(Context);
@ -395,7 +395,7 @@ namespace CppSharp.Generators.CSharp
public override bool VisitDeclaration(Declaration decl) public override bool VisitDeclaration(Declaration decl)
{ {
TypeMap typeMap; TypeMap typeMap;
if (Context.Context.TypeDatabase.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling) if (Context.Context.TypeMaps.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling)
{ {
typeMap.Declaration = decl; typeMap.Declaration = decl;
typeMap.CSharpMarshalToNative(Context); typeMap.CSharpMarshalToNative(Context);

12
src/Generator/Generators/CSharp/CSharpSources.cs

@ -432,11 +432,11 @@ namespace CppSharp.Generators.CSharp
GenerateClassTemplateSpecializationInternal(nestedTemplate); GenerateClassTemplateSpecializationInternal(nestedTemplate);
System.Type typeMap = null; System.Type typeMap = null;
if (Context.TypeDatabase.TypeMaps.ContainsKey(@class.Name)) if (Context.TypeMaps.TypeMaps.ContainsKey(@class.Name))
{ {
typeMap = Context.TypeDatabase.TypeMaps[@class.Name]; typeMap = Context.TypeMaps.TypeMaps[@class.Name];
// disable the type map for the mapped class itself so that operator params are not mapped // disable the type map for the mapped class itself so that operator params are not mapped
Context.TypeDatabase.TypeMaps.Remove(@class.Name); Context.TypeMaps.TypeMaps.Remove(@class.Name);
} }
PushBlock(CSharpBlockKind.Class); PushBlock(CSharpBlockKind.Class);
@ -506,7 +506,7 @@ namespace CppSharp.Generators.CSharp
PopBlock(NewLineKind.BeforeNextBlock); PopBlock(NewLineKind.BeforeNextBlock);
if (typeMap != null) if (typeMap != null)
Context.TypeDatabase.TypeMaps.Add(@class.Name, typeMap); Context.TypeMaps.TypeMaps.Add(@class.Name, typeMap);
} }
private void GenerateClassMarshals(Class @class) private void GenerateClassMarshals(Class @class)
@ -760,7 +760,7 @@ namespace CppSharp.Generators.CSharp
foreach (var @base in @class.Bases.Where(b => b.Class != null)) foreach (var @base in @class.Bases.Where(b => b.Class != null))
{ {
TypeMap typeMap; TypeMap typeMap;
if ((!Context.TypeDatabase.FindTypeMap(@base.Type, out typeMap) && !@base.Class.IsDeclared) || if ((!Context.TypeMaps.FindTypeMap(@base.Type, out typeMap) && !@base.Class.IsDeclared) ||
@base.Class.OriginalClass == @class) @base.Class.OriginalClass == @class)
continue; continue;
@ -2682,7 +2682,7 @@ namespace CppSharp.Generators.CSharp
TypeMap typeMap; TypeMap typeMap;
string construct = null; string construct = null;
if (Context.TypeDatabase.FindTypeMap(retClass, out typeMap)) if (Context.TypeMaps.FindTypeMap(retClass, out typeMap))
construct = typeMap.CSharpConstruct(); construct = typeMap.CSharpConstruct();
if (construct == null) if (construct == null)

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

@ -70,7 +70,7 @@ namespace CppSharp.Generators.CSharp
public BindingContext Context { get; set; } public BindingContext Context { get; set; }
public DriverOptions Options { get { return Context.Options; } } public DriverOptions Options { get { return Context.Options; } }
public TypeMapDatabase TypeMapDatabase { get { return Context.TypeDatabase; } } public TypeMapDatabase TypeMapDatabase { get { return Context.TypeMaps; } }
public CSharpTypePrinter(BindingContext context) public CSharpTypePrinter(BindingContext context)
{ {

2
src/Generator/Passes/Pass.cs

@ -15,7 +15,7 @@ namespace CppSharp.Passes
public IDiagnostics Diagnostics { get { return Context.Diagnostics; } } public IDiagnostics Diagnostics { get { return Context.Diagnostics; } }
public DriverOptions Options { get { return Context.Options; } } public DriverOptions Options { get { return Context.Options; } }
public ASTContext ASTContext { get { return Context.ASTContext; } } public ASTContext ASTContext { get { return Context.ASTContext; } }
public TypeMapDatabase TypeDatabase { get { return Context.TypeDatabase; } } public TypeMapDatabase TypeDatabase { get { return Context.TypeMaps; } }
public bool ClearVisitedDeclarations = false; public bool ClearVisitedDeclarations = false;

Loading…
Cancel
Save