Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
Checked the desugared type when visiting pointer types.
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
  • Loading branch information
ddobrev committed Aug 13, 2013
1 parent 90db6eb commit ef1828d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Generator/Generators/CSharp/CSharpMarshal.cs
Expand Up @@ -275,8 +275,9 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)

var pointee = pointer.Pointee;

if (pointee.IsPrimitiveType(PrimitiveType.Char) ||
pointee.IsPrimitiveType(PrimitiveType.WideChar))
Type type = pointee.Desugar();
if (type.IsPrimitiveType(PrimitiveType.Char) ||
type.IsPrimitiveType(PrimitiveType.WideChar))
{
Context.Return.Write("Marshal.StringToHGlobalAnsi({0})",
Context.Parameter.Name);
Expand All @@ -292,7 +293,7 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)
}

Class @class;
if (pointee.Desugar().IsTagDecl(out @class) && @class.IsValueType)
if (type.IsTagDecl(out @class) && @class.IsValueType)
{
if (Context.Parameter.Usage == ParameterUsage.Out)
{
Expand All @@ -312,7 +313,7 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)
}

PrimitiveType primitive;
if (pointee.IsPrimitiveType(out primitive))
if (type.IsPrimitiveType(out primitive))
{
Context.Return.Write(Context.Parameter.Name);
return true;
Expand Down

0 comments on commit ef1828d

Please sign in to comment.