@@ -910,7 +910,8 @@ private void GenerateFieldSetter(Field field, Class @class, QualifiedType fieldT
910910 ctx . PushMarshalKind ( MarshalKind . NativeField ) ;
911911
912912 var marshal = new CSharpMarshalManagedToNativePrinter ( ctx ) ;
913- ctx . Declaration = field ;
913+ ctx . PushMarshalKind ( MarshalKind . NativeField ) ;
914+ ctx . ReturnType = field . QualifiedType ;
914915
915916 param . Visit ( marshal ) ;
916917
@@ -1188,14 +1189,13 @@ private void GenerateFieldGetter(Field field, Class @class, QualifiedType return
11881189 // IntPtr ensures that non-copying object constructor is invoked.
11891190 Class typeClass ;
11901191 if ( field . Type . TryGetClass ( out typeClass ) && ! typeClass . IsValueType &&
1191- ! ASTUtils . IsMappedToPrimitive ( Context . TypeMaps , field . Type , typeClass ) )
1192+ ! ASTUtils . IsMappedToPrimitive ( Context . TypeMaps , field . Type ) )
11921193 returnVar = $ "new { CSharpTypePrinter . IntPtrType } (&{ returnVar } )";
11931194 }
11941195
11951196 var ctx = new CSharpMarshalContext ( Context , CurrentIndentation )
11961197 {
11971198 ArgName = field . Name ,
1198- Declaration = field ,
11991199 ReturnVarName = returnVar ,
12001200 ReturnType = returnType
12011201 } ;
@@ -2734,16 +2734,17 @@ public void GenerateFunctionCall(string functionName, List<Parameter> parameters
27342734 var indirectRetType = originalFunction . Parameters . First (
27352735 parameter => parameter . Kind == ParameterKind . IndirectReturnType ) ;
27362736
2737- Class retClass ;
2738- indirectRetType . Type . Desugar ( ) . TryGetClass ( out retClass ) ;
2737+ Type type = indirectRetType . Type . Desugar ( ) ;
27392738
27402739 TypeMap typeMap ;
27412740 string construct = null ;
2742- if ( Context . TypeMaps . FindTypeMap ( retClass , out typeMap ) )
2741+ if ( Context . TypeMaps . FindTypeMap ( type , out typeMap ) )
27432742 construct = typeMap . CSharpConstruct ( ) ;
27442743
27452744 if ( construct == null )
27462745 {
2746+ Class retClass ;
2747+ type . TryGetClass ( out retClass ) ;
27472748 var @class = retClass . OriginalClass ?? retClass ;
27482749 WriteLine ( $@ "var { Helpers . ReturnIdentifier } = new {
27492750 TypePrinter . PrintNative ( @class ) } ();" ) ;
@@ -2752,10 +2753,10 @@ public void GenerateFunctionCall(string functionName, List<Parameter> parameters
27522753 {
27532754 if ( string . IsNullOrWhiteSpace ( construct ) )
27542755 {
2755- var typePrinterContext = new TypePrinterContext
2756- {
2757- Type = indirectRetType . Type . Desugar ( )
2758- } ;
2756+ var typePrinterContext = new TypePrinterContext
2757+ {
2758+ Type = indirectRetType . Type . Desugar ( )
2759+ } ;
27592760
27602761 WriteLine ( "{0} {1};" , typeMap . CSharpSignatureType ( typePrinterContext ) ,
27612762 Helpers . ReturnIdentifier ) ;
0 commit comments