Skip to content

Commit 1610aa5

Browse files
Build Agentddobrev
Build Agent
authored andcommitted
Generate valid C++/CLI for passed primitive refs
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 64b1efd commit 1610aa5

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

Diff for: src/Generator/Generators/CLI/CLISources.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1177,12 +1177,6 @@ private ParamMarshal GenerateFunctionParamMarshal(Parameter param, int paramInde
11771177
// tracking references when using in/out, we normalize them here to be able
11781178
// to use the same code for marshaling.
11791179
var paramType = param.Type;
1180-
if (paramType is PointerType && isRef)
1181-
{
1182-
if (!paramType.IsReference())
1183-
paramMarshal.Prefix = "&";
1184-
paramType = (paramType as PointerType).Pointee;
1185-
}
11861180

11871181
var effectiveParam = new Parameter(param)
11881182
{
@@ -1196,7 +1190,10 @@ private ParamMarshal GenerateFunctionParamMarshal(Parameter param, int paramInde
11961190
ArgName = argName,
11971191
Function = function
11981192
};
1193+
if (true)
1194+
{
11991195

1196+
}
12001197
var marshal = new CLIMarshalManagedToNativePrinter(ctx);
12011198
effectiveParam.Visit(marshal);
12021199

Diff for: tests/Common/Common.Tests.cs

+8
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,14 @@ public void TestUTF8()
981981
}
982982
}
983983

984+
[Test]
985+
public void TestPointerToPrimitiveTypedefPointerTestMethod()
986+
{
987+
int a = 50;
988+
Common.PointerToPrimitiveTypedefPointerTestMethod(ref a, 100);
989+
Assert.AreEqual(100, a);
990+
}
991+
984992
private class CustomDerivedFromVirtual : AbstractWithVirtualDtor
985993
{
986994
public override void Abstract()

Diff for: tests/Common/Common.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,11 @@ LPCSTR TakeTypedefedMappedType(LPCSTR string)
11741174
return UTF8.data();
11751175
}
11761176

1177+
void DLL_API PointerToPrimitiveTypedefPointerTestMethod(LPLONG lp, int valToSet)
1178+
{
1179+
*lp = valToSet;
1180+
}
1181+
11771182
StructWithCopyCtor::StructWithCopyCtor() {}
11781183
StructWithCopyCtor::StructWithCopyCtor(const StructWithCopyCtor& other) : mBits(other.mBits) {}
11791184

Diff for: tests/Common/Common.h

+2
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,8 @@ DLL_API void overloadPointer(const void* p, int i = 0);
15431543
DLL_API const char* takeReturnUTF8(const char* utf8);
15441544
typedef const char* LPCSTR;
15451545
DLL_API LPCSTR TakeTypedefedMappedType(LPCSTR string);
1546+
typedef int* LPLONG;
1547+
void DLL_API PointerToPrimitiveTypedefPointerTestMethod(LPLONG lp, int valToSet);
15461548
DLL_API std::string UTF8;
15471549

15481550
struct DLL_API StructWithCopyCtor

0 commit comments

Comments
 (0)