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
11 changes: 11 additions & 0 deletions utils/SkiaSharpGenerator/BaseTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,17 @@ static string RemovePrefixSuffix(string member, string type)
}
}

protected bool IncludeNamespace(string name)
{
foreach (var ns in config.Namespaces)
{
if (name.StartsWith(ns.Key) && ns.Value.Exclude == true)
return false;
}

return true;
}

protected string GetNamespace(string name)
{
foreach (var ns in config.Namespaces)
Expand Down
3 changes: 3 additions & 0 deletions utils/SkiaSharpGenerator/ConfigJson/NamespaceMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ public class NamespaceMapping

[JsonPropertyName("prefix")]
public string? Prefix { get; set; }

[JsonPropertyName("exclude")]
public bool? Exclude { get; set; }
}
}
4 changes: 4 additions & 0 deletions utils/SkiaSharpGenerator/Generate/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private void WriteDelegates(TextWriter writer)

var delegates = compilation.Typedefs
.Where(t => t.ElementType.TypeKind == CppTypeKind.Pointer)
.Where(t => IncludeNamespace(t.GetDisplayName()))
.OrderBy(t => t.GetDisplayName())
.GroupBy(t => GetNamespace(t.GetDisplayName()));

Expand Down Expand Up @@ -149,6 +150,7 @@ private void WriteStructs(TextWriter writer)

var classes = compilation.Classes
.Where(c => c.SizeOf != 0)
.Where(c => IncludeNamespace(c.GetDisplayName()))
.OrderBy(c => c.GetDisplayName())
.GroupBy(c => GetNamespace(c.GetDisplayName()));

Expand Down Expand Up @@ -313,6 +315,7 @@ private void WriteEnums(TextWriter writer)
writer.WriteLine($"#region Enums");

var enums = compilation.Enums
.Where(e => IncludeNamespace(e.GetDisplayName()))
.OrderBy(e => e.GetDisplayName())
.GroupBy(e => GetNamespace(e.GetDisplayName()));

Expand Down Expand Up @@ -437,6 +440,7 @@ private void WriteFunctions(TextWriter writer)
Log?.LogVerbose(" Writing p/invokes...");

var functionGroups = compilation.Functions
.Where(f => IncludeNamespace(f.Name))
.OrderBy(f => f.Name)
.GroupBy(f => f.Span.Start.File.ToLower().Replace("\\", "/"))
.OrderBy(g => Path.GetDirectoryName(g.Key) + "/" + Path.GetFileName(g.Key));
Expand Down