Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improved capitalization of acronyms, like 3Tc, in enum names.

git-svn-id: https://opentk.svn.sourceforge.net/svnroot/opentk/trunk@3102 ebc5dd9b-fb1d-0410-b6f8-d24c324e9604
  • Loading branch information...
commit a60e8e2195aad77b7e4062f28678d3925eb0852a 1 parent 6f95642
the_fiddler authored
Showing with 18 additions and 4 deletions.
  1. +15 −2 Source/Bind/EnumProcessor.cs
  2. +3 −2 Source/Bind/Utilities.cs
View
17 Source/Bind/EnumProcessor.cs
@@ -97,14 +97,27 @@ public static string TranslateEnumName(string name)
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;
View
5 Source/Bind/Utilities.cs
@@ -70,9 +70,10 @@ public static class Utilities
{
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)

0 comments on commit a60e8e2

Please sign in to comment.
Something went wrong with that request. Please try again.