mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-21 21:48:52 +00:00
Improved capitalization of acronyms, like 3Tc, in enum names.
This commit is contained in:
parent
85a774c902
commit
7f0e30fadc
|
@ -97,14 +97,27 @@ namespace Bind
|
||||||
if (Char.IsDigit(name[0]))
|
if (Char.IsDigit(name[0]))
|
||||||
name = Settings.ConstantPrefix + name;
|
name = Settings.ConstantPrefix + name;
|
||||||
|
|
||||||
StringBuilder translator = new StringBuilder(name.Length);
|
StringBuilder translator = new StringBuilder(name);
|
||||||
|
|
||||||
|
// Split on IHV names, to ensure that characters appearing after these name are uppercase.
|
||||||
|
var match = Utilities.Acronyms.Match(name);
|
||||||
|
while (match.Success)
|
||||||
|
{
|
||||||
|
int insert_pos = match.Index + match.Length;
|
||||||
|
translator.Insert(insert_pos, "_");
|
||||||
|
match = match.NextMatch();
|
||||||
|
}
|
||||||
|
name = translator.ToString();
|
||||||
|
translator.Remove(0, translator.Length);
|
||||||
|
|
||||||
// Process according to these rules:
|
// Process according to these rules:
|
||||||
// 1. if current char is '_', '-' remove it and make next char uppercase
|
// 1. if current char is '_', '-' remove it and make next char uppercase
|
||||||
// 2. if current char is or '0-9' keep it and make next char uppercase.
|
// 2. if current char is or '0-9' keep it and make next char uppercase.
|
||||||
// 3. if current character is uppercase make next char lowercase.
|
// 3. if current char is uppercase make next char lowercase.
|
||||||
|
// 4. if current char is lowercase, respect next char case.
|
||||||
bool is_after_underscore_or_number = true;
|
bool is_after_underscore_or_number = true;
|
||||||
bool is_previous_uppercase = false;
|
bool is_previous_uppercase = false;
|
||||||
|
int pos = 0;
|
||||||
foreach (char c in name)
|
foreach (char c in name)
|
||||||
{
|
{
|
||||||
char char_to_add;
|
char char_to_add;
|
||||||
|
|
|
@ -70,9 +70,10 @@ namespace Bind
|
||||||
{
|
{
|
||||||
public static readonly char[] Separators = { ' ', '\n', ',', '(', ')', ';', '#' };
|
public static readonly char[] Separators = { ' ', '\n', ',', '(', ')', ';', '#' };
|
||||||
public static readonly Regex Extensions = new Regex(
|
public static readonly Regex Extensions = new Regex(
|
||||||
"(ARB|EXT|ATIX|ATI|AMDX|AMD|NV|NVX|SUNX|SUN|SGIS|SGIX|SGI|MESAX|MESA|3DFX|IBM|GREMEDY|HP|INTEL|PGI|INGR|APPLE|OML|I3D|ARM|ANGLE|OES|QCOM)",
|
"ARB|EXT|ATIX|ATI|AMDX|AMD|NV|NVX|SUNX|SUN|SGIS|SGIX|SGI|MESAX|MESA|3DFX|IBM|GREMEDY|HP|INTEL|PGI|INGR|APPLE|OML|I3D|ARM|ANGLE|OES|QCOM|VIV|IMG",
|
||||||
|
RegexOptions.Compiled);
|
||||||
|
public static readonly Regex Acronyms = new Regex(Extensions.ToString() + "|EGL|3TC|DXT|ES|RGBA|BGRA|RGB|BGR|ETC",
|
||||||
RegexOptions.Compiled);
|
RegexOptions.Compiled);
|
||||||
|
|
||||||
#region internal StreamReader OpenSpecFile(string file)
|
#region internal StreamReader OpenSpecFile(string file)
|
||||||
|
|
||||||
internal static StreamReader OpenSpecFile(string folder, string file)
|
internal static StreamReader OpenSpecFile(string folder, string file)
|
||||||
|
|
Loading…
Reference in a new issue