+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/Generation/Generator/Model/Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,41 @@ public static string GetImportResolver(GirModel.Function function)
_ => "ImportResolver.Library"
};
}

public static bool HidesFunction(GirModel.Function function)
{
if (function.Parent is not GirModel.Class cls)
return false;

return HidesFunction(cls.Parent, function);
}

private static bool HidesFunction(GirModel.Class? cls, GirModel.Function function)
{
if (cls is null)
return false;

var publicName = GetName(function);
var matchingFunction = cls.Functions.FirstOrDefault(c => GetName(c) == publicName);

if (matchingFunction is null)
matchingFunction = GetName(cls.TypeFunction) == publicName ? cls.TypeFunction : null;

if (matchingFunction is null)
return HidesFunction(cls.Parent, function);

GirModel.Parameter[] parameters = function.Parameters.ToArray();
GirModel.Parameter[] foundParameters = matchingFunction.Parameters.ToArray();

if (parameters.Length != foundParameters.Length)
return HidesFunction(cls.Parent, function);

for (var i = 0; i < parameters.Length; i++)
{
if (!parameters[i].AnyTypeOrVarArgs.Equals(foundParameters[i].AnyTypeOrVarArgs))
return HidesFunction(cls.Parent, function);
}

return true;
}
}
4 changes: 2 additions & 2 deletions src/Generation/Generator/Renderer/Public/FunctionRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public static string Render(GirModel.Function? function)
try
{
var parameters = ParameterToNativeExpression.Initialize(function.Parameters);

var newModifier = Function.HidesFunction(function) ? "new " : string.Empty;
return @$"
{VersionAttribute.Render(function.Version)}
public static {ReturnTypeRenderer.Render(function.ReturnType)} {Function.GetName(function)}({RenderParameters(parameters)})
public static {newModifier}{ReturnTypeRenderer.Render(function.ReturnType)} {Function.GetName(function)}({RenderParameters(parameters)})
{{
{RenderFunctionContent(parameters)}
{RenderCallStatement(function, parameters, out var resultVariableName)}
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Libs/Gtk-4.0.Tests/PropertyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void TestEnum(License windowPosition)
[TestMethod]
public void TestObject()
{
var pixbuf = GdkPixbuf.Pixbuf.NewFromFile("test.bmp");
var pixbuf = GdkPixbuf.Pixbuf.NewFromFile("test.bmp") ?? throw new Exception("Missing image");
var texture = Gdk.Texture.NewForPixbuf(pixbuf);
var dialog = new AboutDialog();
dialog.Logo.Should().BeNull();
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载