|
|
@ -2068,11 +2068,20 @@ namespace CppSharp.Generators.CSharp |
|
|
|
Type pointee; |
|
|
|
Type pointee; |
|
|
|
if (retType.Type.IsPointerTo(out pointee) && isIntPtr) |
|
|
|
if (retType.Type.IsPointerTo(out pointee) && isIntPtr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PrimitiveType primitive; |
|
|
|
pointee = pointee.Desugar(); |
|
|
|
string @null = (pointee.Desugar().IsPrimitiveType(out primitive) || |
|
|
|
string @null; |
|
|
|
pointee.Desugar().IsPointer()) && |
|
|
|
Class @class; |
|
|
|
!CSharpTypePrinter.IsConstCharString(retType) ? |
|
|
|
if (pointee.IsTagDecl(out @class) && @class.IsValueType) |
|
|
|
"IntPtr.Zero" : "null"; |
|
|
|
{ |
|
|
|
|
|
|
|
@null = string.Format("new {0}()", pointee); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
@null = (pointee.IsPrimitiveType() || |
|
|
|
|
|
|
|
pointee.IsPointer()) && |
|
|
|
|
|
|
|
!CSharpTypePrinter.IsConstCharString(retType) ? |
|
|
|
|
|
|
|
"IntPtr.Zero" : "null"; |
|
|
|
|
|
|
|
} |
|
|
|
WriteLine("if ({0} == global::System.IntPtr.Zero) return {1};", |
|
|
|
WriteLine("if ({0} == global::System.IntPtr.Zero) return {1};", |
|
|
|
Generator.GeneratedIdentifier("ret"), @null); |
|
|
|
Generator.GeneratedIdentifier("ret"), @null); |
|
|
|
} |
|
|
|
} |
|
|
|