@@ -841,11 +841,6 @@ private void GeneratePropertySetter<T>(T decl,
841
841
Class @class , bool isAbstract = false , Property property = null )
842
842
where T : Declaration , ITypedDecl
843
843
{
844
- if ( ! ( decl is Function || decl is Field ) )
845
- {
846
- return ;
847
- }
848
-
849
844
PushBlock ( CSharpBlockKind . Method ) ;
850
845
Write ( "set" ) ;
851
846
@@ -905,9 +900,8 @@ private void GeneratePropertySetter<T>(T decl,
905
900
GenerateInternalFunctionCall ( function , new List < Parameter > { param } ) ;
906
901
}
907
902
}
908
- WriteCloseBraceIndent ( ) ;
909
903
}
910
- else
904
+ else if ( decl is Field )
911
905
{
912
906
var field = decl as Field ;
913
907
if ( WrapSetterArrayOfPointers ( decl . Name , field . Type ) )
@@ -957,9 +951,49 @@ private void GeneratePropertySetter<T>(T decl,
957
951
958
952
if ( ( arrayType != null && @class . IsValueType ) || ctx . HasCodeBlock )
959
953
WriteCloseBraceIndent ( ) ;
954
+ }
955
+ else if ( decl is Variable )
956
+ {
957
+ NewLine ( ) ;
958
+ WriteStartBraceIndent ( ) ;
959
+ var var = decl as Variable ;
960
960
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 . Kind = CSharpMarshalKind . Variable ;
980
+ ctx . ReturnType = new QualifiedType ( var . Type ) ;
981
+
982
+ var marshal = new CSharpMarshalManagedToNativePrinter ( ctx ) ;
983
+ decl . CSharpMarshalToNative ( marshal ) ;
984
+
985
+ if ( ! string . IsNullOrWhiteSpace ( marshal . Context . SupportBefore ) )
986
+ Write ( marshal . Context . SupportBefore ) ;
987
+
988
+ if ( ctx . HasCodeBlock )
989
+ PushIndent ( ) ;
990
+
991
+ WriteLine ( $ "*{ ptr } = { marshal . Context . Return } ;", marshal . Context . Return ) ;
992
+
993
+ if ( ctx . HasCodeBlock )
994
+ WriteCloseBraceIndent ( ) ;
962
995
}
996
+ WriteCloseBraceIndent ( ) ;
963
997
964
998
PopBlock ( NewLineKind . BeforeNextBlock ) ;
965
999
}
@@ -1371,7 +1405,8 @@ private void GenerateVariable(Class @class, Variable variable)
1371
1405
1372
1406
GeneratePropertyGetter ( variable . QualifiedType , variable , @class ) ;
1373
1407
1374
- if ( ! variable . QualifiedType . Qualifiers . IsConst )
1408
+ if ( ! variable . QualifiedType . Qualifiers . IsConst &&
1409
+ ! ( variable . Type . Desugar ( ) is ArrayType ) )
1375
1410
GeneratePropertySetter ( variable , @class ) ;
1376
1411
1377
1412
WriteCloseBraceIndent ( ) ;
0 commit comments