public override void CSharpMarshalToNative(MarshalContext ctx) { ctx.SupportBefore.WriteLine("var __qstring{0} = QString.FromUtf16((ushort*) Marshal.StringToHGlobalUni({1}).ToPointer(), {1}.Length);", ctx.ParameterIndex, ctx.Parameter.Name); Type type = ctx.Parameter.Type.Desugar(); if (type.IsAddress()) { ctx.Return.Write("ReferenceEquals(__qstring{0}, null) ? global::System.IntPtr.Zero : __qstring{0}.{1}", ctx.ParameterIndex, Helpers.InstanceIdentifier); return; } Class @class; type.TryGetClass(out @class); if (@class == null) { Type.TryGetClass(out @class); } var qualifiedIdentifier = CSharpMarshalNativeToManagedPrinter.QualifiedIdentifier(@class.OriginalClass ?? @class); ctx.Return.Write("ReferenceEquals(__qstring{0}, null) ? new {1}.Internal() : *({1}.Internal*) (__qstring{0}.{2})", ctx.ParameterIndex, qualifiedIdentifier, Helpers.InstanceIdentifier); }
public static void CSharpMarshalToManaged(this ITypedDecl decl, CSharpMarshalNativeToManagedPrinter printer) { CSharpMarshalToManaged(decl.QualifiedType, printer); }
public static void CSharpMarshalToManaged(this Type type, CSharpMarshalNativeToManagedPrinter printer) { CSharpMarshalToManaged(new QualifiedType(type), printer); }
public static void CSharpMarshalToManaged(this QualifiedType type, CSharpMarshalNativeToManagedPrinter printer) { printer.Context.FullType = type; type.Visit(printer); }