From b19057b71a579a97bb3d18be7c403756e3361002 Mon Sep 17 00:00:00 2001 From: triton Date: Thu, 9 May 2013 00:36:56 +0100 Subject: [PATCH] C# type printing fixes. --- src/Generator/Generators/CSharp/CSharpTypePrinter.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index b84b7d57..c56d9710 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -123,10 +123,6 @@ namespace CppSharp.Generators.CSharp { var pointee = pointer.Pointee.Desugar(); - if (pointee.IsPrimitiveType(PrimitiveType.Void) || - pointee.IsPrimitiveType(PrimitiveType.UInt8)) - return true; - if (pointee.IsPrimitiveType(PrimitiveType.Char) && pointer.QualifiedPointee.Qualifiers.IsConst) return true; @@ -158,6 +154,10 @@ namespace CppSharp.Generators.CSharp var isManagedContext = ContextKind == CSharpTypePrinterContextKind.Managed; + if (pointee.Desugar().IsPrimitiveType(PrimitiveType.Void) || + pointee.Desugar().IsPrimitiveType(PrimitiveType.UInt8)) + return "System.IntPtr"; + if (IsConstCharString(pointer)) return isManagedContext ? "string" : "System.IntPtr"; @@ -207,8 +207,10 @@ namespace CppSharp.Generators.CSharp FunctionType func; if (decl.Type.IsPointerTo(out func)) { + if (ContextKind == CSharpTypePrinterContextKind.Native) + return "System.IntPtr"; // TODO: Use SafeIdentifier() - return string.Format("{0}", VisitDeclaration(decl)); + return VisitDeclaration(decl); } return decl.Type.Visit(this);