-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ea6bbe
commit e0b91cd
Showing
14 changed files
with
3,329 additions
and
3,292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.