Skip to content

Commit daef434

Browse files
committed
Fix generation of field property setters in C++ generator.
1 parent 23fab70 commit daef434

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Generator/Generators/C/CppSources.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ public override bool VisitProperty(Property property)
226226
if (property.HasGetter)
227227
GeneratePropertyGetter(property.GetMethod);
228228

229-
if (property.HasSetter)
229+
if (property.HasSetter && property.SetMethod != null)
230230
GeneratePropertySetter(property.SetMethod);
231231

232-
PopBlock();
232+
PopBlock(NewLineKind.Never);
233233

234234
return true;
235235
}
@@ -447,11 +447,18 @@ public void GenerateFunctionCall(Function function)
447447
var method = function as Method;
448448
var @class = function.Namespace as Class;
449449

450-
var field = (method?.AssociatedDeclaration as Property)?.Field;
450+
var property = method?.AssociatedDeclaration as Property;
451+
var field = property?.Field;
451452
if (field != null)
452453
{
453454
Write($"((::{@class.QualifiedOriginalName}*){Helpers.InstanceIdentifier})->");
454-
WriteLine ($"{field.OriginalName};");
455+
Write($"{field.OriginalName}");
456+
457+
var isGetter = property.GetMethod == method;
458+
if (isGetter)
459+
WriteLine(";");
460+
else
461+
WriteLine($" = {@params[0].Name};");
455462
}
456463
else
457464
{

0 commit comments

Comments
 (0)