From 787798f2bdc2670f472719c39b29d7ab50f2dc32 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sat, 5 Aug 2017 16:03:41 +0300 Subject: [PATCH] Passed the qualified return type when calling internal functions in C#. Signed-off-by: Dimitar Dobrev --- .../Generators/CSharp/CSharpSources.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index f4535da5..6d252bbd 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -1068,7 +1068,7 @@ namespace CppSharp.Generators.CSharp else if (property.GetMethod.IsVirtual) GenerateVirtualPropertyCall(property.GetMethod, @class, property); else GenerateInternalFunctionCall(property.GetMethod, - property.GetMethod.Parameters, property.QualifiedType.Type); + property.GetMethod.Parameters, property.QualifiedType); } private static Property GetActualProperty(Property property, Class c) @@ -2574,7 +2574,8 @@ namespace CppSharp.Generators.CSharp } public void GenerateInternalFunctionCall(Function function, - List parameters = null, Type returnType = null) + List parameters = null, + QualifiedType returnType = default(QualifiedType)) { if (parameters == null) parameters = function.Parameters; @@ -2595,7 +2596,7 @@ namespace CppSharp.Generators.CSharp } public void GenerateFunctionCall(string functionName, List parameters, - Function function, Type returnType = null) + Function function, QualifiedType returnType = default(QualifiedType)) { if (function.IsPure) { @@ -2604,8 +2605,8 @@ namespace CppSharp.Generators.CSharp } var retType = function.OriginalReturnType; - if (returnType == null) - returnType = retType.Type; + if (returnType.Type == null) + returnType = retType; var method = function as Method; var hasThisReturnStructor = method != null && (method.IsConstructor || method.IsDestructor); @@ -2752,7 +2753,7 @@ namespace CppSharp.Generators.CSharp { ArgName = Helpers.ReturnIdentifier, ReturnVarName = Helpers.ReturnIdentifier, - ReturnType = retType, + ReturnType = returnType, Parameter = operatorParam }; @@ -2768,8 +2769,8 @@ namespace CppSharp.Generators.CSharp // Special case for indexer - needs to dereference if the internal // function is a pointer type and the property is not. if (retType.Type.IsAddress() && - retType.Type.GetPointee().Equals(returnType) && - returnType.IsPrimitiveType()) + retType.Type.GetPointee().Equals(returnType.Type) && + returnType.Type.IsPrimitiveType()) WriteLine("return *{0};", marshal.Context.Return); else WriteLine("return {0};", marshal.Context.Return);