Skip to content

Commit

Permalink
Generate valid C# for setters returning Booleans
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information
ddobrev committed Aug 30, 2021
1 parent 8803ede commit 2fdd082
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Generator/Generators/CSharp/CSharpSources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3270,8 +3270,8 @@ private ParamMarshal GenerateFunctionParamMarshal(Parameter param, int paramInde
var name = param.Name;
var function = (Function) param.Namespace;
param.Name = param.Kind == ParameterKind.ImplicitDestructorParameter ? "0" :
function.IsGenerated || function.OperatorKind == CXXOperatorKind.Subscript ?
name : "value";
ActiveBlock.Parent.Kind != BlockKind.Property ||
function.OperatorKind == CXXOperatorKind.Subscript ? name : "value";

var argName = Generator.GeneratedIdentifier("arg") + paramIndex.ToString(CultureInfo.InvariantCulture);
var paramMarshal = new ParamMarshal { Name = argName, Param = param };
Expand Down
12 changes: 6 additions & 6 deletions tests/Common/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,10 @@ int TestProperties::setterReturnsBoolean()
return _setterReturnsBoolean;
}

bool TestProperties::setSetterReturnsBoolean(int value)
bool TestProperties::setSetterReturnsBoolean(int newValue)
{
bool changed = _setterReturnsBoolean != value;
_setterReturnsBoolean = value;
bool changed = _setterReturnsBoolean != newValue;
_setterReturnsBoolean = newValue;
return changed;
}

Expand All @@ -721,10 +721,10 @@ int TestProperties::virtualSetterReturnsBoolean()
return _virtualSetterReturnsBoolean;
}

bool TestProperties::setVirtualSetterReturnsBoolean(int value)
bool TestProperties::setVirtualSetterReturnsBoolean(int newValue)
{
bool changed = _virtualSetterReturnsBoolean != value;
_virtualSetterReturnsBoolean = value;
bool changed = _virtualSetterReturnsBoolean != newValue;
_virtualSetterReturnsBoolean = newValue;
return changed;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,10 @@ struct DLL_API TestProperties
void set(int value);

int setterReturnsBoolean();
bool setSetterReturnsBoolean(int value);
bool setSetterReturnsBoolean(int newValue);

virtual int virtualSetterReturnsBoolean();
virtual bool setVirtualSetterReturnsBoolean(int value);
virtual bool setVirtualSetterReturnsBoolean(int newValue);

int nestedEnum();
int nestedEnum(int i);
Expand Down

0 comments on commit 2fdd082

Please sign in to comment.