From eb909c6fba2dd3f25c4bd79be54c5e92873f3487 Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 14 Aug 2013 00:19:10 +0100 Subject: [PATCH] Added an "argument prefix" generator to the C# context so typemaps can add prefixes before arguments are generated. --- .../Generators/CSharp/CSharpMarshal.cs | 6 +++++- .../Generators/CSharp/CSharpTextTemplate.cs | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index a2e3da4c..cc2421b2 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -1,6 +1,8 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using CppSharp.AST; using CppSharp.Types; +using Type = CppSharp.AST.Type; namespace CppSharp.Generators.CSharp { @@ -16,12 +18,14 @@ namespace CppSharp.Generators.CSharp : base(driver) { Kind = CSharpMarshalKind.Unknown; + ArgumentPrefix = new TextGenerator(); Cleanup = new TextGenerator(); } public CSharpMarshalKind Kind { get; set; } public QualifiedType FullType; + public TextGenerator ArgumentPrefix { get; private set; } public TextGenerator Cleanup { get; private set; } } diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index f8c0178f..0bfdc789 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -1589,6 +1589,7 @@ namespace CppSharp.Generators.CSharp } var needsFixedThis = needsInstance && isValueType; + var @params = GenerateFunctionParamsMarshal(parameters, function); Class retClass = null; if (function.HasHiddenStructParameter) @@ -1602,15 +1603,17 @@ namespace CppSharp.Generators.CSharp retClass.OriginalName); } - retType.Type = new BuiltinType(PrimitiveType.Void); - needsReturn = false; - } - - var @params = GenerateFunctionParamsMarshal(parameters, function); + var names = new List(); + foreach (var param in @params) + { + var name = string.Empty; + if (param.Context != null + && !string.IsNullOrWhiteSpace(param.Context.ArgumentPrefix)) + name += param.Context.ArgumentPrefix; - var names = (from param in @params - where !param.Param.Ignore - select Helpers.SafeIdentifier(param.Name)).ToList(); + name += Helpers.SafeIdentifier(param.Name); + names.Add(name); + } if (function.HasHiddenStructParameter) {