From 3ee616505399f14ed85bd1a4fb759caead1f4d2f Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Tue, 13 Sep 2016 21:18:34 +0300 Subject: [PATCH] Fixed the generated C# when a virtual function returns a primitive pointer. Signed-off-by: Dimitar Dobrev --- src/Generator/Generators/CSharp/CSharpMarshal.cs | 3 ++- tests/Common/Common.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index 24406c14..aaa450da 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -494,7 +494,8 @@ namespace CppSharp.Generators.CSharp if (!VisitType(pointer, quals)) return false; - if (Context.Function != null && pointer.IsPrimitiveTypeConvertibleToRef()) + if (Context.Function != null && pointer.IsPrimitiveTypeConvertibleToRef() && + Context.Kind != CSharpMarshalKind.VTableReturnValue) { var refParamPtr = string.Format("__refParamPtr{0}", Context.ParameterIndex); Context.SupportBefore.WriteLine("fixed ({0} {1} = &{2})", diff --git a/tests/Common/Common.h b/tests/Common/Common.h index 1608eaca..5e8f4a04 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -36,7 +36,7 @@ public: class NestedAbstract { public: - virtual void abstractFunctionInNestedClass() = 0; + virtual int* abstractFunctionInNestedClass() = 0; }; Foo();