@@ -841,11 +841,6 @@ private void GeneratePropertySetter<T>(T decl,
841841 Class @class , bool isAbstract = false , Property property = null )
842842 where T : Declaration , ITypedDecl
843843 {
844- if ( ! ( decl is Function || decl is Field ) )
845- {
846- return ;
847- }
848-
849844 PushBlock ( CSharpBlockKind . Method ) ;
850845 Write ( "set" ) ;
851846
@@ -905,9 +900,8 @@ private void GeneratePropertySetter<T>(T decl,
905900 GenerateInternalFunctionCall ( function , new List < Parameter > { param } ) ;
906901 }
907902 }
908- WriteCloseBraceIndent ( ) ;
909903 }
910- else
904+ else if ( decl is Field )
911905 {
912906 var field = decl as Field ;
913907 if ( WrapSetterArrayOfPointers ( decl . Name , field . Type ) )
@@ -957,9 +951,48 @@ private void GeneratePropertySetter<T>(T decl,
957951
958952 if ( ( arrayType != null && @class . IsValueType ) || ctx . HasCodeBlock )
959953 WriteCloseBraceIndent ( ) ;
954+ }
955+ else if ( decl is Variable )
956+ {
957+ NewLine ( ) ;
958+ WriteStartBraceIndent ( ) ;
959+ var var = decl as Variable ;
960960
961- WriteCloseBraceIndent ( ) ;
961+ TypePrinter . PushContext ( CSharpTypePrinterContextKind . Native ) ;
962+
963+ var location = $@ "CppSharp.SymbolResolver.ResolveSymbol(""{
964+ GetLibraryOf ( decl ) } "", ""{ var . Mangled } "")" ;
965+
966+ string ptr = Generator . GeneratedIdentifier ( "ptr" ) ;
967+ var arrayType = decl . Type as ArrayType ;
968+ var isRefTypeArray = arrayType != null && @class != null && @class . IsRefType ;
969+ if ( isRefTypeArray )
970+ WriteLine ( $@ "var { ptr } = {
971+ ( arrayType . Type . IsPrimitiveType ( PrimitiveType . Char ) &&
972+ arrayType . QualifiedType . Qualifiers . IsConst ?
973+ string . Empty : "(byte*)" ) } { location } ;" ) ;
974+ else
975+ WriteLine ( $ "var { ptr } = ({ var . Type } *){ location } ;") ;
976+
977+ TypePrinter . PopContext ( ) ;
978+
979+ ctx . ReturnType = new QualifiedType ( var . Type ) ;
980+
981+ var marshal = new CSharpMarshalManagedToNativePrinter ( ctx ) ;
982+ decl . CSharpMarshalToNative ( marshal ) ;
983+
984+ if ( ! string . IsNullOrWhiteSpace ( marshal . Context . SupportBefore ) )
985+ Write ( marshal . Context . SupportBefore ) ;
986+
987+ if ( ctx . HasCodeBlock )
988+ PushIndent ( ) ;
989+
990+ WriteLine ( $ "*{ ptr } = { marshal . Context . Return } ;", marshal . Context . Return ) ;
991+
992+ if ( ctx . HasCodeBlock )
993+ WriteCloseBraceIndent ( ) ;
962994 }
995+ WriteCloseBraceIndent ( ) ;
963996
964997 PopBlock ( NewLineKind . BeforeNextBlock ) ;
965998 }
@@ -1371,7 +1404,8 @@ private void GenerateVariable(Class @class, Variable variable)
13711404
13721405 GeneratePropertyGetter ( variable . QualifiedType , variable , @class ) ;
13731406
1374- if ( ! variable . QualifiedType . Qualifiers . IsConst )
1407+ if ( ! variable . QualifiedType . Qualifiers . IsConst &&
1408+ ! ( variable . Type . Desugar ( ) is ArrayType ) )
13751409 GeneratePropertySetter ( variable , @class ) ;
13761410
13771411 WriteCloseBraceIndent ( ) ;
0 commit comments