diff --git a/src/Generator/Generators/CLI/CLIMarshal.cs b/src/Generator/Generators/CLI/CLIMarshal.cs index 896ce2de..9cbba8c7 100644 --- a/src/Generator/Generators/CLI/CLIMarshal.cs +++ b/src/Generator/Generators/CLI/CLIMarshal.cs @@ -220,8 +220,10 @@ namespace Cxxi.Generators.CLI public class CLIMarshalManagedToNativePrinter : ITypeVisitor, IDeclVisitor { - public TextGenerator Support; + public TextGenerator SupportBefore; + public TextGenerator SupportAfter; public TextGenerator Return; + public TextGenerator ArgumentPrefix; Generator Generator { get; set; } MarshalContext Context { get; set; } @@ -231,7 +233,8 @@ namespace Cxxi.Generators.CLI Generator = gen; Context = ctx; - Support = new TextGenerator(); + SupportBefore = new TextGenerator(); + SupportAfter = new TextGenerator(); Return = new TextGenerator(); } @@ -291,7 +294,7 @@ namespace Cxxi.Generators.CLI if (pointee.IsPrimitiveType(PrimitiveType.Char)) { - Support.Write( + SupportBefore.Write( "auto _{0} = clix::marshalString({1});", Context.ArgName, Context.Parameter.Name); @@ -396,7 +399,7 @@ namespace Cxxi.Generators.CLI if (Context.Parameter.Type.IsReference()) { var argName = string.Format("_{0}", Context.ArgName); - Support.Write("auto {0} = (::{1}*)&{2};", + SupportBefore.Write("auto {0} = (::{1}*)&{2};", argName, @class.OriginalName, Context.Parameter.Name); Return.Write("*{0}", argName); diff --git a/src/Generator/Generators/CLI/CLISourcesTemplate.cs b/src/Generator/Generators/CLI/CLISourcesTemplate.cs index 2708e309..627f2668 100644 --- a/src/Generator/Generators/CLI/CLISourcesTemplate.cs +++ b/src/Generator/Generators/CLI/CLISourcesTemplate.cs @@ -304,13 +304,14 @@ namespace Cxxi.Generators.CLI if (string.IsNullOrEmpty(marshal.Return)) return null; - if (!string.IsNullOrWhiteSpace(marshal.Support)) - WriteLine(marshal.Support); + if (!string.IsNullOrWhiteSpace(marshal.SupportBefore)) + WriteLine(marshal.SupportBefore); Write("auto {0} = ", argName); WriteLine("{0};", marshal.Return); - @params.Add(new ParamMarshal { Name = argName, Param = param }); + if (!string.IsNullOrWhiteSpace(marshal.SupportAfter)) + WriteLine(marshal.SupportAfter); } }