Browse Source

Fix generation of field property setters in C++ generator.

pull/1328/head
João Matos 6 years ago committed by João Matos
parent
commit
daef4342c1
  1. 15
      src/Generator/Generators/C/CppSources.cs

15
src/Generator/Generators/C/CppSources.cs

@ -226,10 +226,10 @@ namespace CppSharp.Generators.Cpp
if (property.HasGetter) if (property.HasGetter)
GeneratePropertyGetter(property.GetMethod); GeneratePropertyGetter(property.GetMethod);
if (property.HasSetter) if (property.HasSetter && property.SetMethod != null)
GeneratePropertySetter(property.SetMethod); GeneratePropertySetter(property.SetMethod);
PopBlock(); PopBlock(NewLineKind.Never);
return true; return true;
} }
@ -447,11 +447,18 @@ namespace CppSharp.Generators.Cpp
var method = function as Method; var method = function as Method;
var @class = function.Namespace as Class; var @class = function.Namespace as Class;
var field = (method?.AssociatedDeclaration as Property)?.Field; var property = method?.AssociatedDeclaration as Property;
var field = property?.Field;
if (field != null) if (field != null)
{ {
Write($"((::{@class.QualifiedOriginalName}*){Helpers.InstanceIdentifier})->"); Write($"((::{@class.QualifiedOriginalName}*){Helpers.InstanceIdentifier})->");
WriteLine ($"{field.OriginalName};"); Write($"{field.OriginalName}");
var isGetter = property.GetMethod == method;
if (isGetter)
WriteLine(";");
else
WriteLine($" = {@params[0].Name};");
} }
else else
{ {

Loading…
Cancel
Save