Browse Source

Minor formatting fixes.

pull/144/merge
triton 12 years ago
parent
commit
f2e831ebe2
  1. 36
      src/AST/Function.cs

36
src/AST/Function.cs

@ -160,6 +160,7 @@ namespace CppSharp.AST
var hiddenParam = Parameters.Single(param => var hiddenParam = Parameters.Single(param =>
param.Kind == ParameterKind.IndirectReturnType); param.Kind == ParameterKind.IndirectReturnType);
return hiddenParam.QualifiedType; return hiddenParam.QualifiedType;
} }
} }
@ -187,24 +188,39 @@ namespace CppSharp.AST
CallingConvention = this.CallingConvention, CallingConvention = this.CallingConvention,
ReturnType = this.ReturnType ReturnType = this.ReturnType
}; };
functionType.Parameters.AddRange(Parameters); functionType.Parameters.AddRange(Parameters);
ReplaceIndirectReturnParamWithRegular(functionType); ReplaceIndirectReturnParamWithRegular(functionType);
var pointerType = new PointerType { QualifiedPointee = new QualifiedType(functionType) };
var pointerType = new PointerType
{
QualifiedPointee = new QualifiedType(functionType)
};
return new QualifiedType(pointerType); return new QualifiedType(pointerType);
} }
private static void ReplaceIndirectReturnParamWithRegular(FunctionType functionType) static void ReplaceIndirectReturnParamWithRegular(FunctionType functionType)
{ {
for (int i = functionType.Parameters.Count - 1; i >= 0; i--) for (var i = functionType.Parameters.Count - 1; i >= 0; i--)
{ {
var parameter = functionType.Parameters[i]; var parameter = functionType.Parameters[i];
if (parameter.Kind == ParameterKind.IndirectReturnType) if (parameter.Kind != ParameterKind.IndirectReturnType)
{ continue;
var ptrType = new PointerType { QualifiedPointee = new QualifiedType(parameter.Type) };
var retParam = new Parameter { Name = parameter.Name, QualifiedType = new QualifiedType(ptrType) }; var ptrType = new PointerType
functionType.Parameters.RemoveAt(i); {
functionType.Parameters.Insert(i, retParam); QualifiedPointee = new QualifiedType(parameter.Type)
} };
var retParam = new Parameter
{
Name = parameter.Name,
QualifiedType = new QualifiedType(ptrType)
};
functionType.Parameters.RemoveAt(i);
functionType.Parameters.Insert(i, retParam);
} }
} }
} }

Loading…
Cancel
Save