Browse Source

Added an "argument prefix" generator to the C# context so typemaps can add prefixes before arguments are generated.

pull/28/head
triton 12 years ago
parent
commit
eb909c6fba
  1. 6
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  2. 19
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

6
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -1,6 +1,8 @@ @@ -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 @@ -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; }
}

19
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -1589,6 +1589,7 @@ namespace CppSharp.Generators.CSharp @@ -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 @@ -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<string>();
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)
{

Loading…
Cancel
Save