Skip to content

Commit

Permalink
Make generated code use the same style as godot-cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
chocola-mint committed Nov 16, 2023
1 parent 08740af commit f69f231
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions source/RegAutomation/RegAutomation.Core/PropertyBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,16 @@ public static (string propertyBindings, string functionBindings, string function

// For Ref<T>s, re-wrap the property type with Ref to match with C++ definition.
if(propertyReferenceType is PropertyReferenceType.Ref)
propertyType = $"Ref<{propertyType}>";
propertyType = $"Ref<{propertyType}> ";
// For pointers, we insert the pointer asterisk back into the function declarations.
// We can't put this on propertyType because the asterisk is placed right next to the type for the getter,
// but right next to the parameter for the setter.
string pointerSymbol;
if (propertyReferenceType is PropertyReferenceType.Pointer)
pointerSymbol = "*";
else if (propertyReferenceType is PropertyReferenceType.Pointer)
propertyType = $"{propertyType} *";
else
pointerSymbol = "";
propertyType = $"{propertyType} ";

// Finally, construct the getters and setters.
string genGetterDeclaration = $"\t{propertyType}{pointerSymbol} _gen_{getter}() const {{ return {propertyName}; }}\n";
string genSetterDeclaration = $"\tvoid _gen_{setter}({propertyType} {pointerSymbol}p) {{ {propertyName} = p; }}\n";
string genGetterDeclaration = $"\t{propertyType}_gen_{getter}() const {{ return {propertyName}; }}\n";
string genSetterDeclaration = $"\tvoid _gen_{setter}({propertyType}p) {{ {propertyName} = p; }}\n";

return new (
addPropertyStatement,
Expand Down

0 comments on commit f69f231

Please sign in to comment.