diff --git a/Source/Bind/EnumProcessor.cs b/Source/Bind/EnumProcessor.cs index 14129b92..e83cd591 100644 --- a/Source/Bind/EnumProcessor.cs +++ b/Source/Bind/EnumProcessor.cs @@ -52,11 +52,37 @@ namespace Bind public EnumCollection Process(EnumCollection enums) { var nav = Overrides.CreateNavigator(); + ProcessDeleteOverrides(enums, nav); + ProcessAddOverrides(enums, nav); + enums = ProcessNames(enums, nav); enums = ProcessConstants(enums, nav); return enums; } + void ProcessAddOverrides(EnumCollection enums, XPathNavigator nav) + { + foreach (XPathNavigator add_node in nav.Select("/signatures/add")) + { + var new_enums = new XmlSpecReader().ReadEnums(add_node); + Utilities.Merge(enums, new_enums); + } + } + + void ProcessDeleteOverrides(EnumCollection enums, XPathNavigator nav) + { + var del = nav.SelectSingleNode("/signatures/delete"); + if (del != null) + { + foreach (XPathNavigator d in del.SelectChildren("function", String.Empty)) + { + string name = d.GetAttribute("name", String.Empty); + if (enums.ContainsKey(name)) + enums.Remove(name); + } + } + } + static EnumCollection ProcessNames(EnumCollection enums, XPathNavigator nav) { EnumCollection processed_enums = new EnumCollection(); @@ -99,9 +125,16 @@ namespace Bind StringBuilder translator = new StringBuilder(name.Length); // Process according to these rules: + // 0. If name starts with a vendor name, make the first letter after that 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. // 3. if current character is uppercase make next char lowercase. + var ext = Utilities.GetGL2Extension(name); + if (ext != String.Empty) + { + name = name.Replace(ext.ToUpper(), ext); + } + bool is_after_underscore_or_number = true; bool is_previous_uppercase = false; foreach (char c in name) @@ -141,7 +174,7 @@ namespace Bind translator.Replace("AttribIp", "AttribIP"); translator.Replace("SRgb", "Srgb"); - name = translator.ToString(); + name = translator.ToString().Trim(); if (name.StartsWith(Settings.EnumPrefix)) name = name.Substring(Settings.EnumPrefix.Length); @@ -152,7 +185,7 @@ namespace Bind { foreach (var e in enums.Values) { - var processed_constants = new Dictionary(e.ConstantCollection.Count); + var processed_constants = new SortedDictionary(); foreach (Constant c in e.ConstantCollection.Values) { c.Name = TranslateConstantName(c.Name, false); @@ -245,7 +278,7 @@ namespace Bind else translator.Append(s); - return translator.ToString(); + return translator.ToString().Trim(); } public static string TranslateConstantValue(string value) diff --git a/Source/Bind/FuncProcessor.cs b/Source/Bind/FuncProcessor.cs index ce31ce9f..31bc2635 100644 --- a/Source/Bind/FuncProcessor.cs +++ b/Source/Bind/FuncProcessor.cs @@ -76,13 +76,16 @@ namespace Bind return MarkCLSCompliance(wrappers); } - private void ProcessAddOverrides(DelegateCollection delegates, XPathNavigator nav) + void ProcessAddOverrides(DelegateCollection delegates, XPathNavigator nav) { - var new_delegates = new XmlSpecReader().ReadDelegates(nav.SelectSingleNode("/signatures/add")); - Utilities.Merge(delegates, new_delegates); + foreach (XPathNavigator add_node in nav.Select("/signatures/add")) + { + var new_delegates = new XmlSpecReader().ReadDelegates(add_node); + Utilities.Merge(delegates, new_delegates); + } } - private void ProcessDeleteOverrides(DelegateCollection delegates, XPathNavigator nav) + void ProcessDeleteOverrides(DelegateCollection delegates, XPathNavigator nav) { var del = nav.SelectSingleNode("/signatures/delete"); if (del != null)