Browse Source

Moved the handling of indexers to the C# marshaller.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/890/head
Dimitar Dobrev 8 years ago
parent
commit
47633db649
  1. 4
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  2. 12
      src/Generator/Generators/CSharp/CSharpSources.cs

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

@ -169,6 +169,10 @@ namespace CppSharp.Generators.CSharp @@ -169,6 +169,10 @@ namespace CppSharp.Generators.CSharp
if (Context.Context.Options.MarshalCharAsManagedChar && primitive == PrimitiveType.Char)
Context.Return.Write(string.Format("({0}) ", pointer));
if (Context.Function != null &&
Context.Function.OperatorKind == CXXOperatorKind.Subscript &&
Context.ReturnType.Type.Desugar().IsPrimitiveType(primitive))
Context.Return.Write("*");
Context.Return.Write(Context.ReturnVarName);
return true;
}

12
src/Generator/Generators/CSharp/CSharpSources.cs

@ -2754,7 +2754,8 @@ namespace CppSharp.Generators.CSharp @@ -2754,7 +2754,8 @@ namespace CppSharp.Generators.CSharp
ArgName = Helpers.ReturnIdentifier,
ReturnVarName = Helpers.ReturnIdentifier,
ReturnType = returnType,
Parameter = operatorParam
Parameter = operatorParam,
Function = function
};
var marshal = new CSharpMarshalNativeToManagedPrinter(ctx);
@ -2766,14 +2767,7 @@ namespace CppSharp.Generators.CSharp @@ -2766,14 +2767,7 @@ namespace CppSharp.Generators.CSharp
if (ctx.HasCodeBlock)
PushIndent();
// Special case for indexer - needs to dereference if the internal
// function is a pointer type and the property is not.
if (retType.Type.IsAddress() &&
retType.Type.GetPointee().Equals(returnType.Type) &&
returnType.Type.IsPrimitiveType())
WriteLine("return *{0};", marshal.Context.Return);
else
WriteLine("return {0};", marshal.Context.Return);
WriteLine($"return {marshal.Context.Return};");
if (ctx.HasCodeBlock)
WriteCloseBraceIndent();

Loading…
Cancel
Save