|
|
@ -21,14 +21,7 @@ namespace CppSharp.Tests |
|
|
|
|
|
|
|
|
|
|
|
public override Type CSharpSignatureType(CSharpTypePrinterContext ctx) |
|
|
|
public override Type CSharpSignatureType(CSharpTypePrinterContext ctx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var type = ctx.Type.Desugar(); |
|
|
|
return GetEnumType(ctx.Type); |
|
|
|
ClassTemplateSpecialization classTemplateSpecialization; |
|
|
|
|
|
|
|
var templateSpecializationType = type as TemplateSpecializationType; |
|
|
|
|
|
|
|
if (templateSpecializationType != null) |
|
|
|
|
|
|
|
classTemplateSpecialization = templateSpecializationType.GetClassTemplateSpecialization(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
classTemplateSpecialization = (ClassTemplateSpecialization) ((TagType) type).Declaration; |
|
|
|
|
|
|
|
return classTemplateSpecialization.Arguments[0].Type.Type; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override string CSharpSignature(CSharpTypePrinterContext ctx) |
|
|
|
public override string CSharpSignature(CSharpTypePrinterContext ctx) |
|
|
@ -38,7 +31,7 @@ namespace CppSharp.Tests |
|
|
|
|
|
|
|
|
|
|
|
public override void CSharpMarshalToNative(MarshalContext ctx) |
|
|
|
public override void CSharpMarshalToNative(MarshalContext ctx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ctx.Parameter.Type.IsAddress()) |
|
|
|
if (ctx.Parameter.Type.Desugar().IsAddress()) |
|
|
|
ctx.Return.Write("new global::System.IntPtr(&{0})", ctx.Parameter.Name); |
|
|
|
ctx.Return.Write("new global::System.IntPtr(&{0})", ctx.Parameter.Name); |
|
|
|
else |
|
|
|
else |
|
|
|
ctx.Return.Write(ctx.Parameter.Name); |
|
|
|
ctx.Return.Write(ctx.Parameter.Name); |
|
|
@ -46,7 +39,28 @@ namespace CppSharp.Tests |
|
|
|
|
|
|
|
|
|
|
|
public override void CSharpMarshalToManaged(MarshalContext ctx) |
|
|
|
public override void CSharpMarshalToManaged(MarshalContext ctx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ctx.Return.Write(ctx.ReturnVarName); |
|
|
|
if (ctx.ReturnType.Type.Desugar().IsAddress()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var finalType = ctx.ReturnType.Type.GetFinalPointee() ?? ctx.ReturnType.Type; |
|
|
|
|
|
|
|
var enumType = GetEnumType(finalType); |
|
|
|
|
|
|
|
ctx.Return.Write("*({0}*) {1}", enumType, ctx.ReturnVarName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ctx.Return.Write(ctx.ReturnVarName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Type GetEnumType(Type mappedType) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var type = mappedType.Desugar(); |
|
|
|
|
|
|
|
ClassTemplateSpecialization classTemplateSpecialization; |
|
|
|
|
|
|
|
var templateSpecializationType = type as TemplateSpecializationType; |
|
|
|
|
|
|
|
if (templateSpecializationType != null) |
|
|
|
|
|
|
|
classTemplateSpecialization = templateSpecializationType.GetClassTemplateSpecialization(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
classTemplateSpecialization = (ClassTemplateSpecialization) ((TagType) type).Declaration; |
|
|
|
|
|
|
|
return classTemplateSpecialization.Arguments[0].Type.Type; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|