From f60d2671686d1104cea69a3a8032c614f231ba00 Mon Sep 17 00:00:00 2001 From: Tom Spilman Date: Wed, 28 May 2014 21:14:44 -0500 Subject: [PATCH] This fixes out or in/out enum parameters to generate correctly. --- src/Generator/Generators/CSharp/CSharpMarshal.cs | 4 ++-- src/Generator/Generators/CSharp/CSharpTypePrinter.cs | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index da536cd2..19b2deae 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -149,7 +149,7 @@ namespace CppSharp.Generators.CSharp } PrimitiveType primitive; - if (pointee.IsPrimitiveType(out primitive)) + if (pointee.IsPrimitiveType(out primitive) || pointee.IsEnumType()) { var param = Context.Parameter; if (param != null && (param.IsOut || param.IsInOut)) @@ -462,7 +462,7 @@ namespace CppSharp.Generators.CSharp } PrimitiveType primitive; - if (pointee.IsPrimitiveType(out primitive)) + if (pointee.IsPrimitiveType(out primitive) || pointee.IsEnumType()) { var param = Context.Parameter; diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index 2d2989ff..80a400b4 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -232,7 +232,13 @@ namespace CppSharp.Generators.CSharp Enumeration @enum; if (desugared.TryGetEnum(out @enum)) { - return @enum.Name + "*"; + // Skip one indirection if passed by reference + var param = Context.Parameter; + if (isManagedContext && param != null && (param.IsOut || param.IsInOut) + && pointee == finalPointee) + return pointee.Visit(this, quals); + + return pointee.Visit(this, quals) + "*"; } Class @class;