@ -725,7 +725,7 @@ namespace CppSharp.Generators.CSharp
return Tuple . Create ( library , decl . Mangled ) ;
return Tuple . Create ( library , decl . Mangled ) ;
}
}
private void GeneratePropertySetter < T > ( T decl , Class @class )
private void GeneratePropertySetter < T > ( QualifiedType returnType , T decl , Class @class )
where T : Declaration , ITypedDecl
where T : Declaration , ITypedDecl
{
{
PushBlock ( CSharpBlockKind . Method ) ;
PushBlock ( CSharpBlockKind . Method ) ;
@ -753,8 +753,16 @@ namespace CppSharp.Generators.CSharp
param . QualifiedType = function . Parameters [ 0 ] . QualifiedType ;
param . QualifiedType = function . Parameters [ 0 ] . QualifiedType ;
var parameters = new List < Parameter > { param } ;
var method = function as Method ;
GenerateInternalFunctionCall ( function , parameters ) ;
if ( method ! = null & & method . IsSynthetized )
{
GenerateIndexerSetter ( returnType , method ) ;
}
else
{
var parameters = new List < Parameter > { param } ;
GenerateInternalFunctionCall ( function , parameters ) ;
}
}
}
else if ( decl is Field )
else if ( decl is Field )
{
{
@ -779,6 +787,23 @@ namespace CppSharp.Generators.CSharp
PopBlock ( NewLineKind . BeforeNextBlock ) ;
PopBlock ( NewLineKind . BeforeNextBlock ) ;
}
}
private void GenerateIndexerSetter ( QualifiedType returnType , Function function )
{
Type type ;
returnType . Type . IsPointerTo ( out type ) ;
PrimitiveType primitiveType ;
if ( type . IsPrimitiveType ( out primitiveType ) )
{
WriteLine ( "*({0}*) this[{1}] = *({0}*) value;" ,
type . ToString ( ) , function . Parameters [ 0 ] . Name ) ;
}
else
{
WriteLine ( "*({0}.Internal*) this[{1}].{2} = *({0}.Internal*) value.{2};" ,
type . ToString ( ) , function . Parameters [ 0 ] . Name , Helpers . InstanceIdentifier ) ;
}
}
private void GeneratePropertyGetter < T > ( T decl , Class @class )
private void GeneratePropertyGetter < T > ( T decl , Class @class )
where T : Declaration , ITypedDecl
where T : Declaration , ITypedDecl
{
{
@ -907,7 +932,7 @@ namespace CppSharp.Generators.CSharp
GeneratePropertyGetter ( prop . Field , @class ) ;
GeneratePropertyGetter ( prop . Field , @class ) ;
if ( prop . HasSetter )
if ( prop . HasSetter )
GeneratePropertySetter ( prop . Field , @class ) ;
GeneratePropertySetter ( prop . Field . QualifiedType , prop . Field , @class ) ;
}
}
else
else
{
{
@ -915,7 +940,7 @@ namespace CppSharp.Generators.CSharp
GeneratePropertyGetter ( prop . GetMethod , @class ) ;
GeneratePropertyGetter ( prop . GetMethod , @class ) ;
if ( prop . HasSetter )
if ( prop . HasSetter )
GeneratePropertySetter ( prop . SetMethod , @class ) ;
GeneratePropertySetter ( prop . GetMethod . ReturnType , prop . SetMethod , @class ) ;
}
}
WriteCloseBraceIndent ( ) ;
WriteCloseBraceIndent ( ) ;
@ -938,7 +963,7 @@ namespace CppSharp.Generators.CSharp
GeneratePropertyGetter ( variable , @class ) ;
GeneratePropertyGetter ( variable , @class ) ;
if ( ! variable . QualifiedType . Qualifiers . IsConst )
if ( ! variable . QualifiedType . Qualifiers . IsConst )
GeneratePropertySetter ( variable , @class ) ;
GeneratePropertySetter ( variable . QualifiedType , variable , @class ) ;
WriteCloseBraceIndent ( ) ;
WriteCloseBraceIndent ( ) ;
PopBlock ( NewLineKind . BeforeNextBlock ) ;
PopBlock ( NewLineKind . BeforeNextBlock ) ;