Skip to content

Commit

Permalink
Fixed naming inconsistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
JunaMeinhold committed Sep 15, 2024
1 parent 8ea6bbe commit e0b91cd
Show file tree
Hide file tree
Showing 14 changed files with 3,329 additions and 3,292 deletions.
36 changes: 36 additions & 0 deletions Generator/NamingPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace Generator
{
using CppAst;
using HexaGen;
using HexaGen.Patching;

public class NamingPatch : PrePatch
{
private readonly string[] prefixes;

public NamingPatch(params string[] name)
{
prefixes = name;
}

protected override void PatchFunction(CsCodeGeneratorConfig settings, CppFunction cppFunction)
{
var name = settings.GetCsFunctionName(cppFunction.Name);
foreach (var prefix in prefixes)
{
if (name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
{
name = name[prefix.Length..];
}
}

if (!settings.TryGetFunctionMapping(cppFunction.Name, out var mapping))
{
mapping = new(cppFunction.Name, name, null, [], []);
settings.FunctionMappings.Add(mapping);
}

mapping.FriendlyName ??= name;
}
}
}
1 change: 1 addition & 0 deletions Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ private static bool Generate(string header, string settingsPath, string output,
generator.PatchEngine.RegisterPrePatch(new ImGuiDefinitionsPatch());
generator.PatchEngine.RegisterPrePatch(new ImGuizmoPrePatch());
generator.PatchEngine.RegisterPrePatch(new ImGuiPrePatch());
generator.PatchEngine.RegisterPrePatch(new NamingPatch("ImGui", "ImGuizmo", "ImNodes", "ImPlot"));
generator.PatchEngine.RegisterPostPatch(new ImGuiPostPatch());

generator.LogEvent += GeneratorLogEvent;
Expand Down
Loading

0 comments on commit e0b91cd

Please sign in to comment.