Browse Source

Fixed type maps processing bugs.

pull/169/head
triton 12 years ago
parent
commit
3849c0e0c0
  1. 11
      src/Generator/Generators/CLI/CLIMarshal.cs
  2. 8
      src/Generator/Generators/CLI/CLITypePrinter.cs
  3. 19
      src/Generator/Generators/CLI/CLITypeReferences.cs

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

@ -30,6 +30,9 @@ namespace CppSharp.Generators.CLI @@ -30,6 +30,9 @@ namespace CppSharp.Generators.CLI
public override bool VisitTagType(TagType tag, TypeQualifiers quals)
{
if (!VisitType(tag, quals))
return false;
var decl = tag.Declaration;
return decl.Visit(this);
}
@ -90,8 +93,11 @@ namespace CppSharp.Generators.CLI @@ -90,8 +93,11 @@ namespace CppSharp.Generators.CLI
return true;
}
TypeMap typeMap = null;
Context.Driver.TypeDatabase.FindTypeMap(pointee, out typeMap);
Class @class;
if (pointee.IsTagDecl(out @class))
if (pointee.IsTagDecl(out @class) && typeMap == null)
{
var instance = (pointer.IsReference) ? "&" + Context.ReturnVarName
: Context.ReturnVarName;
@ -344,6 +350,9 @@ namespace CppSharp.Generators.CLI @@ -344,6 +350,9 @@ namespace CppSharp.Generators.CLI
public override bool VisitTagType(TagType tag, TypeQualifiers quals)
{
if (!VisitType(tag, quals))
return false;
var decl = tag.Declaration;
return decl.Visit(this);
}

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

@ -43,6 +43,14 @@ namespace CppSharp.Generators.CLI @@ -43,6 +43,14 @@ namespace CppSharp.Generators.CLI
public string VisitTagType(TagType tag, TypeQualifiers quals)
{
TypeMap typeMap = null;
if (TypeMapDatabase.FindTypeMap(tag, out typeMap))
{
typeMap.Type = tag;
Context.Type = tag;
return typeMap.CLISignature(Context);
}
Declaration decl = tag.Declaration;
if (decl == null)

19
src/Generator/Generators/CLI/CLITypeReferences.cs

@ -87,26 +87,23 @@ namespace CppSharp.Generators.CLI @@ -87,26 +87,23 @@ namespace CppSharp.Generators.CLI
record.Value.Visit(this);
GenerateInclude(record);
ProcessTypeMap(record);
}
}
private void ProcessTypeMap(ASTRecord<Declaration> record)
private void GenerateInclude(ASTRecord<Declaration> record)
{
TypeMap typeMap;
if (!TypeMapDatabase.FindTypeMap(record.Value, out typeMap))
var decl = record.Value;
if(decl.Namespace == null)
return;
// Find a type map for the declaration and use it if it exists.
TypeMap typeMap;
if (TypeMapDatabase.FindTypeMap(record.Value, out typeMap))
{
typeMap.Declaration = record.Value;
typeMap.CLITypeReference(this, record);
}
private void GenerateInclude(ASTRecord<Declaration> record)
{
var decl = record.Value;
if(decl.Namespace == null)
return;
}
var declFile = decl.Namespace.TranslationUnit.FileName;

Loading…
Cancel
Save