From 6759ec6754f0103643c3afd90e166605f5941f22 Mon Sep 17 00:00:00 2001 From: triton Date: Sun, 26 May 2013 18:28:57 +0100 Subject: [PATCH] Added better support for out parameters in the marshaler. --- src/Generator/Generators/CSharp/CSharpMarshal.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index 8a556b31..6172048a 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -285,8 +285,20 @@ namespace CppSharp.Generators.CSharp Class @class; if (pointee.Desugar().IsTagDecl(out @class) && @class.IsValueType) { + if (Context.Parameter.Usage == ParameterUsage.Out) + { + Context.SupportBefore.WriteLine("var {0} = new {1}.Internal();", + Helpers.GeneratedIdentifier(Context.ArgName), @class.Name); + } + else + { + Context.SupportBefore.WriteLine("var {0} = {1}.ToInternal();", + Helpers.GeneratedIdentifier(Context.ArgName), + Helpers.SafeIdentifier(Context.Parameter.Name)); + } + Context.Return.Write("new System.IntPtr(&{0})", - Context.Parameter.Name); + Helpers.GeneratedIdentifier(Context.ArgName)); return true; }