Added setting to DropMultipleTokens. Disabled this functionality (caused problems with some enums)

This commit is contained in:
the_fiddler 2008-01-14 23:41:53 +00:00
parent b82bf0a073
commit c15abc0d84
2 changed files with 50 additions and 52 deletions

View file

@ -73,39 +73,27 @@ namespace Bind
public static string DelegatesClass = "Delegates"; public static string DelegatesClass = "Delegates";
public static string ImportsClass = "Imports"; 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;
/// <summary> /// <summary>
/// The name of the C# enum which holds every single OpenGL enum (for compatibility purposes). /// The name of the C# enum which holds every single OpenGL enum (for compatibility purposes).
/// </summary> /// </summary>
public static string CompleteEnumName = "All"; public static string CompleteEnumName = "All";
[Flags] [Flags]
public enum Legacy public enum Legacy
{ {
/// <summary> /// <summary>Default value.</summary>
/// Default value.
/// </summary>
None = 0x00, None = 0x00,
/// <summary> /// <summary>Leave enums as plain const ints.</summary>
/// Leave enums as plain const ints.
/// </summary>
ConstIntEnums = 0x01, ConstIntEnums = 0x01,
/// <summary> /// <summary>Leave enums in the default STRANGE_capitalization.ALL_CAPS form.</summary>
/// Leave enums in the default STRANGE_capitalization.ALL_CAPS form.
/// </summary>
NoAdvancedEnumProcessing = 0x02, NoAdvancedEnumProcessing = 0x02,
/// <summary> /// <summary>Don't allow unsafe wrappers in the interface.</summary>
/// Don't allow unsafe wrappers in the interface.
/// </summary>
NoPublicUnsafeFunctions = 0x04, NoPublicUnsafeFunctions = 0x04,
/// <summary> /// <summary>Don't trim the [fdisub]v? endings from functions.</summary>
/// Don't trim the [fdisub]v? endings from functions.
/// </summary>
NoTrimFunctionEnding = NoPublicUnsafeFunctions, NoTrimFunctionEnding = NoPublicUnsafeFunctions,
/// <summary> /// <summary>Don't trim the [gl|wgl|glx|glu] prefixes from functions.</summary>
/// Don't trim the [gl|wgl|glx|glu] prefixes from functions.
/// </summary>
NoTrimFunctionPrefix = 0x08, NoTrimFunctionPrefix = 0x08,
/// <summary> /// <summary>
/// Don't spearate functions in different namespaces, according to their extension category /// 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.) /// explicitly, to avoid the 'object' overload from being called.)
/// </summary> /// </summary>
TurnVoidPointersToIntPtr = 0x20, TurnVoidPointersToIntPtr = 0x20,
/// <summary> /// <summary>Generate all possible permutations for ref/array/pointer parameters.</summary>
/// Generate all possible permutations for ref/array/pointer parameters.
/// </summary>
GenerateAllPermutations = 0x40, GenerateAllPermutations = 0x40,
/// <summary> /// <summary>Nest enums inside the GL class.</summary>
/// Nest enums inside the GL class.
/// </summary>
NestedEnums = 0x80, NestedEnums = 0x80,
/// <summary> /// <summary>Turn GLboolean to int (Boolean enum), not bool.</summary>
/// Turn GLboolean to int (Boolean enum), not bool. NoBoolParameters = 0x100,
/// </summary> /// <summary>Keep all enum tokens, even if same value (e.g. FooARB, FooEXT and FooSGI).</summary>
NoBoolParameters = 0100, NoDropMultipleTokens = 0x200,
Tao = ConstIntEnums | Tao = ConstIntEnums |
NoAdvancedEnumProcessing | NoAdvancedEnumProcessing |
NoPublicUnsafeFunctions | NoPublicUnsafeFunctions |
@ -138,9 +122,17 @@ namespace Bind
NoSeparateFunctionNamespaces | NoSeparateFunctionNamespaces |
TurnVoidPointersToIntPtr | TurnVoidPointersToIntPtr |
NestedEnums | NestedEnums |
NoBoolParameters, NoBoolParameters |
NoDropMultipleTokens,
/*GenerateAllPermutations,*/ /*GenerateAllPermutations,*/
} }
/// <summary>True if multiple tokens should be dropped (e.g. FooARB, FooEXT and FooSGI).</summary>
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"; public static string WindowsGDI = "OpenTK.Platform.Windows.API";
} }

View file

@ -216,36 +216,42 @@ namespace Bind.Structures
foreach (Constant c in e.ConstantCollection.Values) foreach (Constant c in e.ConstantCollection.Values)
Constant.TranslateConstantWithReference(c, Enum.GLEnums, Enum.AuxEnums); Constant.TranslateConstantWithReference(c, Enum.GLEnums, Enum.AuxEnums);
// When there are multiple tokens with the same value but different extension if (Settings.DropMultipleTokens)
// 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) // When there are multiple tokens with the same value but different extension
foreach (Constant c2 in e.ConstantCollection.Values) // 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")) || if (c.Name != c2.Name && c.Value == c2.Value)
c2.Name.Contains(Constant.Translate("TEXTURE_DEFORMATION_BIT_SGIX")))
{ {
} 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)); int prefer = OrderOfPreference(Utilities.GetGL2Extension(c.Name), Utilities.GetGL2Extension(c2.Name));
if (prefer == -1) if (prefer == -1)
{ {
c2.Name = ""; c2.Name = "";
c2.Value = ""; c2.Value = "";
} }
else if (prefer == 1) else if (prefer == 1)
{ {
c.Name = ""; c.Name = "";
c.Value = ""; c.Value = "";
}
} }
} }
} }
}
} }
} }