Browse Source

CLI.Gen.cs: fix omitted typemap from previous commit

pull/1802/head
Deadlocklogic 2 years ago
parent
commit
473ecf9ed3
  1. 54
      tests/dotnet/CLI/CLI.Gen.cs

54
tests/dotnet/CLI/CLI.Gen.cs

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Generators.C;
using CppSharp.Passes;
using CppSharp.Types;
using CppSharp.Utils;
@ -21,32 +20,49 @@ namespace CppSharp.Tests @@ -21,32 +20,49 @@ namespace CppSharp.Tests
}
}
[TypeMap("TestMappedTypeNonConstRefParam", GeneratorKindID = GeneratorKind.CLI_ID)]
public class TestMappedTypeNonConstRefParamTypeMap : TypeMap
namespace CLI
{
public override Type SignatureType(TypePrinterContext ctx, GeneratorKind kind)
{
return new CILType(typeof(string));
}
public override void MarshalToManaged(MarshalContext ctx, GeneratorKind kind)
[TypeMap("TestMappedTypeNonConstRefParam", GeneratorKindID = GeneratorKind.CLI_ID)]
public class TestMappedTypeNonConstRefParamTypeMap : TypeMap
{
ctx.Return.Write("clix::marshalString<clix::E_UTF8>({0}.m_str)", ctx.ReturnVarName);
}
public override Type SignatureType(TypePrinterContext ctx, GeneratorKind kind)
{
return new CILType(typeof(string));
}
public override void MarshalToNative(MarshalContext ctx, GeneratorKind kind)
{
if (ctx.Parameter.Usage == ParameterUsage.InOut)
public override void MarshalToManaged(MarshalContext ctx, GeneratorKind kind)
{
ctx.Before.WriteLine($"System::String^ _{ctx.Parameter.Name} = {ctx.Parameter.Name};");
ctx.Return.Write("clix::marshalString<clix::E_UTF8>({0}.m_str)", ctx.ReturnVarName);
}
string paramName = ctx.Parameter.Usage == ParameterUsage.InOut ? $"_{ctx.Parameter.Name}" : ctx.Parameter.Name;
public override void MarshalToNative(MarshalContext ctx, GeneratorKind kind)
{
if (ctx.Parameter.Usage == ParameterUsage.InOut)
{
ctx.Before.WriteLine($"System::String^ _{ctx.Parameter.Name} = {ctx.Parameter.Name};");
}
ctx.Before.WriteLine(
$"::TestMappedTypeNonConstRefParam _{ctx.ArgName} = clix::marshalString<clix::E_UTF8>({paramName});");
string paramName = ctx.Parameter.Usage == ParameterUsage.InOut ? $"_{ctx.Parameter.Name}" : ctx.Parameter.Name;
ctx.Return.Write("_{0}", ctx.ArgName);
ctx.Before.WriteLine(
$"::TestMappedTypeNonConstRefParam _{ctx.ArgName} = clix::marshalString<clix::E_UTF8>({paramName});");
ctx.Return.Write("_{0}", ctx.ArgName);
}
}
}
namespace Cpp
{
[TypeMap("TestMappedTypeNonConstRefParam", GeneratorKindID = GeneratorKind.CPlusPlus_ID)]
public class TestMappedTypeNonConstRefParamTypeMap : TypeMap
{
public override Type SignatureType(TypePrinterContext ctx, GeneratorKind kind)
{
var tagType = ctx.Type as TagType;
var typePrinter = new CppTypePrinter(Context);
return new CustomType(tagType.Declaration.Visit(typePrinter));
}
}
}

Loading…
Cancel
Save