diff --git a/Source/Bind/Settings.cs b/Source/Bind/Settings.cs index 2e3eb5cd..204c74bc 100644 --- a/Source/Bind/Settings.cs +++ b/Source/Bind/Settings.cs @@ -73,39 +73,27 @@ namespace Bind public static string DelegatesClass = "Delegates"; public static string ImportsClass = "Imports"; - public static Legacy Compatibility = Legacy.None; + // TODO: Remove legacy for for 0.3.15. + public static Legacy Compatibility = Legacy.NoDropMultipleTokens; /// /// The name of the C# enum which holds every single OpenGL enum (for compatibility purposes). /// public static string CompleteEnumName = "All"; - [Flags] public enum Legacy { - /// - /// Default value. - /// + /// Default value. None = 0x00, - /// - /// Leave enums as plain const ints. - /// + /// Leave enums as plain const ints. ConstIntEnums = 0x01, - /// - /// Leave enums in the default STRANGE_capitalization.ALL_CAPS form. - /// + /// Leave enums in the default STRANGE_capitalization.ALL_CAPS form. NoAdvancedEnumProcessing = 0x02, - /// - /// Don't allow unsafe wrappers in the interface. - /// + /// Don't allow unsafe wrappers in the interface. NoPublicUnsafeFunctions = 0x04, - /// - /// Don't trim the [fdisub]v? endings from functions. - /// + /// Don't trim the [fdisub]v? endings from functions. NoTrimFunctionEnding = NoPublicUnsafeFunctions, - /// - /// Don't trim the [gl|wgl|glx|glu] prefixes from functions. - /// + /// Don't trim the [gl|wgl|glx|glu] prefixes from functions. NoTrimFunctionPrefix = 0x08, /// /// Don't spearate functions in different namespaces, according to their extension category @@ -118,18 +106,14 @@ namespace Bind /// explicitly, to avoid the 'object' overload from being called.) /// TurnVoidPointersToIntPtr = 0x20, - /// - /// Generate all possible permutations for ref/array/pointer parameters. - /// + /// Generate all possible permutations for ref/array/pointer parameters. GenerateAllPermutations = 0x40, - /// - /// Nest enums inside the GL class. - /// + /// Nest enums inside the GL class. NestedEnums = 0x80, - /// - /// Turn GLboolean to int (Boolean enum), not bool. - /// - NoBoolParameters = 0100, + /// Turn GLboolean to int (Boolean enum), not bool. + NoBoolParameters = 0x100, + /// Keep all enum tokens, even if same value (e.g. FooARB, FooEXT and FooSGI). + NoDropMultipleTokens = 0x200, Tao = ConstIntEnums | NoAdvancedEnumProcessing | NoPublicUnsafeFunctions | @@ -138,9 +122,17 @@ namespace Bind NoSeparateFunctionNamespaces | TurnVoidPointersToIntPtr | NestedEnums | - NoBoolParameters, + NoBoolParameters | + NoDropMultipleTokens, /*GenerateAllPermutations,*/ } + + /// True if multiple tokens should be dropped (e.g. FooARB, FooEXT and FooSGI). + public static bool DropMultipleTokens + { + get { return (Settings.Compatibility & Legacy.NoDropMultipleTokens) == Legacy.None; } + set { if (value) Settings.Compatibility |= Legacy.NoDropMultipleTokens; else Settings.Compatibility &= ~Legacy.NoDropMultipleTokens; } + } public static string WindowsGDI = "OpenTK.Platform.Windows.API"; } diff --git a/Source/Bind/Structures/Enum.cs b/Source/Bind/Structures/Enum.cs index 50d8d258..92266f38 100644 --- a/Source/Bind/Structures/Enum.cs +++ b/Source/Bind/Structures/Enum.cs @@ -216,36 +216,42 @@ namespace Bind.Structures foreach (Constant c in e.ConstantCollection.Values) Constant.TranslateConstantWithReference(c, Enum.GLEnums, Enum.AuxEnums); - // When there are multiple tokens with the same value but different extension - // drop the duplicates. Order of preference: core > ARB > EXT > vendor specific - foreach (Enum e in this.Values) + if (Settings.DropMultipleTokens) { - if (e.Name == "All") - continue; - foreach (Constant c in e.ConstantCollection.Values) - foreach (Constant c2 in e.ConstantCollection.Values) + // When there are multiple tokens with the same value but different extension + // drop the duplicates. Order of preference: core > ARB > EXT > vendor specific + foreach (Enum e in this.Values) + { + if (e.Name == "All") + continue; + + foreach (Constant c in e.ConstantCollection.Values) { - if (c.Name != c2.Name && c.Value == c2.Value) + foreach (Constant c2 in e.ConstantCollection.Values) { - if (c.Name.Contains(Constant.Translate("TEXTURE_DEFORMATION_BIT_SGIX")) || - c2.Name.Contains(Constant.Translate("TEXTURE_DEFORMATION_BIT_SGIX"))) + if (c.Name != c2.Name && c.Value == c2.Value) { - } + if (c.Name.Contains(Constant.Translate("TEXTURE_DEFORMATION_BIT_SGIX")) || + c2.Name.Contains(Constant.Translate("TEXTURE_DEFORMATION_BIT_SGIX"))) + { + } - int prefer = OrderOfPreference(Utilities.GetGL2Extension(c.Name), Utilities.GetGL2Extension(c2.Name)); - if (prefer == -1) - { - c2.Name = ""; - c2.Value = ""; - } - else if (prefer == 1) - { - c.Name = ""; - c.Value = ""; + int prefer = OrderOfPreference(Utilities.GetGL2Extension(c.Name), Utilities.GetGL2Extension(c2.Name)); + if (prefer == -1) + { + c2.Name = ""; + c2.Value = ""; + } + else if (prefer == 1) + { + c.Name = ""; + c.Value = ""; + } } } } + } } }