diff --git a/src/AST/CppTypePrinter.cs b/src/AST/CppTypePrinter.cs index 40dab134..b39a3870 100644 --- a/src/AST/CppTypePrinter.cs +++ b/src/AST/CppTypePrinter.cs @@ -9,6 +9,7 @@ namespace CppSharp.AST { C, Cpp, + ObjC } public enum CppTypePrintScopeKind @@ -251,13 +252,16 @@ namespace CppSharp.AST } public string VisitParameters(IEnumerable @params, - bool hasNames) + bool hasNames = true) { var args = new List(); foreach (var param in @params) args.Add(VisitParameter(param, hasNames)); + if (PrintFlavorKind == CppTypePrintFlavorKind.ObjC) + return string.Join(" ", args); + return string.Join(", ", args); } @@ -265,11 +269,13 @@ namespace CppSharp.AST { var type = arg.Type.Visit(this, arg.QualifiedType.Qualifiers); var name = arg.Name; + var printName = hasName && !string.IsNullOrEmpty(name); - if (hasName && !string.IsNullOrEmpty(name)) - return string.Format("{0} {1}", type, name); + if (PrintFlavorKind == CppTypePrintFlavorKind.ObjC) + return printName ? string.Format(":({0}){1}", type, name) + : string.Format(":({0})", type); - return type; + return printName ? string.Format("{0} {1}", type, name) : type; } public string VisitDelegate(FunctionType function) diff --git a/src/AST/ITypePrinter.cs b/src/AST/ITypePrinter.cs index b93d2b9a..f5068dd6 100644 --- a/src/AST/ITypePrinter.cs +++ b/src/AST/ITypePrinter.cs @@ -63,7 +63,7 @@ namespace CppSharp.AST public interface ITypePrinter : ITypePrinter, ITypeVisitor { - T VisitParameters(IEnumerable @params, bool hasNames); + T VisitParameters(IEnumerable @params, bool hasNames = true); T VisitParameter(Parameter param, bool hasName = true); T VisitDelegate(FunctionType function);