From 97ca64121c2a5a8972a0de20432d26378eefd15c Mon Sep 17 00:00:00 2001 From: "Stefanos A." Date: Sun, 27 Oct 2013 17:35:36 +0100 Subject: [PATCH] Made IsFlagsCollection read-write The decision whether an Enum is a flags collection is now made either by the spec reader or the enum processor (not the Enum class itself.) --- Source/Bind/Structures/Enum.cs | 13 ++++++------- Source/Bind/XmlSpecReader.cs | 7 +++++++ Source/OpenTK/Graphics/OpenGL/GLEnums.cs | 1 - 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Source/Bind/Structures/Enum.cs b/Source/Bind/Structures/Enum.cs index 51b1baa6..8e553d2f 100644 --- a/Source/Bind/Structures/Enum.cs +++ b/Source/Bind/Structures/Enum.cs @@ -23,13 +23,7 @@ namespace Bind.Structures // Returns true if the enum contains a collection of flags, i.e. 1, 2, 4, 8, ... public bool IsFlagCollection { - get - { - // It seems that all flag collections contain "Mask" in their names. - // This looks like a heuristic, but it holds 100% in practice - // (checked all enums to make sure). - return Name.Contains("Mask"); - } + get; set; } public string Name @@ -95,6 +89,11 @@ namespace Bind.Structures return sb.ToString(); } + + public void Add(Constant constant) + { + ConstantCollection.Add(constant.Name, constant); + } } #endregion diff --git a/Source/Bind/XmlSpecReader.cs b/Source/Bind/XmlSpecReader.cs index 97adc7e4..4e462fd0 100644 --- a/Source/Bind/XmlSpecReader.cs +++ b/Source/Bind/XmlSpecReader.cs @@ -157,9 +157,16 @@ namespace Bind Name = node.GetAttribute("name", String.Empty), Type = node.GetAttribute("type", String.Empty) }; + if (String.IsNullOrEmpty(e.Name)) throw new InvalidOperationException(String.Format("Empty name for enum element {0}", node.ToString())); + + // It seems that all flag collections contain "Mask" in their names. + // This looks like a heuristic, but it holds 100% in practice + // (checked all enums to make sure). + e.IsFlagCollection = e.Name.ToLower().Contains("mask"); + foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element)) { Constant c = null; diff --git a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs index 3a3607a0..af47df15 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs @@ -50653,7 +50653,6 @@ namespace OpenTK.Graphics.OpenGL /// /// Not used directly. /// - [Flags] public enum SgisTextureColorMask : int { ///