Browse Source

Added Objective-C parameter printing to type printer.

pull/696/head
Joao Matos 9 years ago
parent
commit
e90ffcc5bd
  1. 14
      src/AST/CppTypePrinter.cs
  2. 2
      src/AST/ITypePrinter.cs

14
src/AST/CppTypePrinter.cs

@ -9,6 +9,7 @@ namespace CppSharp.AST @@ -9,6 +9,7 @@ namespace CppSharp.AST
{
C,
Cpp,
ObjC
}
public enum CppTypePrintScopeKind
@ -251,13 +252,16 @@ namespace CppSharp.AST @@ -251,13 +252,16 @@ namespace CppSharp.AST
}
public string VisitParameters(IEnumerable<Parameter> @params,
bool hasNames)
bool hasNames = true)
{
var args = new List<string>();
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 @@ -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)

2
src/AST/ITypePrinter.cs

@ -63,7 +63,7 @@ namespace CppSharp.AST @@ -63,7 +63,7 @@ namespace CppSharp.AST
public interface ITypePrinter<out T> : ITypePrinter, ITypeVisitor<T>
{
T VisitParameters(IEnumerable<Parameter> @params, bool hasNames);
T VisitParameters(IEnumerable<Parameter> @params, bool hasNames = true);
T VisitParameter(Parameter param, bool hasName = true);
T VisitDelegate(FunctionType function);

Loading…
Cancel
Save