From a5315aeec43b9d7f8e783ca04b78fc1539d2ace4 Mon Sep 17 00:00:00 2001 From: triton Date: Thu, 22 Aug 2013 01:27:00 +0100 Subject: [PATCH] Reworked native C++ pointer type printing. --- src/Generator/Types/CppTypePrinter.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Generator/Types/CppTypePrinter.cs b/src/Generator/Types/CppTypePrinter.cs index 562b6d8e..8b699fcd 100644 --- a/src/Generator/Types/CppTypePrinter.cs +++ b/src/Generator/Types/CppTypePrinter.cs @@ -47,15 +47,27 @@ namespace CppSharp.Types public string VisitPointerType(PointerType pointer, TypeQualifiers quals) { - var s = string.Empty; + var pointee = pointer.Pointee; - if (quals.IsConst) - s += "const "; + var function = pointee as FunctionType; + if (function != null) + { + var arguments = function.Parameters; + var returnType = function.ReturnType; + var args = string.Empty; + + if (arguments.Count > 0) + args = VisitParameters(function.Parameters, hasNames: false); + return string.Format("{0} (*)({1})", returnType.Visit(this), args); + } + + var pointeeType = pointer.Pointee.Visit(this, quals); var mod = ConvertModifierToString(pointer.Modifier); - var pointee = pointer.Pointee.Visit(this, quals); - s += string.Format("{0}{1}", pointee, mod); + var s = quals.IsConst ? "const " : string.Empty; + s += string.Format("{0}{1}", pointeeType, mod); + return s; }