Skip to content

Commit a835dbf

Browse files
committed
CLI.Gen.cs: fix omitted typemap from previous commit
1 parent 6e0a7be commit a835dbf

File tree

1 file changed

+35
-19
lines changed

1 file changed

+35
-19
lines changed

tests/dotnet/CLI/CLI.Gen.cs

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using CppSharp.AST;
22
using CppSharp.Generators;
33
using CppSharp.Generators.C;
4-
using CppSharp.Passes;
54
using CppSharp.Types;
65
using CppSharp.Utils;
76

@@ -21,32 +20,49 @@ public override void MarshalToManaged(MarshalContext ctx, GeneratorKind kind)
2120
}
2221
}
2322

24-
[TypeMap("TestMappedTypeNonConstRefParam", GeneratorKindID = GeneratorKind.CLI_ID)]
25-
public class TestMappedTypeNonConstRefParamTypeMap : TypeMap
23+
namespace CLI
2624
{
27-
public override Type SignatureType(TypePrinterContext ctx, GeneratorKind kind)
28-
{
29-
return new CILType(typeof(string));
30-
}
31-
32-
public override void MarshalToManaged(MarshalContext ctx, GeneratorKind kind)
25+
[TypeMap("TestMappedTypeNonConstRefParam", GeneratorKindID = GeneratorKind.CLI_ID)]
26+
public class TestMappedTypeNonConstRefParamTypeMap : TypeMap
3327
{
34-
ctx.Return.Write("clix::marshalString<clix::E_UTF8>({0}.m_str)", ctx.ReturnVarName);
35-
}
28+
public override Type SignatureType(TypePrinterContext ctx, GeneratorKind kind)
29+
{
30+
return new CILType(typeof(string));
31+
}
3632

37-
public override void MarshalToNative(MarshalContext ctx, GeneratorKind kind)
38-
{
39-
if (ctx.Parameter.Usage == ParameterUsage.InOut)
33+
public override void MarshalToManaged(MarshalContext ctx, GeneratorKind kind)
4034
{
41-
ctx.Before.WriteLine($"System::String^ _{ctx.Parameter.Name} = {ctx.Parameter.Name};");
35+
ctx.Return.Write("clix::marshalString<clix::E_UTF8>({0}.m_str)", ctx.ReturnVarName);
4236
}
4337

44-
string paramName = ctx.Parameter.Usage == ParameterUsage.InOut ? $"_{ctx.Parameter.Name}" : ctx.Parameter.Name;
38+
public override void MarshalToNative(MarshalContext ctx, GeneratorKind kind)
39+
{
40+
if (ctx.Parameter.Usage == ParameterUsage.InOut)
41+
{
42+
ctx.Before.WriteLine($"System::String^ _{ctx.Parameter.Name} = {ctx.Parameter.Name};");
43+
}
4544

46-
ctx.Before.WriteLine(
47-
$"::TestMappedTypeNonConstRefParam _{ctx.ArgName} = clix::marshalString<clix::E_UTF8>({paramName});");
45+
string paramName = ctx.Parameter.Usage == ParameterUsage.InOut ? $"_{ctx.Parameter.Name}" : ctx.Parameter.Name;
4846

49-
ctx.Return.Write("_{0}", ctx.ArgName);
47+
ctx.Before.WriteLine(
48+
$"::TestMappedTypeNonConstRefParam _{ctx.ArgName} = clix::marshalString<clix::E_UTF8>({paramName});");
49+
50+
ctx.Return.Write("_{0}", ctx.ArgName);
51+
}
52+
}
53+
}
54+
55+
namespace Cpp
56+
{
57+
[TypeMap("TestMappedTypeNonConstRefParam", GeneratorKindID = GeneratorKind.CPlusPlus_ID)]
58+
public class TestMappedTypeNonConstRefParamTypeMap : TypeMap
59+
{
60+
public override Type SignatureType(TypePrinterContext ctx, GeneratorKind kind)
61+
{
62+
var tagType = ctx.Type as TagType;
63+
var typePrinter = new CppTypePrinter(Context);
64+
return new CustomType(tagType.Declaration.Visit(typePrinter));
65+
}
5066
}
5167
}
5268

0 commit comments

Comments
 (0)