diff --git a/Source/Bind/EnumProcessor.cs b/Source/Bind/EnumProcessor.cs index 3aec114b..14bf0a41 100644 --- a/Source/Bind/EnumProcessor.cs +++ b/Source/Bind/EnumProcessor.cs @@ -97,14 +97,27 @@ namespace Bind if (Char.IsDigit(name[0])) 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: // 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. - // 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_previous_uppercase = false; + int pos = 0; foreach (char c in name) { char char_to_add; diff --git a/Source/Bind/Utilities.cs b/Source/Bind/Utilities.cs index e885e0ae..89cc933f 100644 --- a/Source/Bind/Utilities.cs +++ b/Source/Bind/Utilities.cs @@ -70,9 +70,10 @@ namespace Bind { public static readonly char[] Separators = { ' ', '\n', ',', '(', ')', ';', '#' }; 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); - #region internal StreamReader OpenSpecFile(string file) internal static StreamReader OpenSpecFile(string folder, string file)