mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 16:35:36 +00:00
The generator now detects and adds the FlagsAttribute to bitwise collections. Fixes bug [#792] "Resharper - Bitwise operation on enum which is not marked by [Flags] attribute" (http://www.opentk.com/node/792).
This commit is contained in:
parent
9f6e2bf323
commit
370396ab7f
|
@ -466,6 +466,10 @@ namespace Bind.GL2
|
|||
using (BindStreamWriter sw = new BindStreamWriter(Path.Combine(Settings.OutputPath, enumsFile)))
|
||||
{
|
||||
WriteLicense(sw);
|
||||
|
||||
sw.WriteLine("using System;");
|
||||
sw.WriteLine();
|
||||
|
||||
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
|
||||
{
|
||||
sw.WriteLine("namespace {0}", Settings.OutputNamespace);
|
||||
|
|
|
@ -51,16 +51,6 @@ namespace Bind.Structures
|
|||
{
|
||||
get
|
||||
{
|
||||
//if (String.IsNullOrEmpty(Reference))
|
||||
// return _value;
|
||||
//else
|
||||
//{
|
||||
// Enum @ref;
|
||||
// if (Enum.GLEnums.TryGetValue(Reference, out @ref) || Enum.AuxEnums.TryGetValue(Reference, out @ref))
|
||||
// if (@ref.ConstantCollection.ContainsKey(_value))
|
||||
// return (@ref.ConstantCollection[_value] as Constant).Value;
|
||||
//}
|
||||
|
||||
return _value;
|
||||
}
|
||||
set
|
||||
|
|
|
@ -8,6 +8,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Bind.Structures
|
||||
{
|
||||
|
@ -77,6 +78,20 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
|
||||
#region public string Name
|
||||
|
||||
public string Name
|
||||
|
@ -87,14 +102,19 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region ConstantCollection
|
||||
|
||||
Dictionary<string, Constant> _constant_collection = new Dictionary<string, Constant>();
|
||||
|
||||
public IDictionary<string, Constant> ConstantCollection
|
||||
{
|
||||
get { return _constant_collection; }
|
||||
//set { _constant_collection = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TranslateName
|
||||
|
||||
public static string TranslateName(string name)
|
||||
{
|
||||
if (Utilities.Keywords.Contains(name))
|
||||
|
@ -137,6 +157,10 @@ namespace Bind.Structures
|
|||
return translator.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToString
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -149,6 +173,8 @@ namespace Bind.Structures
|
|||
return ret;
|
||||
});
|
||||
|
||||
if (IsFlagCollection)
|
||||
sb.AppendLine("[Flags]");
|
||||
sb.AppendLine("public enum " + Name);
|
||||
sb.AppendLine("{");
|
||||
|
||||
|
@ -163,6 +189,10 @@ namespace Bind.Structures
|
|||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenTK.Graphics
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
|
@ -43,6 +45,7 @@ namespace OpenTK.Graphics
|
|||
UnsignedInt = ((int)0X1405),
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum AttribMask
|
||||
{
|
||||
CurrentBit = ((int)0X00000001),
|
||||
|
@ -69,6 +72,7 @@ namespace OpenTK.Graphics
|
|||
AllAttribBits = unchecked((int)0Xffffffff),
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum ClearBufferMask
|
||||
{
|
||||
DepthBufferBit = ((int)0X00000100),
|
||||
|
@ -77,6 +81,7 @@ namespace OpenTK.Graphics
|
|||
ColorBufferBit = ((int)0X00004000),
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum ClientAttribMask
|
||||
{
|
||||
ClientPixelStoreBit = ((int)0X00000001),
|
||||
|
@ -441,6 +446,7 @@ namespace OpenTK.Graphics
|
|||
LineResetToken = ((int)0X0707),
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum FfdMaskSgix
|
||||
{
|
||||
TextureDeformationBitSgix = ((int)0X00000001),
|
||||
|
@ -2804,6 +2810,7 @@ namespace OpenTK.Graphics
|
|||
Ycrcb444Sgix = ((int)0X81bc),
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SgisTextureColorMask
|
||||
{
|
||||
TextureColorWritemaskSgis = ((int)0X81ef),
|
||||
|
@ -9867,6 +9874,7 @@ namespace OpenTK.Graphics
|
|||
UnsignedNormalized = ((int)0X8c17),
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum BufferAccessMask
|
||||
{
|
||||
MapReadBit = ((int)0X0001),
|
||||
|
|
Loading…
Reference in a new issue