Skip to content

Commit

Permalink
Add new modifier to GetType on interface helper classes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreeve committed Jul 22, 2024
1 parent fe2ee83 commit 858faeb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Generation/Generator/Renderer/Public/FunctionRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace Generator.Renderer.Public;
internal static class FunctionRenderer
{
public static string Render(GirModel.Function? function)
{
return Render(function, forceNewModifier: false);
}

public static string Render(GirModel.Function? function, bool forceNewModifier)
{
if (function is null)
return string.Empty;
Expand All @@ -19,7 +24,7 @@ public static string Render(GirModel.Function? function)
try
{
var parameters = ParameterToNativeExpression.Initialize(function.Parameters);
var newModifier = Function.HidesFunction(function) ? "new " : string.Empty;
var newModifier = (forceNewModifier || Function.HidesFunction(function)) ? "new " : string.Empty;
return @$"
{VersionAttribute.Render(function.Version)}
public static {newModifier}{ReturnTypeRenderer.Render(function.ReturnType)} {Function.GetName(function)}({RenderParameters(parameters)})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ namespace {Namespace.GetPublicName(@interface.Namespace)};
public partial class {Interface.GetImplementationName(@interface)} : GObject.GTypeProvider
{{
{FunctionRenderer.Render(@interface.TypeFunction)}
// The implementation class also inherits from GObject.Object so GetType needs the new modifier
{FunctionRenderer.Render(@interface.TypeFunction, forceNewModifier: true)}
{@interface.Functions
.Select(FunctionRenderer.Render)
Expand Down

0 comments on commit 858faeb

Please sign in to comment.