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.)
This commit is contained in:
Stefanos A. 2013-10-27 17:35:36 +01:00
parent 2444ccf082
commit 97ca64121c
3 changed files with 13 additions and 8 deletions

View file

@ -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

View file

@ -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;

View file

@ -50653,7 +50653,6 @@ namespace OpenTK.Graphics.OpenGL
/// <summary>
/// Not used directly.
/// </summary>
[Flags]
public enum SgisTextureColorMask : int
{
/// <summary>