From 5d51050576e6b01f3ad56451348293a26cc2bc19 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Thu, 24 Jan 2008 09:16:49 +0000 Subject: [PATCH] Fixed capitalization of Texture2D etc. --- Source/Bind/Structures/Constant.cs | 14 ++++++++++---- Source/Bind/Structures/Enum.cs | 14 ++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Source/Bind/Structures/Constant.cs b/Source/Bind/Structures/Constant.cs index 6a3f7661..447b0252 100644 --- a/Source/Bind/Structures/Constant.cs +++ b/Source/Bind/Structures/Constant.cs @@ -138,16 +138,22 @@ namespace Bind.Structures if ((Settings.Compatibility & Settings.Legacy.NoAdvancedEnumProcessing) == Settings.Legacy.None) { bool next_char_uppercase = true; + bool is_after_digit = false; foreach (char c in s) { - if (c != '_') + if (c == '_') + next_char_uppercase = true; + else if (Char.IsDigit(c)) { - translator.Append(next_char_uppercase ? Char.ToUpper(c) : Char.ToLower(c)); - next_char_uppercase = false; + is_after_digit = true; + translator.Append(c); } else - next_char_uppercase = true; + { + translator.Append(next_char_uppercase || (is_after_digit && c == 'd') ? Char.ToUpper(c) : Char.ToLower(c)); + is_after_digit = next_char_uppercase = false; + } } translator[0] = Char.ToUpper(translator[0]); diff --git a/Source/Bind/Structures/Enum.cs b/Source/Bind/Structures/Enum.cs index 92266f38..a0b393c4 100644 --- a/Source/Bind/Structures/Enum.cs +++ b/Source/Bind/Structures/Enum.cs @@ -101,7 +101,7 @@ namespace Bind.Structures // Translate the constant's name to match .Net naming conventions if ((Settings.Compatibility & Settings.Legacy.NoAdvancedEnumProcessing) == Settings.Legacy.None) { - bool is_after_underscore = true; // Detect if we just passed a '_' and make the next char + bool is_after_underscore_or_number = true; // Detect if we just passed a '_' or a number and make the next char // uppercase. bool is_previous_uppercase = false; // Detect if previous character was uppercase, and turn // the current one to lowercase. @@ -109,16 +109,18 @@ namespace Bind.Structures foreach (char c in name) { char char_to_add; - if (c != '_') + if (c == '_') + is_after_underscore_or_number = true; + else { - char_to_add = is_after_underscore ? Char.ToUpper(c) : + if (Char.IsDigit(c)) + is_after_underscore_or_number = true; + char_to_add = is_after_underscore_or_number ? Char.ToUpper(c) : is_previous_uppercase ? Char.ToLower(c) : c; is_previous_uppercase = Char.IsUpper(c); translator.Append(char_to_add); - is_after_underscore = false; + is_after_underscore_or_number = false; } - else - is_after_underscore = true; } translator[0] = Char.ToUpper(translator[0]);