From ffc96de8f96acfdf17d1ff650b84908b99a48f39 Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 23 Jan 2013 10:11:45 +0000 Subject: [PATCH] Fixed the managed to native marshaling of pointers to primitive types by following typedefs and casting when necessary. --- src/Generator/Generators/CLI/CLIMarshal.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Generator/Generators/CLI/CLIMarshal.cs b/src/Generator/Generators/CLI/CLIMarshal.cs index acefbdf3..f2546c3a 100644 --- a/src/Generator/Generators/CLI/CLIMarshal.cs +++ b/src/Generator/Generators/CLI/CLIMarshal.cs @@ -270,9 +270,17 @@ namespace Cxxi.Generators.CLI { var pointee = pointer.Pointee; - if (pointee.IsPrimitiveType(PrimitiveType.Void)) + var isVoidPtr = pointee.IsPrimitiveType(PrimitiveType.Void, + walkTypedefs: true); + + var isUInt8Ptr = pointee.IsPrimitiveType(PrimitiveType.UInt8, + walkTypedefs: true); + + if (isVoidPtr || isUInt8Ptr) { - Return = string.Format("{0}.ToPointer()", Context.Parameter.Name); + if (isUInt8Ptr) + Return += string.Format("({0})", "uint8*"); + Return += string.Format("{0}.ToPointer()", Context.Parameter.Name); return true; } @@ -324,7 +332,7 @@ namespace Cxxi.Generators.CLI case PrimitiveType.UInt64: case PrimitiveType.Float: case PrimitiveType.Double: - Return = Context.Parameter.Name; + Return += Context.Parameter.Name; return true; case PrimitiveType.WideChar: return false;