Browse Source

Merge pull request #333 from ddobrev/master

Fixed the pass for changing parameter types to their respective interface, if any, not to lose any pointers
pull/335/head
João Matos 11 years ago
parent
commit
999b69dbeb
  1. 23
      src/Generator/Passes/ParamTypeToInterfacePass.cs

23
src/Generator/Passes/ParamTypeToInterfacePass.cs

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
using System.Linq;
using CppSharp.AST;
using CppSharp.AST;
namespace CppSharp.Passes
{
@ -9,25 +8,16 @@ namespace CppSharp.Passes @@ -9,25 +8,16 @@ namespace CppSharp.Passes
{
if (!function.IsOperator)
{
if (function.HasIndirectReturnTypeParameter)
ChangeToInterfaceType(function.ReturnType);
foreach (Parameter parameter in function.Parameters)
{
var parameter = function.Parameters.Find(p => p.Kind == ParameterKind.IndirectReturnType);
parameter.QualifiedType = GetInterfaceType(parameter.QualifiedType);
}
else
{
function.ReturnType = GetInterfaceType(function.ReturnType);
}
foreach (Parameter parameter in function.Parameters.Where(
p => p.Kind != ParameterKind.IndirectReturnType))
{
parameter.QualifiedType = GetInterfaceType(parameter.QualifiedType);
ChangeToInterfaceType(parameter.QualifiedType);
}
}
return base.VisitFunctionDecl(function);
}
private static QualifiedType GetInterfaceType(QualifiedType type)
private static void ChangeToInterfaceType(QualifiedType type)
{
var tagType = type.Type as TagType;
if (tagType == null)
@ -43,10 +33,9 @@ namespace CppSharp.Passes @@ -43,10 +33,9 @@ namespace CppSharp.Passes
{
var @interface = @class.Namespace.Classes.Find(c => c.OriginalClass == @class);
if (@interface != null)
return new QualifiedType(new TagType(@interface));
tagType.Declaration = @interface;
}
}
return type;
}
}
}

Loading…
Cancel
Save