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

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

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

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

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

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

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

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

@ -28,7 +28,7 @@ namespace CppSharp.Generators.CLI @@ -28,7 +28,7 @@ namespace CppSharp.Generators.CLI
public BindingContext Context { get; private set; }
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)
{

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

@ -64,7 +64,7 @@ namespace CppSharp.Generators.CSharp @@ -64,7 +64,7 @@ namespace CppSharp.Generators.CSharp
public override bool VisitType(Type type, TypeQualifiers quals)
{
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.CSharpMarshalToManaged(Context);
@ -77,7 +77,7 @@ namespace CppSharp.Generators.CSharp @@ -77,7 +77,7 @@ namespace CppSharp.Generators.CSharp
public override bool VisitDeclaration(Declaration decl)
{
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.CSharpMarshalToManaged(Context);
@ -382,7 +382,7 @@ namespace CppSharp.Generators.CSharp @@ -382,7 +382,7 @@ namespace CppSharp.Generators.CSharp
public override bool VisitType(Type type, TypeQualifiers quals)
{
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.CSharpMarshalToNative(Context);
@ -395,7 +395,7 @@ namespace CppSharp.Generators.CSharp @@ -395,7 +395,7 @@ namespace CppSharp.Generators.CSharp
public override bool VisitDeclaration(Declaration decl)
{
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.CSharpMarshalToNative(Context);

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

@ -432,11 +432,11 @@ namespace CppSharp.Generators.CSharp @@ -432,11 +432,11 @@ namespace CppSharp.Generators.CSharp
GenerateClassTemplateSpecializationInternal(nestedTemplate);
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
Context.TypeDatabase.TypeMaps.Remove(@class.Name);
Context.TypeMaps.TypeMaps.Remove(@class.Name);
}
PushBlock(CSharpBlockKind.Class);
@ -506,7 +506,7 @@ namespace CppSharp.Generators.CSharp @@ -506,7 +506,7 @@ namespace CppSharp.Generators.CSharp
PopBlock(NewLineKind.BeforeNextBlock);
if (typeMap != null)
Context.TypeDatabase.TypeMaps.Add(@class.Name, typeMap);
Context.TypeMaps.TypeMaps.Add(@class.Name, typeMap);
}
private void GenerateClassMarshals(Class @class)
@ -760,7 +760,7 @@ namespace CppSharp.Generators.CSharp @@ -760,7 +760,7 @@ namespace CppSharp.Generators.CSharp
foreach (var @base in @class.Bases.Where(b => b.Class != null))
{
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)
continue;
@ -2682,7 +2682,7 @@ namespace CppSharp.Generators.CSharp @@ -2682,7 +2682,7 @@ namespace CppSharp.Generators.CSharp
TypeMap typeMap;
string construct = null;
if (Context.TypeDatabase.FindTypeMap(retClass, out typeMap))
if (Context.TypeMaps.FindTypeMap(retClass, out typeMap))
construct = typeMap.CSharpConstruct();
if (construct == null)

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

@ -70,7 +70,7 @@ namespace CppSharp.Generators.CSharp @@ -70,7 +70,7 @@ namespace CppSharp.Generators.CSharp
public BindingContext Context { get; set; }
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)
{

2
src/Generator/Passes/Pass.cs

@ -15,7 +15,7 @@ namespace CppSharp.Passes @@ -15,7 +15,7 @@ namespace CppSharp.Passes
public IDiagnostics Diagnostics { get { return Context.Diagnostics; } }
public DriverOptions Options { get { return Context.Options; } }
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;

Loading…
Cancel
Save