Permalink
Browse files

Moved the handling of indexers to the C# marshaller.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Aug 5, 2017
1 parent 787798f commit 47633db649889f9a88a9c0008e658cc3a8e1f1a4
@@ -169,6 +169,10 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)
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;
}
@@ -2754,7 +2754,8 @@ into context
ArgName = Helpers.ReturnIdentifier,
ReturnVarName = Helpers.ReturnIdentifier,
ReturnType = returnType,
Parameter = operatorParam
Parameter = operatorParam,
Function = function
};
var marshal = new CSharpMarshalNativeToManagedPrinter(ctx);
@@ -2766,14 +2767,7 @@ into context
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();

0 comments on commit 47633db

Please sign in to comment.