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 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using CppSharp.AST; using CppSharp.AST;
using CppSharp.Types; using CppSharp.Types;
using Type = CppSharp.AST.Type;
namespace CppSharp.Generators.CSharp namespace CppSharp.Generators.CSharp
{ {
@ -16,12 +18,14 @@ namespace CppSharp.Generators.CSharp
: base(driver) : base(driver)
{ {
Kind = CSharpMarshalKind.Unknown; Kind = CSharpMarshalKind.Unknown;
ArgumentPrefix = new TextGenerator();
Cleanup = new TextGenerator(); Cleanup = new TextGenerator();
} }
public CSharpMarshalKind Kind { get; set; } public CSharpMarshalKind Kind { get; set; }
public QualifiedType FullType; public QualifiedType FullType;
public TextGenerator ArgumentPrefix { get; private set; }
public TextGenerator Cleanup { get; private set; } public TextGenerator Cleanup { get; private set; }
} }

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

@ -1589,6 +1589,7 @@ namespace CppSharp.Generators.CSharp
} }
var needsFixedThis = needsInstance && isValueType; var needsFixedThis = needsInstance && isValueType;
var @params = GenerateFunctionParamsMarshal(parameters, function);
Class retClass = null; Class retClass = null;
if (function.HasHiddenStructParameter) if (function.HasHiddenStructParameter)
@ -1602,15 +1603,17 @@ namespace CppSharp.Generators.CSharp
retClass.OriginalName); retClass.OriginalName);
} }
retType.Type = new BuiltinType(PrimitiveType.Void); var names = new List<string>();
needsReturn = false; foreach (var param in @params)
} {
var name = string.Empty;
var @params = GenerateFunctionParamsMarshal(parameters, function); if (param.Context != null
&& !string.IsNullOrWhiteSpace(param.Context.ArgumentPrefix))
name += param.Context.ArgumentPrefix;
var names = (from param in @params name += Helpers.SafeIdentifier(param.Name);
where !param.Param.Ignore names.Add(name);
select Helpers.SafeIdentifier(param.Name)).ToList(); }
if (function.HasHiddenStructParameter) if (function.HasHiddenStructParameter)
{ {

Loading…
Cancel
Save