From 1610aa565d3a728a5eac9c4361544d2e1b5d81f6 Mon Sep 17 00:00:00 2001 From: Build Agent Date: Tue, 14 Apr 2020 17:10:19 +0100 Subject: [PATCH] Generate valid C++/CLI for passed primitive refs Signed-off-by: Dimitar Dobrev --- src/Generator/Generators/CLI/CLISources.cs | 9 +++------ tests/Common/Common.Tests.cs | 8 ++++++++ tests/Common/Common.cpp | 5 +++++ tests/Common/Common.h | 2 ++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Generator/Generators/CLI/CLISources.cs b/src/Generator/Generators/CLI/CLISources.cs index 5b7541cd15..a2d588f5d9 100644 --- a/src/Generator/Generators/CLI/CLISources.cs +++ b/src/Generator/Generators/CLI/CLISources.cs @@ -1177,12 +1177,6 @@ private ParamMarshal GenerateFunctionParamMarshal(Parameter param, int paramInde // tracking references when using in/out, we normalize them here to be able // to use the same code for marshaling. var paramType = param.Type; - if (paramType is PointerType && isRef) - { - if (!paramType.IsReference()) - paramMarshal.Prefix = "&"; - paramType = (paramType as PointerType).Pointee; - } var effectiveParam = new Parameter(param) { @@ -1196,7 +1190,10 @@ private ParamMarshal GenerateFunctionParamMarshal(Parameter param, int paramInde ArgName = argName, Function = function }; + if (true) + { + } var marshal = new CLIMarshalManagedToNativePrinter(ctx); effectiveParam.Visit(marshal); diff --git a/tests/Common/Common.Tests.cs b/tests/Common/Common.Tests.cs index 5f60e7d5b7..8af313fa42 100644 --- a/tests/Common/Common.Tests.cs +++ b/tests/Common/Common.Tests.cs @@ -981,6 +981,14 @@ public void TestUTF8() } } + [Test] + public void TestPointerToPrimitiveTypedefPointerTestMethod() + { + int a = 50; + Common.PointerToPrimitiveTypedefPointerTestMethod(ref a, 100); + Assert.AreEqual(100, a); + } + private class CustomDerivedFromVirtual : AbstractWithVirtualDtor { public override void Abstract() diff --git a/tests/Common/Common.cpp b/tests/Common/Common.cpp index 4de55acfba..1149832b15 100644 --- a/tests/Common/Common.cpp +++ b/tests/Common/Common.cpp @@ -1174,6 +1174,11 @@ LPCSTR TakeTypedefedMappedType(LPCSTR string) return UTF8.data(); } +void DLL_API PointerToPrimitiveTypedefPointerTestMethod(LPLONG lp, int valToSet) +{ + *lp = valToSet; +} + StructWithCopyCtor::StructWithCopyCtor() {} StructWithCopyCtor::StructWithCopyCtor(const StructWithCopyCtor& other) : mBits(other.mBits) {} diff --git a/tests/Common/Common.h b/tests/Common/Common.h index 3a2960ec74..12e48213b8 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -1543,6 +1543,8 @@ DLL_API void overloadPointer(const void* p, int i = 0); DLL_API const char* takeReturnUTF8(const char* utf8); typedef const char* LPCSTR; DLL_API LPCSTR TakeTypedefedMappedType(LPCSTR string); +typedef int* LPLONG; +void DLL_API PointerToPrimitiveTypedefPointerTestMethod(LPLONG lp, int valToSet); DLL_API std::string UTF8; struct DLL_API StructWithCopyCtor