From 6130c896fcabd3d9e603db84061ef6358a41dc27 Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 14 Aug 2013 00:19:43 +0100 Subject: [PATCH] Extracted internal parameter gathering in its own method. --- .../Generators/CSharp/CSharpTextTemplate.cs | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 0bfdc789..387e8039 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -453,6 +453,47 @@ namespace CppSharp.Generators.CSharp return functions; } + List GatherInternalParams(Function function, out CSharpTypePrinterResult retType) + { + var @params = new List(); + + TypePrinter.PushContext(CSharpTypePrinterContextKind.Native); + + var retParam = new Parameter { QualifiedType = function.ReturnType }; + retType = retParam.CSharpType(TypePrinter); + + var method = function as Method; + if (method != null && !method.IsStatic) + { + @params.Add("global::System.IntPtr instance"); + + if (method.IsConstructor && base.Options.IsMicrosoftAbi) + retType = "global::System.IntPtr"; + } + + foreach (var param in function.Parameters) + { + if (param.Kind == ParameterKind.OperatorParameter) + continue; + + var typeName = param.CSharpType(TypePrinter); + string paramName = param.IsSynthetized ? + GeneratedIdentifier(param.Name) : SafeIdentifier(param.Name); + @params.Add(string.Format("{0} {1}", typeName, paramName)); + } + + if (method != null && method.IsConstructor) + { + var @class = (Class) method.Namespace; + if (Options.IsMicrosoftAbi && @class.Layout.HasVirtualBases) + @params.Add("int " + CSharpTextTemplate.GeneratedIdentifier("forBases")); + } + + TypePrinter.PopContext(); + + return @params; + } + private void GenerateClassInternalHead(Class @class = null) { Write("public ");