From c36145b29dd5e8ae273557c2a31fd4d8a7a044be Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Tue, 31 Aug 2021 22:53:06 +0300 Subject: [PATCH] Bind default constructors with dependent pointers Signed-off-by: Dimitar Dobrev --- src/AST/FunctionExtensions.cs | 2 +- tests/CSharp/CSharp.Tests.cs | 4 +++- tests/CSharp/CSharpTemplates.h | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/AST/FunctionExtensions.cs b/src/AST/FunctionExtensions.cs index e8e2848e..5666d000 100644 --- a/src/AST/FunctionExtensions.cs +++ b/src/AST/FunctionExtensions.cs @@ -95,7 +95,7 @@ namespace CppSharp.AST public static bool NeedsSymbol(this Method method) { - Class @class = (Class) method.Namespace; + Class @class = (Class) (method.OriginalFunction ?? method).Namespace; // virtual functions cannot really be inlined and // we don't need their symbols anyway as we call them through the v-table return (!method.IsVirtual && !method.IsSynthetized && diff --git a/tests/CSharp/CSharp.Tests.cs b/tests/CSharp/CSharp.Tests.cs index fc206f72..0218ed6e 100644 --- a/tests/CSharp/CSharp.Tests.cs +++ b/tests/CSharp/CSharp.Tests.cs @@ -1334,8 +1334,10 @@ public unsafe class CSharpTests [Test] public void TestFieldWithDependentPointerType() { - using (var dependentPointerFields = new DependentPointerFields(0)) + float f = 0.5f; + using (var dependentPointerFields = DependentPointerFieldsExtensions.DependentPointerFields(ref f)) { + Assert.That(dependentPointerFields.Property, Is.EqualTo(f)); } } diff --git a/tests/CSharp/CSharpTemplates.h b/tests/CSharp/CSharpTemplates.h index f359fa00..dd891b7a 100644 --- a/tests/CSharp/CSharpTemplates.h +++ b/tests/CSharp/CSharpTemplates.h @@ -260,7 +260,7 @@ template class DependentPointerFields { public: - DependentPointerFields(T t = 0); + DependentPointerFields(T* t = 0); ~DependentPointerFields(); T property(); T takeField(T t); @@ -268,7 +268,7 @@ public: }; template -DependentPointerFields::DependentPointerFields(T t) +DependentPointerFields::DependentPointerFields(T* t) : field(t) { }