Add support for function deprecation.

This commit is contained in:
the_fiddler 2010-10-10 12:28:27 +00:00
parent bf4a48548e
commit 93743f913d
4 changed files with 37 additions and 0 deletions

View file

@ -162,6 +162,11 @@ namespace Bind.GL2
case "category": case "category":
d.Category = words[1]; d.Category = words[1];
break; break;
case "deprecated":
d.Deprecated = true;
d.DeprecatedVersion = words[1];
break;
} }
} }
while (!specFile.EndOfStream); while (!specFile.EndOfStream);
@ -709,10 +714,16 @@ namespace Bind.GL2
private static void WriteMethod(BindStreamWriter sw, Function f) private static void WriteMethod(BindStreamWriter sw, Function f)
{ {
if (f.Deprecated && Settings.IsEnabled(Settings.Legacy.AddDeprecationWarnings))
{
sw.WriteLine("[Obsolete(\"Deprecated in OpenGL {0}\")]", f.DeprecatedVersion);
}
if (!f.CLSCompliant) if (!f.CLSCompliant)
{ {
sw.WriteLine("[System.CLSCompliant(false)]"); sw.WriteLine("[System.CLSCompliant(false)]");
} }
sw.WriteLine("[AutoGenerated(Category = \"{0}\", Version = \"{1}\", EntryPoint = \"{2}\")]", sw.WriteLine("[AutoGenerated(Category = \"{0}\", Version = \"{1}\", EntryPoint = \"{2}\")]",
f.Category, f.Version, Settings.FunctionPrefix + f.WrappedDelegate.Name); f.Category, f.Version, Settings.FunctionPrefix + f.WrappedDelegate.Name);
sw.WriteLine("public static "); sw.WriteLine("public static ");

View file

@ -139,6 +139,7 @@
<Compile Include="..\GlobalAssemblyInfo.cs"> <Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link> <Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile> </Compile>
<Compile Include="GL2\GL4Generator.cs" />
<Compile Include="IBind.cs"> <Compile Include="IBind.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>

View file

@ -127,6 +127,8 @@ namespace Bind
NoDebugHelpers = 0x800, NoDebugHelpers = 0x800,
/// <summary>Generate both typed and untyped ("All") signatures for enum parameters.</summary> /// <summary>Generate both typed and untyped ("All") signatures for enum parameters.</summary>
KeepUntypedEnums = 0x1000, KeepUntypedEnums = 0x1000,
/// <summary>Marks deprecated functions as [Obsolete]</summary>
AddDeprecationWarnings = 0x2000,
Tao = ConstIntEnums | Tao = ConstIntEnums |
NoAdvancedEnumProcessing | NoAdvancedEnumProcessing |
NoPublicUnsafeFunctions | NoPublicUnsafeFunctions |
@ -142,6 +144,24 @@ namespace Bind
/*GenerateAllPermutations,*/ /*GenerateAllPermutations,*/
} }
// Returns true if flag is enabled.
public static bool IsEnabled(Legacy flag)
{
return (Compatibility & flag) != (Legacy)0;
}
// Enables the specified flag.
public static void Enable(Legacy flag)
{
Compatibility |= flag;
}
// Disables the specified flag.
public static void Disable(Legacy flag)
{
Compatibility &= ~flag;
}
/// <summary>True if multiple tokens should be dropped (e.g. FooARB, FooEXT and FooSGI).</summary> /// <summary>True if multiple tokens should be dropped (e.g. FooARB, FooEXT and FooSGI).</summary>
public static bool DropMultipleTokens public static bool DropMultipleTokens
{ {

View file

@ -79,6 +79,8 @@ namespace Bind.Structures
ReturnType = new Type(d.ReturnType); ReturnType = new Type(d.ReturnType);
Version = d.Version; Version = d.Version;
//this.Version = !String.IsNullOrEmpty(d.Version) ? new string(d.Version.ToCharArray()) : ""; //this.Version = !String.IsNullOrEmpty(d.Version) ? new string(d.Version.ToCharArray()) : "";
Deprecated = d.Deprecated;
DeprecatedVersion = d.DeprecatedVersion;
} }
#endregion #endregion
@ -277,6 +279,9 @@ namespace Bind.Structures
#endregion #endregion
public bool Deprecated { get; set; }
public string DeprecatedVersion { get; set; }
#endregion #endregion
#region --- Strings --- #region --- Strings ---